mirror of https://github.com/theNewDynamic/gohugo-theme-ananke.git

Developer Davo
01.08.2017 f9b62a2645cf1880f34a9f5f59ac483e557dd224
#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
2 files modified
13 ■■■■■ changed files
exampleSite/config.toml 1 ●●●● patch | view | raw | blame | history
layouts/index.html 12 ●●●●● patch | view | raw | blame | history
exampleSite/config.toml
@@ -28,3 +28,4 @@
  # 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
layouts/index.html
@@ -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 }}