Skip to content

Commit

Permalink
✨ Feat: add post navigation config and remove params.Site.Params.navi…
Browse files Browse the repository at this point in the history
…gationReverse

Closes hugo-fixit#480
  • Loading branch information
Lruihao committed Aug 11, 2024
1 parent 1c84791 commit 6a83650
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
9 changes: 7 additions & 2 deletions hugo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,6 @@ enableEmoji = true
enablePWA = false
# FixIt 0.2.14 | NEW whether to add external Icon for external links automatically
externalIcon = false
# FixIt 0.3.0 | NEW whether to reverse the order of the navigation menu
navigationReverse = false
# FixIt 0.3.0 | NEW whether to add site title to the title of every page
# remember to set up your site title in `hugo.toml` (e.g. title = "title")
withSiteTitle = true
Expand Down Expand Up @@ -444,6 +442,13 @@ enableEmoji = true
sticky = false
showHome = false

# FixIt 0.3.10 | NEW Post navigation config
[params.navigation]
# whether to show the post navigation in section pages scope
inSection = false
# whether to reverse the next/previous post navigation order
reverse = false

# Footer config
[params.footer]
enable = true
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/init/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- .Scratch.Set "version" "v0.3.10-24873c5e" -}}
{{- .Scratch.Set "version" "v0.3.10-c936e541" -}}
{{- .Scratch.Set "this" dict -}}

{{- partial "init/detection-env.html" . -}}
Expand Down
9 changes: 8 additions & 1 deletion layouts/partials/single/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,18 @@
</section>
</div>

{{- $navigation := .Site.Params.navigation -}}
<div class="post-nav">
{{- $pages := .Scratch.Get "mainSectionPages" -}}
{{- $prev := $pages.Prev . -}}
{{- $next := $pages.Next . -}}
{{- if .Site.Params.navigationReverse -}}
{{- /* Show the post navigation in section pages */ -}}
{{- if $navigation.inSection -}}
{{- $prev = .PrevInSection -}}
{{- $next = .NextInSection -}}
{{- end -}}
{{- /* Reverse the next/previous post navigation order */ -}}
{{- if $navigation.reverse -}}
{{- $prev = $pages.Next . -}}
{{- $next = $pages.Prev . -}}
{{- end -}}
Expand Down

0 comments on commit 6a83650

Please sign in to comment.