diff --git a/source/Models/Frontmatter.cs b/source/Models/Frontmatter.cs index 9937f5d197e1abf1301a196a5601cae43452ee35..6500798ce9d0a0d3423a82a4b0e2334db1990510 100644 --- a/source/Models/Frontmatter.cs +++ b/source/Models/Frontmatter.cs @@ -3,6 +3,7 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.IO; using System.Linq; +using System.Text.RegularExpressions; using Fluid; using Markdig; using SuCoS.Helpers; @@ -77,6 +78,11 @@ public class Frontmatter : IBaseContent, IParams /// public int Weight { get; set; } = 0; + /// + /// A list of tags, if any. + /// + public List? Tags { get; set; } + /// /// The source filename, without the extension. ;) /// @@ -134,9 +140,10 @@ public class Frontmatter : IBaseContent, IParams public Frontmatter? Parent { get; set; } /// - /// A list of tags, if any. + /// Plain markdown content, without HTML. /// - public List? Tags { get; set; } + [YamlIgnore] + public string Plain => Markdown.ToPlainText(RawContent, Site.MarkdownPipeline); /// /// A list of tags, if any. @@ -147,6 +154,7 @@ public class Frontmatter : IBaseContent, IParams /// /// Check if the page is expired /// + [YamlIgnore] public bool IsDateExpired => ExpiryDate is not null && ExpiryDate <= clock.Now; /// @@ -158,18 +166,29 @@ public class Frontmatter : IBaseContent, IParams /// /// Just a simple check if the current page is the home page /// + [YamlIgnore] public bool IsHome => Site.Home == this; /// /// Just a simple check if the current page is a section page /// + [YamlIgnore] public bool IsSection => Type == "section"; /// /// Just a simple check if the current page is a "page" /// + [YamlIgnore] public bool IsPage => Type == "page"; + /// + /// The number of words in the main content + /// + [YamlIgnore] + public int WordCount => + Plain.Split(new char[] { ' ', ',', ';', '.', '!', '"', '(', ')', '?' }, + StringSplitOptions.RemoveEmptyEntries).Length; + /// /// The markdown content converted to HTML ///