YaeBlog/YaeBlog.Core/Models/BlogEssay.cs

40 lines
920 B
C#
Raw Normal View History

2024-01-17 13:20:32 +08:00
namespace YaeBlog.Core.Models;
public class BlogEssay
{
public required string Title { get; init; }
2024-01-23 14:33:35 +08:00
public required string FileName { get; init; }
2024-01-17 13:20:32 +08:00
public required DateTime PublishTime { get; init; }
2024-01-24 14:00:55 +08:00
public required string Description { get; init; }
public required uint WordCount { get; init; }
2024-01-19 20:33:41 +08:00
public List<string> Tags { get; } = [];
2024-01-17 13:20:32 +08:00
public required string HtmlContent { get; init; }
2024-01-19 20:33:41 +08:00
public BlogEssay WithNewHtmlContent(string newHtmlContent)
{
var essay = new BlogEssay
{
Title = Title,
FileName = FileName,
PublishTime = PublishTime,
Description = Description,
WordCount = WordCount,
HtmlContent = newHtmlContent
};
essay.Tags.AddRange(Tags);
return essay;
}
2024-01-19 20:33:41 +08:00
public override string ToString()
{
return $"{Title}-{PublishTime}";
}
2024-01-17 13:20:32 +08:00
}