refactor: use Hugo's cascade system for edit, related, breadcrumb

BREAKING CHANGES:

The editable and show_related options must now be controlled from front matter, either directly or cascaded from Hugo config

Move breadcrumb option from params.yaml to front matter `show_breadcrumb: true`
This commit is contained in:
George Cushen committed 2022-01-19 23:10:53 +00:00
1 parent cf47911ab9
commit ab96e174c2
3 files changed
+5 -10

No files matched your search

+1 -2
View File
@@ -1,8 +1,7 @@
{{ $current_page := . }}
{{/* Check whether to show breadcrumb navigation. */}}
{{ $breadcrumb_page_types := site.Params.breadcrumb.page_types | default dict }}
{{ $show_breadcrumb := index $breadcrumb_page_types .Type | default false }}
{{ $show_breadcrumb := .Params.show_breadcrumb }}
<div class="container-fluid docs">
<div class="row flex-xl-nowrap">
+2 -4
View File
@@ -1,6 +1,5 @@
{{/* This makes `edit_page` optional in `params.toml` and prevents errors if it's removed. */}}
{{ if site.Params.edit_page }}
{{ if site.Params.edit_page.repo_url | and (index site.Params.edit_page.editable .Type) | and (ne .Params.editable false) | or .Params.editable }}
{{/* Add link to let visitors edit the page on GitHub. */}}
{{ if .Params.editable | and site.Params.edit_page.repo_url }}
{{/* Get language subfolder for multilingual sites. */}}
{{/* Limitations: the subfolder param, `<LANG>.contentDir`, is unexposed in the Hugo `site` API so we attempt to workaround this issue. */}}
{{ $content_dir := "content" }}
@@ -16,4 +15,3 @@
</a>
</p>
{{ end }}
{{ end }}
+2 -4
View File
@@ -1,6 +1,5 @@
{{/* This makes `show_related` optional in `params.toml` and prevents errors if it's removed. */}}
{{ if site.Params.show_related }}
{{ if (index site.Params.show_related .Type) | and (ne .Params.show_related false) | or .Params.show_related }}
{{/* Show related/recommended content. */}}
{{ if .Params.show_related }}
{{ $related := site.RegularPages.Related . | first 5 }}
{{ with $related }}
<div class="article-widget content-widget-hr">
@@ -13,4 +12,3 @@
</div>
{{ end }}
{{ end }}
{{ end }}