diff --git a/Models/ContentTypes/Page.Generated.cs b/Models/ContentTypes/Page.Generated.cs index 1c3b6f7..f36cd46 100644 --- a/Models/ContentTypes/Page.Generated.cs +++ b/Models/ContentTypes/Page.Generated.cs @@ -14,6 +14,7 @@ public partial class Page { public const string Codename = "page"; public const string BodyCodename = "body"; + public const string CategoriesCodename = "categories"; public const string ImageCodename = "image"; public const string MetadataMetaDescriptionCodename = "metadata__meta_description"; public const string MetadataMetaKeywordsCodename = "metadata__meta_keywords"; @@ -27,10 +28,12 @@ public partial class Page public const string MetadataTwitterSiteCodename = "metadata__twitter_site"; public const string RelatedCodename = "related"; public const string SettingsCodename = "settings"; + public const string TagsCodename = "tags"; public const string TitleCodename = "title"; public const string UrlSlugCodename = "url_slug"; public string Body { get; set; } + public IEnumerable Categories { get; set; } public IEnumerable Image { get; set; } public string MetadataMetaDescription { get; set; } public string MetadataMetaKeywords { get; set; } @@ -45,6 +48,7 @@ public partial class Page public IEnumerable Related { get; set; } public IEnumerable Settings { get; set; } public IContentItemSystemAttributes System { get; set; } + public IEnumerable Tags { get; set; } public string Title { get; set; } public string UrlSlug { get; set; } } diff --git a/Models/ContentTypes/Post.Generated.cs b/Models/ContentTypes/Post.Generated.cs index 18416e6..98a403e 100644 --- a/Models/ContentTypes/Post.Generated.cs +++ b/Models/ContentTypes/Post.Generated.cs @@ -15,6 +15,7 @@ public partial class Post public const string Codename = "post"; public const string AuthorCodename = "author"; public const string BodyCodename = "body"; + public const string CategoriesCodename = "categories"; public const string ImageCodename = "image"; public const string MetadataMetaDescriptionCodename = "metadata__meta_description"; public const string MetadataMetaKeywordsCodename = "metadata__meta_keywords"; @@ -36,6 +37,7 @@ public partial class Post public IEnumerable Author { get; set; } public string Body { get; set; } + public IEnumerable Categories { get; set; } public IEnumerable Image { get; set; } public string MetadataMetaDescription { get; set; } public string MetadataMetaKeywords { get; set; } diff --git a/Pipelines/Pages.cs b/Pipelines/Pages.cs index 3e0898c..d23509b 100644 --- a/Pipelines/Pages.cs +++ b/Pipelines/Pages.cs @@ -7,6 +7,7 @@ using Statiq.Core; using Statiq.Razor; using Statiq.SearchIndex; +using System.Linq; namespace Kentico.Kontent.Statiq.Lumen.Pipelines { @@ -19,6 +20,10 @@ public Pages(IDeliveryClient deliveryClient, SiteSettings site) new Kontent(deliveryClient) .OrderBy(Post.TitleCodename, SortOrder.Descending) .WithQuery(new DepthParameter(2), new IncludeTotalCountParameter()), + new SetMetadata(nameof(Page.Tags), + KontentConfig.Get(post => post.Tags?.Select(t => t.Codename).ToArray())), + new SetMetadata(nameof(Page.Categories), + KontentConfig.Get(post => post.Categories?.Select(t => t.Codename).ToArray())), new SetDestination(KontentConfig.Get((Page page) => new NormalizedPath(page.Url))), new SetMetadata(SearchIndex.SearchItemKey, Config.FromDocument((doc, ctx) => { diff --git a/Pipelines/Posts.cs b/Pipelines/Posts.cs index 7e37651..0bf46b0 100644 --- a/Pipelines/Posts.cs +++ b/Pipelines/Posts.cs @@ -21,6 +21,8 @@ public Posts(IDeliveryClient deliveryClient, SiteSettings site) .WithQuery(new DepthParameter(2), new IncludeTotalCountParameter()), new SetMetadata(nameof(Post.Tags), KontentConfig.Get(post => post.Tags?.Select(t => t.Codename).ToArray())), + new SetMetadata(nameof(Post.Categories), + KontentConfig.Get(post => post.Categories?.Select(t => t.Codename).ToArray())), new SetDestination(KontentConfig.Get((Post post) => new NormalizedPath(post.Url))), new SetMetadata(SearchIndex.SearchItemKey, Config.FromDocument((doc,ctx)=> { diff --git a/appsettings.json b/appsettings.json index 375eb4c..25086ce 100644 --- a/appsettings.json +++ b/appsettings.json @@ -2,7 +2,7 @@ "DeliveryOptions": { "ProjectId": "e10d7fbd-315f-01e2-20a5-e067cdf43f2f" }, - "LinkHideExtensions": "true", + "LinkHideExtensions": false, "Host": "", "LinksUseHttps": true, "LinkRoot": "", diff --git a/input/Shared/postbox.cshtml b/input/Shared/postbox.cshtml index e6b5f75..0d868c8 100644 --- a/input/Shared/postbox.cshtml +++ b/input/Shared/postbox.cshtml @@ -9,13 +9,13 @@

- @Model.Title + @Model.Title @if (Model.Rating.HasValue) {
diff --git a/input/Shared/related-posts.cshtml b/input/Shared/related-posts.cshtml new file mode 100644 index 0000000..4275d1e --- /dev/null +++ b/input/Shared/related-posts.cshtml @@ -0,0 +1,39 @@ +@using Kentico.Kontent.Statiq.Memoirs.Models +@model Kentico.Kontent.Statiq.Memoirs.Models.Post + +@if (!Model.Tags.Any() && !Model.Categories.Any() && !Model.Related.Any()) +{ + return; +} + + \ No newline at end of file diff --git a/input/Shared/related-posts.html b/input/Shared/related-posts.html deleted file mode 100644 index c35b749..0000000 --- a/input/Shared/related-posts.html +++ /dev/null @@ -1,54 +0,0 @@ - - \ No newline at end of file diff --git a/input/post.cshtml b/input/post.cshtml index 908f2d3..338d66d 100644 --- a/input/post.cshtml +++ b/input/post.cshtml @@ -30,10 +30,7 @@ else -@* {% include article.html %} *@ -
- @Html.Raw(Model.Body) -
+ @if (Model.Rating.HasValue) @@ -46,13 +43,13 @@ else - + -{% include related-posts.html %} +