Skip to content

Commit

Permalink
#68|Parmeterize number of recent posts in index.html (#69)
Browse files Browse the repository at this point in the history
* Parmeterize number of recent posts in index.html

* Replace .Site.Params.recent_posts_number with $.Param "recent_posts_number" in index.html
  • Loading branch information
Developer Davo authored and Bud Parr committed Nov 1, 2017
1 parent 2a1495a commit f9b62a2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 7 additions & 5 deletions layouts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,22 @@ <h1 class="flex-none">
</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 }}
Expand Down

0 comments on commit f9b62a2

Please sign in to comment.