From 19a7c8141e07c2ce1b55d58b7cb19a47975b6c1c Mon Sep 17 00:00:00 2001 From: Marnix van Valen Date: Tue, 24 Nov 2020 22:35:59 +0100 Subject: [PATCH] Cleanup --- Pipelines/Lunr.cs => Modules/LunrIndexer.cs | 32 ++------------------- Pipelines/SearchIndex.cs | 32 +++++++++++++++++++++ appsettings.json | 4 +-- 3 files changed, 37 insertions(+), 31 deletions(-) rename Pipelines/Lunr.cs => Modules/LunrIndexer.cs (69%) create mode 100644 Pipelines/SearchIndex.cs diff --git a/Pipelines/Lunr.cs b/Modules/LunrIndexer.cs similarity index 69% rename from Pipelines/Lunr.cs rename to Modules/LunrIndexer.cs index cb2ec36..35f39d8 100644 --- a/Pipelines/Lunr.cs +++ b/Modules/LunrIndexer.cs @@ -1,38 +1,14 @@ -using Kentico.Kontent.Statiq.Lumen.Pipelines; +using MemoirsTheme.Pipelines; using Statiq.Common; -using Statiq.Core; using Statiq.SearchIndex; using System; using System.Collections.Generic; -using System.Linq; using System.Text.RegularExpressions; using System.Threading.Tasks; -using Pipeline = Statiq.Core.Pipeline; using Index = Lunr.Index; -namespace MemoirsTheme.Pipelines +namespace MemoirsTheme.Modules { - public class SearchIndex : Pipeline - { - public const string SearchItemKey = GenerateLunrIndexKeys.LunrIndexItem; - public SearchIndex() - { - Dependencies.AddRange(nameof(Posts)); - PostProcessModules = new ModuleList( - // pull documents from other pipelines - new ReplaceDocuments(Dependencies.ToArray()), - new LunrIndexer(), - new AppendContent(Config.FromContext(ctx => ctx.FileSystem.GetInputFile("assets/js/lunrsearchengine.js").ReadAllTextAsync())), - new SetDestination("assets/js/lunrsearchengine.js") - - ); - OutputModules = new ModuleList( - - new WriteFiles() - ); - } - } - public class LunrIndexer : Module { private static readonly Regex StripHtmlAndSpecialChars = new Regex(@"<[^>]+>|&[a-zA-Z]{2,};|&#\d+;|[^a-zA-Z-#]", RegexOptions.Compiled); @@ -86,6 +62,4 @@ protected override async Task> ExecuteContextAsync(IExecu } } -} - - +} \ No newline at end of file diff --git a/Pipelines/SearchIndex.cs b/Pipelines/SearchIndex.cs new file mode 100644 index 0000000..e055ae9 --- /dev/null +++ b/Pipelines/SearchIndex.cs @@ -0,0 +1,32 @@ +using MemoirsTheme.Modules; +using Statiq.Common; +using Statiq.Core; +using Statiq.SearchIndex; +using System.Linq; +using Pipeline = Statiq.Core.Pipeline; + +namespace MemoirsTheme.Pipelines +{ + public class SearchIndex : Pipeline + { + public const string SearchItemKey = GenerateLunrIndexKeys.LunrIndexItem; + public SearchIndex() + { + Dependencies.AddRange(nameof(Posts)); + PostProcessModules = new ModuleList( + // pull documents from other pipelines + new ReplaceDocuments(Dependencies.ToArray()), + new LunrIndexer(), + new AppendContent(Config.FromContext(ctx => ctx.FileSystem.GetInputFile("assets/js/lunrsearchengine.js").ReadAllTextAsync())), + new SetDestination("assets/js/lunrsearchengine.js") + + ); + OutputModules = new ModuleList( + + new WriteFiles() + ); + } + } +} + + diff --git a/appsettings.json b/appsettings.json index e0443f0..acb1021 100644 --- a/appsettings.json +++ b/appsettings.json @@ -6,8 +6,8 @@ "LinksUseHttps": true, "LinkLowercase": true, "Site": { - "name": "Memoirs", - "title": "Memoirs", + "Name": "Memoirs", + "Title": "Memoirs", "Description": "I will take you on the fabulous world of exploration. Travel, culture, lifestyle. Eat, Pray, Love!", "Logo": "assets/images/logo.png", "Favicon": "assets/images/logo.png",