From a654fef19f342f7e78246e3a0996540d0249b1f3 Mon Sep 17 00:00:00 2001 From: Martijn Laarman Date: Tue, 17 Jun 2025 09:14:59 +0200 Subject: [PATCH] Forward nested layout sections to global layout --- src/Elastic.Markdown/Slices/_Layout.cshtml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Elastic.Markdown/Slices/_Layout.cshtml b/src/Elastic.Markdown/Slices/_Layout.cshtml index 4094c2275..6217cc456 100644 --- a/src/Elastic.Markdown/Slices/_Layout.cshtml +++ b/src/Elastic.Markdown/Slices/_Layout.cshtml @@ -2,7 +2,7 @@ @implements IUsesLayout @functions { public GlobalLayoutViewModel LayoutModel => Model; - protected override Task ExecuteSectionAsync(string name) + protected override async Task ExecuteSectionAsync(string name) { if (name == GlobalSections.Footer && Model.Layout is not LayoutName.Archive) { @@ -19,8 +19,15 @@ + //this ensures we forward footer sections declared in this project into to GlobalLayout view's section + await RenderSectionAsync(GlobalSections.Footer); + } + + if (name == GlobalSections.Head) + { + //this ensures we forward head sections declared in this project into to GlobalLayout view's section + await RenderSectionAsync(GlobalSections.Head); } - return Task.CompletedTask; } private async Task RenderDefault() {