From 006bb12ce6f465e22a95a19abde73b4169d21182 Mon Sep 17 00:00:00 2001 From: Bruno Massa Date: Fri, 30 Jun 2023 14:38:36 -0300 Subject: [PATCH] feat: page IsPage IsHome IsSection getters --- source/Models/Frontmatter.cs | 16 ++++++++++++++++ source/Models/Site.cs | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/source/Models/Frontmatter.cs b/source/Models/Frontmatter.cs index 56ae87a..33cd623 100644 --- a/source/Models/Frontmatter.cs +++ b/source/Models/Frontmatter.cs @@ -117,6 +117,7 @@ public class Frontmatter : IBaseContent, IParams /// Other content that mention this content. /// Used to create the tags list and Related Posts section. /// + [YamlIgnore] public ConcurrentBag? PagesReferences { get; set; } /// @@ -136,6 +137,21 @@ public class Frontmatter : IBaseContent, IParams [YamlIgnore] public bool IsDatePublishable => GetPublishDate is null || GetPublishDate <= clock.Now; + /// + /// Just a simple check if the current page is the home page + /// + public bool IsHome => Site.Home == this; + + /// + /// Just a simple check if the current page is a section page + /// + public bool IsSection => Type == "section"; + + /// + /// Just a simple check if the current page is a "page" + /// + public bool IsPage => Type == "page"; + /// /// The markdown content converted to HTML /// diff --git a/source/Models/Site.cs b/source/Models/Site.cs index f44eeb0..4ec4c88 100644 --- a/source/Models/Site.cs +++ b/source/Models/Site.cs @@ -117,7 +117,7 @@ public class Site : IParams /// /// The frontmatter of the home page; /// - public Frontmatter? HomePage { get; set; } + public Frontmatter? Home { get; set; } /// /// List of all content to be scanned and processed. @@ -346,7 +346,7 @@ public class Site : IParams { home = CreateIndexPage(string.Empty); } - HomePage = home; + Home = home; home.Kind = Kind.index; stopwatch.Stop("Parse", filesParsed); -- GitLab