Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
alanta committed Nov 24, 2020
1 parent 8169310 commit 19a7c81
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 31 deletions.
32 changes: 3 additions & 29 deletions Pipelines/Lunr.cs → Modules/LunrIndexer.cs
Original file line number Diff line number Diff line change
@@ -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);
Expand Down Expand Up @@ -86,6 +62,4 @@ protected override async Task<IEnumerable<IDocument>> ExecuteContextAsync(IExecu

}
}
}


}
32 changes: 32 additions & 0 deletions Pipelines/SearchIndex.cs
Original file line number Diff line number Diff line change
@@ -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()
);
}
}
}


4 changes: 2 additions & 2 deletions appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 19a7c81

Please sign in to comment.