diff --git a/README.md b/README.md index 31a9527..63366e8 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ Also includes examples of Hugo Features or Functions: - `len` - Conditionals - `ge` (greater than or equal to) +- `.Site.Params.mainSections` to avoid hard-coding "blog," etc. [[release note](https://github.com/spf13/hugo/blob/66ec6305f6cb450ddf9c489854146bac02f7dca1/docs/content/meta/release-notes.md#enhancements)] This theme uses the "Tachyons" CSS library. This will allow you to manipulate the design of the theme by changing class names in HTML without touching the original CSS files. For more information see the [Tachyons website](http://tachyons.io/). diff --git a/exampleSite/config.toml b/exampleSite/config.toml index ce9dd69..46cb441 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -24,3 +24,4 @@ enableRobotsTXT = true youtube = "" # choose a background color from any on this page: http://tachyons.io/docs/themes/skins/ and preface it with "bg-" background_color_class = "bg-black" + featured_image = "/images/gohugo-default-sample-hero-image.jpg" diff --git a/layouts/index.html b/layouts/index.html index 90bdd02..4c80892 100755 --- a/layouts/index.html +++ b/layouts/index.html @@ -2,18 +2,27 @@
{{ .Content }}
- {{/* For Hugo 0.20 this will default to the section with the most number of pages. */}} + {{/* Define a section to pull recent posts from. For Hugo 0.20 this will default to the section with the most number of pages. */}} {{ $mainSections := .Site.Params.mainSections | default (slice "post") }} - {{/* Create a variable to use the same section twice. */}} + {{/* Create a variable with that section to use in multiple places. */}} {{ $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) " ") }} +
-

- Recent Articles -

+ {{/* 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 }}
+ {{/* Range through the first three items of the section */}} {{ range (first 3 $section) }}
{{ partial "summary-with-image.html" . }} @@ -22,8 +31,10 @@
-

More Posts

- {{/* Nest the requirements, "after" then "first" on the outside */}} + +

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)) }}

@@ -31,9 +42,14 @@

{{ end }} - All Posts -
-
+ {{/* As above, Use $section_name to get the section title, and URL. Use "with" to only show it if it exists */}} + {{ with .Site.GetPage "section" $section_name }} + All {{.Title }} + {{ end }} + + + + {{ end }} {{ end }} diff --git a/layouts/partials/page-header.html b/layouts/partials/page-header.html index bba7d70..9e408ce 100644 --- a/layouts/partials/page-header.html +++ b/layouts/partials/page-header.html @@ -1,5 +1,6 @@ -{{ if .Params.featured_image }} -
+{{ $featured_image := $.Param "featured_image" }} +{{ if $featured_image }} +
{{ partial "site-navigation.html" . }}
diff --git a/layouts/partials/site-header.html b/layouts/partials/site-header.html index ff68ec7..dce121e 100755 --- a/layouts/partials/site-header.html +++ b/layouts/partials/site-header.html @@ -1,5 +1,6 @@ -{{ if .Params.featured_image }} -
+{{ $featured_image := $.Param "featured_image" }} +{{ if $featured_image }} +