pulumi-hugo-cn/themes/default/layouts/shortcodes/get-started-stepper.html
Kimberley Mackenzie e35e01f06f
Prettier Spike (#1517)
* Add Prettier set-up (no formatting in this commit).

* Manual fixes for Prettier issues.

* Run Prettier fix on non-markdown files.

* Incorporate Prettier PR feedback - update commands, re-apply new yaml styles, add editor config.

* Remove deprecated config item.

* Add dependency on prettier-plugin-go-template.

* reconcile changed file with prettier formatting.

* Add git blame ignore revs file to include Prettier formatting commit.

* Fix format issue with merge conflict.
2022-06-01 10:58:20 -07:00

44 lines
1.4 KiB
HTML

{{/* Emits PREVIOUS and NEXT buttons based on the pages in the current directory,
ordered by page weight.
*/}}
{{ $currentPage := .Page }}
{{/* Get the pages in the current directory. */}}
{{ $unsortedPages := slice $currentPage }}
{{ if eq $currentPage.File.Dir $currentPage.Parent.File.Dir }}
{{ $unsortedPages = $unsortedPages | append $currentPage.Parent }}
{{ end }}
{{ range $index, $page := .Page.CurrentSection.Pages }}
{{ if and (gt $page.Weight 0) (ne $page.RelPermalink $currentPage.RelPermalink) }}
{{ $unsortedPages = $unsortedPages | append $page }}
{{ end }}
{{ end }}
{{/* Sort by weight. */}}
{{ $pages := sort $unsortedPages "Weight" }}
{{/* Set the first and last indexes. */}}
{{ $first := 0 }}
{{ $last := sub (len $pages) 1 }}
{{/* Determine the index of the current step. */}}
{{ $step := -1 }}
{{ range $index, $element := $pages }}
{{ if eq $element.RelPermalink $currentPage.RelPermalink }}
{{ $step = $index }}
{{ end }}
{{ end }}
<div class="mt-6">
{{ if ne $step $first }}
{{ $prev := index $pages (sub $step 1) }}
<a data-track="previous-step" class="btn btn-secondary" href="{{ $prev.RelPermalink }}">&larr; Previous Step</a>
{{ end }}
{{ if ne $step $last }}
{{ $next := index $pages (add $step 1) }}
<a data-track="next-step" class="btn" href="{{ $next.RelPermalink }}">{{ $next.LinkTitle }} &rarr;</a>
{{ end }}
</div>