From 1d4816f90afc2871aac39c518daa3e315207117d Mon Sep 17 00:00:00 2001 From: James Panther <4462786+jpanther@users.noreply.github.com> Date: Mon, 24 Jan 2022 17:05:50 +1100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20option=20to=20invert=20articl?= =?UTF-8?q?e=20pagination?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + config/_default/params.toml | 1 + exampleSite/config/_default/params.toml | 1 + exampleSite/content/docs/_index.md | 1 + exampleSite/content/docs/configuration.md | 1 + exampleSite/content/docs/front-matter.md | 1 + layouts/partials/article-pagination.html | 22 ++++++++++++++-------- package-lock.json | 4 ++-- 8 files changed, 22 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ad843f6..eb9304ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Tables of Contents on article pages - Taxonomy and term listings now support Markdown content - Taxonomies on article and list pages +- Article pagination direction can be inverted - Author `headline` parameter - Skip to content and Scroll to top links diff --git a/config/_default/params.toml b/config/_default/params.toml index 7826c1db..da9dd8e0 100644 --- a/config/_default/params.toml +++ b/config/_default/params.toml @@ -29,6 +29,7 @@ showScrollToTop = true editAppendPath = true showHeadingAnchors = true showPagination = true + invertPagination = false showReadingTime = true showTableOfContents = false showTaxonomies = false diff --git a/exampleSite/config/_default/params.toml b/exampleSite/config/_default/params.toml index 2c48352b..b6c9040a 100644 --- a/exampleSite/config/_default/params.toml +++ b/exampleSite/config/_default/params.toml @@ -29,6 +29,7 @@ showScrollToTop = true editAppendPath = true showHeadingAnchors = true showPagination = true + invertPagination = false showReadingTime = true showTableOfContents = true showTaxonomies = false diff --git a/exampleSite/content/docs/_index.md b/exampleSite/content/docs/_index.md index 263f6e86..a6a2c4b1 100755 --- a/exampleSite/content/docs/_index.md +++ b/exampleSite/content/docs/_index.md @@ -5,6 +5,7 @@ description: "Learn how to use Congo and its features." cascade: showDate: false showAuthor: false + invertPagination: true --- {{< lead >}} diff --git a/exampleSite/content/docs/configuration.md b/exampleSite/content/docs/configuration.md index 2eb2e047..865d7b25 100644 --- a/exampleSite/content/docs/configuration.md +++ b/exampleSite/content/docs/configuration.md @@ -117,6 +117,7 @@ Many of the article defaults here can be overridden on a per article basis by sp |`article.editAppendPath`|`true`|When `article.showEdit` is active, whether or not the path to the current article should be appended to the URL set at `article.editURL`.| |`article.showHeadingAnchors`|`true`|Whether or not heading anchor links are displayed alongside headings within articles.| |`article.showPagination`|`true`|Whether or not the next/previous article links are displayed in the article footer.| +|`article.invertPagination`|`false`|Whether or not to flip the direction of the next/previous article links.| |`article.showReadingTime`|`true`|Whether or not article reading times are displayed.| |`article.showTableOfContents`|`false`|Whether or not the table of contents is displayed on articles.| |`article.showTaxonomies`|`false`|Whether or not the taxonomies related to this article are displayed.| diff --git a/exampleSite/content/docs/front-matter.md b/exampleSite/content/docs/front-matter.md index f7efe9d5..45571833 100644 --- a/exampleSite/content/docs/front-matter.md +++ b/exampleSite/content/docs/front-matter.md @@ -29,6 +29,7 @@ Front matter parameter default values are inherited from the theme's [base confi |`showEdit`|`article.showEdit`|Whether or not the link to edit the article content should be displayed.| |`showHeadingAnchors`|`article.showHeadingAnchors`|Whether or not heading anchor links are displayed alongside headings within this article.| |`showPagination`|`article.showPagination`|Whether or not the next/previous article links are displayed in the article footer.| +|`invertPagination`|`article.invertPagination`|Whether or not to flip the direction of the next/previous article links.| |`showReadingTime`|`article.showReadingTime`|Whether or not the article reading time is displayed.| |`showTaxonomies`|`article.showTaxonomies`|Whether or not the taxonomies that relate to this article are displayed.| |`showTableOfContents`|`article.showTableOfContents`|Whether or not the table of contents is displayed on this article.| diff --git a/layouts/partials/article-pagination.html b/layouts/partials/article-pagination.html index 647a7136..85b4d22d 100644 --- a/layouts/partials/article-pagination.html +++ b/layouts/partials/article-pagination.html @@ -1,11 +1,17 @@ {{ if .Params.showPagination | default (.Site.Params.article.showPagination | default true) }} {{ if or .NextInSection .PrevInSection }} + {{ $next := .NextInSection }} + {{ $prev := .PrevInSection }} + {{ if .Params.invertPagination | default (.Site.Params.article.invertPagination | default false) }} + {{ $next = .PrevInSection }} + {{ $prev = .NextInSection }} + {{ end }}