Skip to content

Commit

Permalink
Merge pull request #3 from alanta/feature/update-to-net6
Browse files Browse the repository at this point in the history
Update to .NET 6 and Kontent.Statiq v2
  • Loading branch information
alanta authored Apr 29, 2022
2 parents e61488e + eb1f40d commit 07ff23c
Show file tree
Hide file tree
Showing 13 changed files with 96 additions and 115 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dotnet-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.401
dotnet-version: '6.0.x'
- name: Install dependencies
run: dotnet restore
- name: Build
Expand Down
5 changes: 2 additions & 3 deletions Helpers/HtmlHelpers.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using AngleSharp.Dom;
using Kentico.Kontent.Delivery.Abstractions;
using Kentico.Kontent.ImageTransformation;
using Kentico.Kontent.Urls.ImageTransformation;
using Kentico.Kontent.Statiq.Memoirs.Models;
using Microsoft.AspNetCore.Html;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Statiq.Common;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -59,7 +58,7 @@ public static IHtmlContent Image(this IHtmlHelper html, IAsset asset, string? de
imageUrl = imageUrl.WithFitMode(fit.Value);
}

tag.MergeAttributes(HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes), true);
tag.MergeAttributes(Microsoft.AspNetCore.Mvc.ViewFeatures.HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes), true);

if (lazy)
{
Expand Down
13 changes: 7 additions & 6 deletions MemoirsTheme.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Kontent.Statiq" Version="1.0.0-*" />
<PackageReference Include="LunrCore" Version="2.3.9" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="3.1.21" />
<PackageReference Include="NUglify" Version="1.16.1" />
<PackageReference Include="Kontent.Statiq" Version="2.0.0-beta0014" />
<PackageReference Include="LunrCore" Version="2.3.10" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="6.0.0" />
<PackageReference Include="NUglify" Version="1.20.0" />
<PackageReference Include="Statiq.App" Version="1.0.0-*" />
<PackageReference Include="Statiq.Sass" Version="1.0.0-*" />
<PackageReference Include="Statiq.Web" Version="1.0.0-*" />
Expand Down
4 changes: 2 additions & 2 deletions MemoirsTheme.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30413.136
# Visual Studio Version 17
VisualStudioVersion = 17.1.32407.343
MinimumVisualStudioVersion = 15.0.26124.0
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MemoirsTheme", "MemoirsTheme.csproj", "{FD3E8728-0F91-418E-8CA4-5F37B44FF70B}"
EndProject
Expand Down
6 changes: 1 addition & 5 deletions Models/ContentTypes/Post.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
using System;
using System.Collections.Generic;
using Kentico.Kontent.Delivery.Abstractions;

namespace Kentico.Kontent.Statiq.Memoirs.Models
{
public partial class Post: IPageMetadata
{
public string Url => $"post/{PostDate.Value.Year}/{PostDate.Value.Month:00}/{UrlSlug}.html";
public string Url => $"post/{PostDate?.Year ?? 0}/{(PostDate?.Month??0):00}/{UrlSlug}.html";

}
}
8 changes: 5 additions & 3 deletions Pipelines/Pages.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Kentico.Kontent.Delivery.Abstractions;
using Kentico.Kontent.Delivery.Urls.QueryParameters;
using Kentico.Kontent.Urls.Delivery.QueryParameters;
using Kentico.Kontent.Statiq.Memoirs.Models;
using Kontent.Statiq;
using MemoirsTheme.Models;
Expand All @@ -19,8 +19,10 @@ public Pages(IDeliveryClient deliveryClient, SiteSettings site)
InputModules = new ModuleList
{
new Kontent<Page>(deliveryClient)
.OrderBy(Post.TitleCodename, SortOrder.Descending)
.WithQuery(new DepthParameter(2), new IncludeTotalCountParameter()),
.WithQuery(
new DepthParameter(2),
new IncludeTotalCountParameter(),
new OrderParameter("elements."+Post.TitleCodename, SortOrder.Descending)),
new SetMetadata(nameof(Page.Tags),
KontentConfig.Get<Page,ITaxonomyTerm[]>(post => post.Tags?.ToArray())),
new SetMetadata(nameof(Page.Categories),
Expand Down
10 changes: 6 additions & 4 deletions Pipelines/Posts.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Kentico.Kontent.Delivery.Abstractions;
using Kentico.Kontent.Delivery.Urls.QueryParameters;
using Kentico.Kontent.Urls.Delivery.QueryParameters;
using Kentico.Kontent.Statiq.Memoirs.Models;
using Kontent.Statiq;
using MemoirsTheme.Models;
Expand All @@ -18,8 +18,10 @@ public Posts(IDeliveryClient deliveryClient, SiteSettings site)
Dependencies.Add(nameof(Seo));
InputModules = new ModuleList{
new Kontent<Post>(deliveryClient)
.OrderBy(Post.PostDateCodename, SortOrder.Descending)
.WithQuery(new DepthParameter(2), new IncludeTotalCountParameter()),
.WithQuery(
new DepthParameter(2),
new IncludeTotalCountParameter(),
new OrderParameter("elements."+Post.PostDateCodename, SortOrder.Descending)),
new SetMetadata(nameof(Post.Tags),
KontentConfig.Get<Post,ITaxonomyTerm[]>(post => post.Tags?.ToArray())),
new SetMetadata(nameof(Post.Categories),
Expand Down Expand Up @@ -66,4 +68,4 @@ public Posts(IDeliveryClient deliveryClient, SiteSettings site)
};
}
}
}
}
2 changes: 1 addition & 1 deletion Pipelines/Seo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Kentico.Kontent.Delivery.Abstractions;
using Kentico.Kontent.Delivery.Urls.QueryParameters;
using Kentico.Kontent.Urls.Delivery.QueryParameters;
using Kontent.Statiq;
using Statiq.Common;
using Statiq.Core;
Expand Down
21 changes: 1 addition & 20 deletions Pipelines/Taxonomy.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Kentico.Kontent.Delivery.Abstractions;
using Kentico.Kontent.Statiq.Lumen.Pipelines;
using Kentico.Kontent.Statiq.Memoirs.Models;
using Kentico.Kontent.Statiq.Memoirs.Models;
using Kontent.Statiq;
using MemoirsTheme.Modules;
using Statiq.Common;
Expand Down Expand Up @@ -71,22 +69,5 @@ public Taxonomy(SiteSettings site)
new WriteFiles()
};
}

