Quellcode durchsuchen

#68|Parmeterize number of recent posts in index.html (#69)

* Parmeterize number of recent posts in index.html

* Replace .Site.Params.recent_posts_number with $.Param "recent_posts_number" in index.html
tags/1.31
Developer Davo vor 7 Jahren
Ursprung
Commit
f9b62a2645
2 geänderte Dateien mit 8 neuen und 5 gelöschten Zeilen
  1. 1
    0
      exampleSite/config.toml
  2. 7
    5
      layouts/index.html

+ 1
- 0
exampleSite/config.toml Datei anzeigen

@@ -28,3 +28,4 @@ enableRobotsTXT = true
# 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"
recent_posts_number = 2

+ 7
- 5
layouts/index.html Datei anzeigen

@@ -20,20 +20,22 @@
</h1>
{{ end }}

{{ $n_posts := $.Param "recent_posts_number" | default 3 }}

<section class="w-100 mw8">
{{/* Range through the first three items of the section */}}
{{ range (first 3 $section) }}
{{/* Range through the first $n_posts items of the section */}}
{{ range (first $n_posts $section) }}
<div class="relative w-100 mb4">
{{ partial "summary-with-image.html" . }}
</div>
{{ end }}
</section>

{{ if ge $section_count 4 }}
{{ if ge $section_count (add $n_posts 1) }}
<section class="w-100">
<h1 class="f3">More</h1>
{{/* 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)) }}
{{/* Now, range through the next four after the initial $n_posts items. Nest the requirements, "after" then "first" on the outside */}}
{{ range (first 4 (after $n_posts $section)) }}
<h2 class="f5 fw4 mb4 dib mr3">
<a href="{{ .URL }}" class="link black dim">
{{ .Title }}

Laden…
Abbrechen
Speichern