From 00a797e9bddf18714ee099d5fddca8f64b8c486b Mon Sep 17 00:00:00 2001 From: Bud Parr Date: Fri, 21 Apr 2017 18:41:10 -0400 Subject: [PATCH] fix clunky construction on home page to get section name (#17) --- layouts/index.html | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/layouts/index.html b/layouts/index.html index 4c80892..094006c 100755 --- a/layouts/index.html +++ b/layouts/index.html @@ -8,18 +8,16 @@ {{ $section := where .Site.RegularPages "Section" "in" $mainSections }} {{/* Check to see if the section is defined for ranging through it */}} {{ if $section }} - - {{/* Derive the section name by creating a string from the initial section definition */}} - {{ $section_name := printf "%s" (delimit ($mainSections) " ") }} + {{/* Derive the section name */}} + {{ $section_name := index (.Site.Params.mainSections) 0 }}
- {{/* Use $section_name to get the section title. Use "with" to only show it if it exists */}} - {{ with .Site.GetPage "section" $section_name }} -

- Recent {{ .Title }} -

- {{ end }} + {{ with .Site.GetPage "section" $section_name }} +

+ Recent {{ .Title }} +

+ {{ end }}
{{/* Range through the first three items of the section */}} @@ -31,9 +29,7 @@
-

More

- {{/* Now, range through the next four after the initial 3 items. Nest the requirements, "after" then "first" on the outside */}} {{ range (first 4 (after 3 $section)) }}

@@ -47,9 +43,7 @@ {{ with .Site.GetPage "section" $section_name }} All {{.Title }} {{ end }} -

-
{{ end }} {{ end }}