public class TaxonomyTermComparer : IEqualityComparer<ITaxonomyTerm>
{
public bool Equals(ITaxonomyTerm x, ITaxonomyTerm y)
{
if (ReferenceEquals(x, y)) return true;
if (ReferenceEquals(x, null)) return false;
if (ReferenceEquals(y, null)) return false;
if (x.GetType() != y.GetType()) return false;
return x.Codename == y.Codename;
}

public int GetHashCode(ITaxonomyTerm obj)
{
return (obj.Codename != null ? obj.Codename.GetHashCode() : 0);
}
}
}
}
32 changes: 16 additions & 16 deletions input/Shared/_article.cshtml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
@using Kentico.Kontent.Statiq.Memoirs.Models
@model Kentico.Kontent.Statiq.Memoirs.Models.IPageMetadata
<!-- Post, Page Content
================================================== -->
<div class="article-post">
<!-- Toc if any -->
@using Kentico.Kontent.Statiq.Memoirs.Models
@model Kentico.Kontent.Statiq.Memoirs.Models.IPageMetadata
<!-- Post, Page Content
================================================== -->
<div class="article-post">
<!-- Toc if any -->
@if( Model.TableOfContents()){
/*if (Model.beforetoc)
{
<p><em>Model.beforetoc</em></p>
}*/
<div class="toc mt-4 mb-4 lead">
<h3 class="font-weight-bold">Summary</h3>
@Html.TableOfContents(Model.Body)
</div>
}
<!-- End Toc -->
<article>
@Html.Raw(Model.Body)
</article>
}*/
<div class="toc mt-4 mb-4 lead">
<h3 class="font-weight-bold">Summary</h3>
@Html.TableOfContents(Model.Body)
</div>
}
<!-- End Toc -->
<article>
@Html.Raw(Model.Body)
</article>
</div>
36 changes: 18 additions & 18 deletions input/Shared/_featured-image.cshtml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
@using Kentico.Kontent.Delivery.Abstractions
@model IEnumerable<Kentico.Kontent.Delivery.Abstractions.IAsset>
@{
bool lazyImages = Html.Site().LazyImages;
@using Kentico.Kontent.Delivery.Abstractions
@model IEnumerable<Kentico.Kontent.Delivery.Abstractions.IAsset>
@{
bool lazyImages = Html.Site().LazyImages;
bool imageShadow = Html.Site().ImageShadow;
IAsset image = Model?.FirstOrDefault();
}
@if (image != null)
{
<div class="entry-featured-image">
@if (lazyImages)
{
<img class="featured-image lazyimg @(imageShadow?"image-shadow":"")" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAACCAQAAAA3fa6RAAAADklEQVR42mNkAANGCAUAACMAA2w/AMgAAAAASUVORK5CYII=" data-src="@image.Url?w=940&h=670&fit=crop" alt="@image.Description">
}
else
{
<img class="featured-image @(imageShadow?"image-shadow":"")" src="@image.Url?w=940&h=670&fit=crop" alt="@image.Description">
}
</div>
IAsset image = Model?.FirstOrDefault();
}
@if (image != null)
{
<div class="entry-featured-image">
@if (lazyImages)
{
<img class="featured-image lazyimg @(imageShadow?"image-shadow":"")" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAACCAQAAAA3fa6RAAAADklEQVR42mNkAANGCAUAACMAA2w/AMgAAAAASUVORK5CYII=" data-src="@image.Url?w=940&h=670&fit=crop" alt="@image.Description">
}
else
{
<img class="featured-image @(imageShadow?"image-shadow":"")" src="@image.Url?w=940&h=670&fit=crop" alt="@image.Description">
}
</div>
}
70 changes: 35 additions & 35 deletions input/Shared/author-box.cshtml
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
@using Kentico.Kontent.ImageTransformation
@using Kentico.Kontent.Statiq.Memoirs.Models
@using MemoirsTheme.Helpers
@model Kentico.Kontent.Statiq.Memoirs.Models.Author
@{
var site = ViewData["SiteMetaData"] as SiteSettings;
}
<!-- Author Box -->
@using Kentico.Kontent.Urls.ImageTransformation
@using Kentico.Kontent.Statiq.Memoirs.Models
@using MemoirsTheme.Helpers
@model Kentico.Kontent.Statiq.Memoirs.Models.Author
@{
var site = ViewData["SiteMetaData"] as SiteSettings;
}
<!-- Author Box -->
@if( Model != null && site.AuthorBox){
<div class="d-flex authorbox align-items-center">
<div class="col-md-2 mr-4 text-center">
@if (Model?.AvatarImage != null)
{
@Html.Image(Model.AvatarImage, Model.Name, site.LazyImages, 580, 400, ImageFitMode.Crop, new { @class = "img-thumb" })
}
else
{
<img class="author-thumb" src="https://www.gravatar.com/avatar/@Model.Gravatar?s=250&d=mm&r=x" alt="@Model.Name">
}
</div>
<div class="col-md-10">
@foreach (var contact in Model.Contacts.OfType<Contact>())
{
@if (contact.Icon == "web")
{
<a target="_blank" class="text-dark h4" href="@contact.Url">About @Model.Name</a>
}
else
{
<a target="_blank" href="@contact.Url" class="btn-sm"><i class="fab [email protected]"></i></a>
}
}

<span class="author-description d-block mt-2">@Model.Bio</span>
</div>
</div>
<div class="d-flex authorbox align-items-center">
<div class="col-md-2 mr-4 text-center">
@if (Model?.AvatarImage != null)
{
@Html.Image(Model.AvatarImage, Model.Name, site.LazyImages, 580, 400, ImageFitMode.Crop, new { @class = "img-thumb" })
}
else
{
<img class="author-thumb" src="https://www.gravatar.com/avatar/@Model.Gravatar?s=250&d=mm&r=x" alt="@Model.Name">
}
</div>
<div class="col-md-10">
@foreach (var contact in Model.Contacts.OfType<Contact>())
{
@if (contact.Icon == "web")
{
<a target="_blank" class="text-dark h4" href="@contact.Url">About @Model.Name</a>
}
else
{
<a target="_blank" href="@contact.Url" class="btn-sm"><i class="fab [email protected]"></i></a>
}
}

<span class="author-description d-block mt-2">@Model.Bio</span>
</div>
</div>
}
2 changes: 1 addition & 1 deletion input/Shared/postbox.cshtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@using Kentico.Kontent.ImageTransformation
@using Kentico.Kontent.Urls.ImageTransformation
@using Kentico.Kontent.Statiq.Memoirs.Models
@model Kentico.Kontent.Statiq.Memoirs.Models.Post
@{ var site = ViewData["SiteMetadata"] as SiteSettings;
Expand Down

0 comments on commit 07ff23c

Please sign in to comment.