Add option to invert article pagination

pull/100/head
James Panther 2022-01-24 17:05:50 +11:00
parent 3703a09ce3
commit 1d4816f90a
No known key found for this signature in database
GPG Key ID: D36F789E45745D17
8 changed files with 22 additions and 10 deletions

View File

@ -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 - Tables of Contents on article pages
- Taxonomy and term listings now support Markdown content - Taxonomy and term listings now support Markdown content
- Taxonomies on article and list pages - Taxonomies on article and list pages
- Article pagination direction can be inverted
- Author `headline` parameter - Author `headline` parameter
- Skip to content and Scroll to top links - Skip to content and Scroll to top links

View File

@ -29,6 +29,7 @@ showScrollToTop = true
editAppendPath = true editAppendPath = true
showHeadingAnchors = true showHeadingAnchors = true
showPagination = true showPagination = true
invertPagination = false
showReadingTime = true showReadingTime = true
showTableOfContents = false showTableOfContents = false
showTaxonomies = false showTaxonomies = false

View File

@ -29,6 +29,7 @@ showScrollToTop = true
editAppendPath = true editAppendPath = true
showHeadingAnchors = true showHeadingAnchors = true
showPagination = true showPagination = true
invertPagination = false
showReadingTime = true showReadingTime = true
showTableOfContents = true showTableOfContents = true
showTaxonomies = false showTaxonomies = false

View File

@ -5,6 +5,7 @@ description: "Learn how to use Congo and its features."
cascade: cascade:
showDate: false showDate: false
showAuthor: false showAuthor: false
invertPagination: true
--- ---
{{< lead >}} {{< lead >}}

View File

@ -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.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.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.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.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.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.| |`article.showTaxonomies`|`false`|Whether or not the taxonomies related to this article are displayed.|

View File

@ -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.| |`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.| |`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.| |`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.| |`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.| |`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.| |`showTableOfContents`|`article.showTableOfContents`|Whether or not the table of contents is displayed on this article.|

View File

@ -1,11 +1,17 @@
{{ if .Params.showPagination | default (.Site.Params.article.showPagination | default true) }} {{ if .Params.showPagination | default (.Site.Params.article.showPagination | default true) }}
{{ if or .NextInSection .PrevInSection }} {{ if or .NextInSection .PrevInSection }}
{{ $next := .NextInSection }}
{{ $prev := .PrevInSection }}
{{ if .Params.invertPagination | default (.Site.Params.article.invertPagination | default false) }}
{{ $next = .PrevInSection }}
{{ $prev = .NextInSection }}
{{ end }}
<div class="pt-8 article-pagination"> <div class="pt-8 article-pagination">
<hr class="border-dotted border-neutral-300 dark:border-neutral-600" /> <hr class="border-dotted border-neutral-300 dark:border-neutral-600" />
<div class="flex justify-between pt-3"> <div class="flex justify-between pt-3">
<span> <span>
{{ if .NextInSection }} {{ if $prev }}
<a class="flex" href="{{ .NextInSection.RelPermalink }}"> <a class="flex" href="{{ $prev.RelPermalink }}">
<span <span
class="mr-3 ltr:inline rtl:hidden article-pagination-direction text-neutral-700 dark:text-neutral" class="mr-3 ltr:inline rtl:hidden article-pagination-direction text-neutral-700 dark:text-neutral"
>&larr;</span >&larr;</span
@ -16,11 +22,11 @@
> >
<span class="flex flex-col"> <span class="flex flex-col">
<span class="article-pagination-title mt-[0.1rem] leading-6" <span class="article-pagination-title mt-[0.1rem] leading-6"
>{{ .NextInSection.Title | emojify }}</span >{{ $prev.Title | emojify }}</span
> >
<span class="mt-[0.1rem] text-xs text-neutral-500 dark:text-neutral-400"> <span class="mt-[0.1rem] text-xs text-neutral-500 dark:text-neutral-400">
{{ if .Params.showDate | default (.Site.Params.article.showDate | default true) }} {{ if .Params.showDate | default (.Site.Params.article.showDate | default true) }}
{{ partial "meta/date.html" .NextInSection.Date }} {{ partial "meta/date.html" $prev.Date }}
{{ end }} {{ end }}
</span> </span>
</span> </span>
@ -28,15 +34,15 @@
{{ end }} {{ end }}
</span> </span>
<span> <span>
{{ if .PrevInSection }} {{ if $next }}
<a class="flex text-right" href="{{ .PrevInSection.RelPermalink }}"> <a class="flex text-right" href="{{ $next.RelPermalink }}">
<span class="flex flex-col"> <span class="flex flex-col">
<span class="article-pagination-title mt-[0.1rem] leading-6" <span class="article-pagination-title mt-[0.1rem] leading-6"
>{{ .PrevInSection.Title | emojify }}</span >{{ $next.Title | emojify }}</span
> >
<span class="mt-[0.1rem] text-xs text-neutral-500 dark:text-neutral-400"> <span class="mt-[0.1rem] text-xs text-neutral-500 dark:text-neutral-400">
{{ if .Params.showDate | default (.Site.Params.article.showDate | default true) }} {{ if .Params.showDate | default (.Site.Params.article.showDate | default true) }}
{{ partial "meta/date.html" .PrevInSection.Date }} {{ partial "meta/date.html" $next.Date }}
{{ end }} {{ end }}
</span> </span>
</span> </span>

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "hugo-congo-theme", "name": "hugo-congo-theme",
"version": "1.6.3", "version": "1.6.4",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "hugo-congo-theme", "name": "hugo-congo-theme",
"version": "1.6.3", "version": "1.6.4",
"hasInstallScript": true, "hasInstallScript": true,
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {