From 52694049045d821f5e314862f8e365a855fe4f92 Mon Sep 17 00:00:00 2001 From: Marnix van Valen Date: Wed, 25 Nov 2020 08:57:52 +0100 Subject: [PATCH] Fix - case sensitive file names for razor views * Failed to generate content for most pipelines on linux * Added exception to Lunr index module ( issue #2 ) --- .github/workflows/dotnet-core.yml | 2 +- Modules/LunrIndexer.cs | 5 +++++ Pipelines/Home.cs | 2 +- Pipelines/Pages.cs | 11 +---------- Pipelines/Posts.cs | 2 +- 5 files changed, 9 insertions(+), 13 deletions(-) diff --git a/.github/workflows/dotnet-core.yml b/.github/workflows/dotnet-core.yml index 8085ada..d06bb8b 100644 --- a/.github/workflows/dotnet-core.yml +++ b/.github/workflows/dotnet-core.yml @@ -9,7 +9,7 @@ on: jobs: build: - runs-on: windows-latest + runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 diff --git a/Modules/LunrIndexer.cs b/Modules/LunrIndexer.cs index 35f39d8..39ee393 100644 --- a/Modules/LunrIndexer.cs +++ b/Modules/LunrIndexer.cs @@ -15,6 +15,11 @@ public class LunrIndexer : Module protected override async Task> ExecuteContextAsync(IExecutionContext context) { + if (context.Inputs.Length == 0) + { + throw new InvalidOperationException($"No input documents available. Cannot build a search index for pipeline {context.PipelineName}"); + } + var documents = new Dictionary(); Index idx = await Index.Build(async builder => diff --git a/Pipelines/Home.cs b/Pipelines/Home.cs index ce16799..c4e546f 100644 --- a/Pipelines/Home.cs +++ b/Pipelines/Home.cs @@ -18,7 +18,7 @@ public Home(SiteSettings site) new ReplaceDocuments(Dependencies.ToArray()), new PaginateDocuments(6), new SetDestination(Config.FromDocument((doc, ctx) => Filename(doc))), - new MergeContent(new ReadFiles(patterns: "Index.cshtml")), + new MergeContent(new ReadFiles(patterns: "index.cshtml")), new RenderRazor() .WithViewData("Title", "Home") .WithViewData("SiteMetaData", site) diff --git a/Pipelines/Pages.cs b/Pipelines/Pages.cs index ad6c020..78b88e5 100644 --- a/Pipelines/Pages.cs +++ b/Pipelines/Pages.cs @@ -40,7 +40,7 @@ public Pages(IDeliveryClient deliveryClient, SiteSettings site) ProcessModules = new ModuleList { - new MergeContent(new ReadFiles( KontentConfig.Get( ViewForPage))), + new MergeContent(new ReadFiles( "page.cshtml")), new RenderRazor() .WithViewData( "SEO", Config.FromDocument((doc, ctx) => { @@ -62,15 +62,6 @@ public Pages(IDeliveryClient deliveryClient, SiteSettings site) new WriteFiles(), }; } - - public string ViewForPage(Page page) - { - return page.System.Codename switch - { - "contact" => "Contact.cshtml", - _ => "Page.cshtml" - }; - } } } diff --git a/Pipelines/Posts.cs b/Pipelines/Posts.cs index 690a120..f77a7e5 100644 --- a/Pipelines/Posts.cs +++ b/Pipelines/Posts.cs @@ -38,7 +38,7 @@ public Posts(IDeliveryClient deliveryClient, SiteSettings site) }; ProcessModules = new ModuleList { - new MergeContent(new ReadFiles(patterns: "Post.cshtml") ), + new MergeContent(new ReadFiles(patterns: "post.cshtml") ), new RenderRazor() .WithViewData( "SEO", Config.FromDocument((doc, ctx) => {