using System.ComponentModel.DataAnnotations.Schema; using SmartFormat; namespace OliverBooth.Data.Blog; /// internal sealed class BlogPost : IBlogPost { /// [NotMapped] public IBlogAuthor Author { get; internal set; } = null!; /// public string Body { get; internal set; } = string.Empty; /// public bool EnableComments { get; internal set; } /// public string? Excerpt { get; internal set; } /// public Guid Id { get; private set; } = Guid.NewGuid(); /// public bool IsRedirect { get; internal set; } /// public string? Password { get; internal set; } /// public DateTimeOffset Published { get; internal set; } /// public Uri? RedirectUrl { get; internal set; } /// public string Slug { get; internal set; } = string.Empty; /// public IReadOnlyList Tags { get; internal set; } = ArraySegment.Empty; /// public string Title { get; internal set; } = string.Empty; /// public DateTimeOffset? Updated { get; internal set; } /// public Visibility Visibility { get; internal set; } /// public int? WordPressId { get; set; } /// /// Gets or sets the ID of the author of this blog post. /// /// The ID of the author of this blog post. internal Guid AuthorId { get; set; } /// /// Gets or sets the base URL of the Disqus comments for the blog post. /// /// The Disqus base URL. internal string? DisqusDomain { get; set; } /// /// Gets or sets the identifier of the Disqus comments for the blog post. /// /// The Disqus identifier. internal string? DisqusIdentifier { get; set; } /// /// Gets or sets the URL path of the Disqus comments for the blog post. /// /// The Disqus URL path. internal string? DisqusPath { get; set; } /// /// Gets the Disqus domain for the blog post. /// /// The Disqus domain. public string GetDisqusDomain() { return string.IsNullOrWhiteSpace(DisqusDomain) ? "https://oliverbooth.dev/blog" : Smart.Format(DisqusDomain, this); } /// public string GetDisqusIdentifier() { return string.IsNullOrWhiteSpace(DisqusIdentifier) ? $"post-{Id}" : Smart.Format(DisqusIdentifier, this); } /// public string GetDisqusUrl() { string path = string.IsNullOrWhiteSpace(DisqusPath) ? $"{Published:yyyy/MM/dd}/{Slug}/" : Smart.Format(DisqusPath, this); return $"{GetDisqusDomain()}/{path}"; } /// public string GetDisqusPostId() { return WordPressId?.ToString() ?? Id.ToString(); } }