diff --git a/exampleSite/hugo.toml b/exampleSite/hugo.toml index 85e39f0a..026d967d 100644 --- a/exampleSite/hugo.toml +++ b/exampleSite/hugo.toml @@ -58,6 +58,9 @@ defaultContentLanguage = 'en' secondary_font = "Inter" # Default is System font mono_font = "Fira Code" # Default is System font + [params.landingpage] + enabled = true # (optional) - Set to 'false' to disable the landing page (default is true) + [params.footer] copyright = "© :YEAR: Lotus Labs. Built with [**Lotus Docs**](https://github.com/colinwilson/lotusdocs)" # version = true # includes git commit info @@ -173,4 +176,4 @@ defaultContentLanguage = 'en' # name = "Community" # url = "https://github.com/colinwilson/lotusdocs/discussions" # identifier = "community" -# weight = 30 \ No newline at end of file +# weight = 30 diff --git a/layouts/index.html b/layouts/index.html index 76b71a33..bc1fd105 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -1,24 +1,22 @@ -{{ define "main" }} - {{ $landingData := .Site.Data.landing }} - {{ $map := newScratch }} - - {{ range $key, $value := $landingData }} - {{ $sectionTitle := (index $key) }} - {{ $weight := string ($value.weight) }} - {{ $template := string (replaceRE `( |-{1,})` "_" $value.template) }} - {{ with and $template $weight }} - {{ $map.SetInMap "wgtTpl" $sectionTitle (dict - "weight" $weight - "template" $template - "sectionTitle" $sectionTitle - )}} - {{ end }} - {{ end }} - - {{ range sort ($map.Get "wgtTpl") ".weight" }} - {{ $.Scratch.Set "sectionTitle" .sectionTitle }} - {{ $path := printf "landing/%s.html" .template }} - {{ partial $path $.Page }} - {{ end }} - {{/* printf "%s" (sort ($map.Get "wgtTpl") ".weight" ) */}} -{{ end }} \ No newline at end of file +{{- define "main" -}} + {{- $landingPageEnabled := .Site.Params.landingpage.enabled | default true -}} + {{- if not $landingPageEnabled -}} + + {{- else -}} + {{- $landingData := .Site.Data.landing -}} + {{- $sections := slice -}} + {{- range $sectionTitle, $value := $landingData -}} + {{- $weight := printf "%v" $value.weight -}} + {{- $template := replaceRE `( |-{1,})` "_" $value.template -}} + {{- $section := dict "sectionTitle" $sectionTitle "weight" $weight "template" $template -}} + {{- $sections = $sections | append $section -}} + {{- end -}} + {{- $sortedSections := sort $sections "weight" -}} + {{- range $sortedSections -}} + {{- $.Scratch.Set "sectionTitle" .sectionTitle -}} + {{- partial (printf "landing/%s.html" .template) $.Page -}} + {{- end -}} + {{- end -}} +{{- end -}}