Last active
September 12, 2017 00:30
-
-
Save budparr/9b679750a522b1f757c7fa27af00dc34 to your computer and use it in GitHub Desktop.
#gohugoio
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{/* Set header classes (e.g. colors scheme) at either the global, section, or page level */}} | |
{{/* Initially set $.Param "headerClasses" at the page or global (config) level, with a default if neither exist */}} | |
{{ $headerClasses := $.Param "headerClasses" | default "bg-near-black silver"}} | |
{{/* To set at the section level, get the section the current page belongs to */}} | |
{{ $section := .Site.GetPage "section" .Section }} | |
{{/* If the page belongs to a section, */}} | |
{{ if $section}} | |
{{/* get the section's headerClasses param value, defaulting to the global/page level. */}} | |
{{ $headerClasses := $section.Param "headerClasses" | default $headerClasses }} | |
{{/* Set the colors based on the page's setting, but if there isn't one, look to the section's settings above */}} | |
{{ $headerClasses := .Params.headerClasses | default $headerClasses }} | |
{{/* Add to Scratch so we can access it outside of the conditional */}} | |
{{ $.Scratch.Add "headerClasses" $headerClasses }} | |
{{ end }} | |
{{/* Define the variable based on what's in Scratch, and if nothing there, get the first default values */}} | |
{{ $headerClasses := $.Scratch.Get "headerClasses" | default $headerClasses }} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment