Skip to content

Commit

Permalink
fix: broken previous doc link and next doc link (#1080)
Browse files Browse the repository at this point in the history
  • Loading branch information
razonyang authored Nov 2, 2024
1 parent e4fd3a2 commit bc4d8bb
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
37 changes: 37 additions & 0 deletions layouts/partials/docs/doc-nav.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{{- $pages := slice }}
{{- with .CurrentSection }}
{{- $pages = .Pages }}
{{- end }}
{{- $sortedPages := sort (where $pages "Params.navWeight" ">" 0) "Params.navWeight" "desc" -}}
{{- $pages = union $sortedPages (sort $pages "Title") -}}
{{- $prev := false }}
{{- $next := false }}
{{- range $i, $page := $pages }}
{{- if eq $page.RelPermalink $.RelPermalink }}
{{- if gt $i 0 }}
{{- $prev = index $pages (sub $i 1) }}
{{- end }}
{{- with index $pages (add $i 1) }}
{{- $next = . }}
{{- end }}
{{- break }}
{{- end }}
{{- end }}
{{- if and (default true .Site.Params.post.nav) (default true .Params.nav) (or $prev $next) -}}
<div class="card-footer">
<div class="post-navs d-flex justify-content-evenly">
{{- with $prev -}}
<div class="post-nav post-prev">
<i class="fas fa-fw fa-chevron-down post-prev-icon me-1" data-fa-transform="rotate-90"></i>
<a href="{{ .RelPermalink }}">{{ partial "helpers/title" . }}</a>
</div>
{{- end -}}
{{- with $next -}}
<div class="post-nav post-next">
<a href="{{ .RelPermalink }}">{{ partial "helpers/title" . }}</a>
<i class="fas fa-fw fa-chevron-down post-next-icon ms-1" data-fa-transform="rotate-270"></i>
</div>
{{- end -}}
</div>
</div>
{{- end -}}
2 changes: 1 addition & 1 deletion layouts/partials/docs/post.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ <h1 class="card-title post-title my-2">{{ partial "helpers/title" . }}</h1>
{{- partial "post/reward" . -}}
{{- partial "hooks/content-end" . -}}
</div>
{{- partial "post/nav" . -}}
{{- partial "docs/doc-nav" . -}}
</article>
{{- partial "post/copyright/index" . -}}
{{- partial "post/related-posts" . -}}
Expand Down

0 comments on commit bc4d8bb

Please sign in to comment.