From a5f5106154ac1f5cd0d84a5a2212b0ec500edc21 Mon Sep 17 00:00:00 2001 From: Dave Johnston Date: Fri, 18 Apr 2014 07:23:13 +0000 Subject: [PATCH] Add in-section Next/Prev content pointers Conflicts: docs/content/meta/release-notes.md docs/content/templates/variables.md --- docs/content/meta/release-notes.md | 4 ++++ docs/content/templates/variables.md | 2 ++ hugolib/page.go | 2 ++ hugolib/site.go | 9 +++++++++ 4 files changed, 17 insertions(+) diff --git a/docs/content/meta/release-notes.md b/docs/content/meta/release-notes.md index e26d7d7dc..a55b00ae8 100644 --- a/docs/content/meta/release-notes.md +++ b/docs/content/meta/release-notes.md @@ -10,6 +10,7 @@ title: Release Notes weight: 10 --- + ## **0.12.0** Sept 1, 2014 A lot has happened since Hugo v0.11.0 was released. Most of the work has been @@ -56,6 +57,9 @@ This release represents over 110 code commits from 29 different contributors. * Renamed Indexes > [Taxonomies](/taxonomies/overview) * Renamed Chrome > [Partials](/templates/partials) +## Next release + * Added section Prev/Next pointers. + ## **0.10.0** March 1, 2014 This release represents over 110 code commits from 29 different contributors. diff --git a/docs/content/templates/variables.md b/docs/content/templates/variables.md index 054adfba3..93f5ad02b 100644 --- a/docs/content/templates/variables.md +++ b/docs/content/templates/variables.md @@ -39,6 +39,8 @@ matter, content or derived from file location. **.TableOfContents** The rendered table of contents for this content.
**.Prev** Pointer to the previous content (based on pub date).
**.Next** Pointer to the following content (based on pub date).
+**.PrevInSection** Pointer to the previous content within the same section (based on pub date)
+**.NextInSection** Pointer to the following content within the same section (based on pub date)
**.FuzzyWordCount** The approximate number of words in the content.
**.WordCount** The number of words in the content.
**.ReadingTime** The estimated time it takes to read the content in minutes.
diff --git a/hugolib/page.go b/hugolib/page.go index 2ebc17b6b..1383f387e 100644 --- a/hugolib/page.go +++ b/hugolib/page.go @@ -80,6 +80,8 @@ type PageMeta struct { type Position struct { Prev *Page Next *Page + PrevInSection *Page + NextInSection *Page } type Pages []*Page diff --git a/hugolib/site.go b/hugolib/site.go index 41c0d26c7..b4af9e76c 100644 --- a/hugolib/site.go +++ b/hugolib/site.go @@ -724,6 +724,15 @@ func (s *Site) assembleSections() { for k := range s.Sections { s.Sections[k].Sort() + + for i, wp := range s.Sections[k] { + if i > 0 { + wp.Page.NextInSection = s.Sections[k][i - 1].Page; + } + if i < len(s.Sections[k]) - 1 { + wp.Page.PrevInSection = s.Sections[k][i + 1].Page; + } + } } }