mirror of
https://github.com/gethinode/hinode.git
synced 2025-10-18 15:33:10 +00:00
Refactor breadcrumb
This commit is contained in:
16
data/structures/breadcrumb.yml
Normal file
16
data/structures/breadcrumb.yml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
comment: Displays a breadcrumb for a specific page.
|
||||||
|
arguments:
|
||||||
|
page:
|
||||||
|
type:
|
||||||
|
- '*hugolib.pageState'
|
||||||
|
- '*hugolib.pageForShortcode'
|
||||||
|
optional: false
|
||||||
|
comment: Page to display the breadcrumb for.
|
||||||
|
group: partial
|
||||||
|
path:
|
||||||
|
type: string
|
||||||
|
optional: true
|
||||||
|
comment: Path of the page to display the breadcrumb for.
|
||||||
|
group: shortcode
|
||||||
|
|
||||||
|
|
@@ -11,7 +11,7 @@
|
|||||||
<div class="container-xxl p-4 px-xxl-0">
|
<div class="container-xxl p-4 px-xxl-0">
|
||||||
{{- if ne $layout "featured" -}}
|
{{- if ne $layout "featured" -}}
|
||||||
{{ if and (not $page.IsHome) site.Params.navigation.breadcrumb }}
|
{{ if and (not $page.IsHome) site.Params.navigation.breadcrumb }}
|
||||||
<div>{{ partial "assets/breadcrumb.html" $page }}</div>
|
<div>{{ partial "assets/breadcrumb.html" (dict "page" $page) }}</div>
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{{- define "partials/single-main.html" -}}
|
{{- define "partials/single-main.html" -}}
|
||||||
{{- $breakpoint := $.Scratch.Get "breakpoint" -}}
|
{{- $breakpoint := $.Scratch.Get "breakpoint" -}}
|
||||||
{{ if .Site.Params.navigation.breadcrumb }}{{ partial "assets/breadcrumb.html" . }}{{ end -}}
|
{{ if .Site.Params.navigation.breadcrumb }}{{ partial "assets/breadcrumb.html" (dict "page" .) }}{{ end -}}
|
||||||
|
|
||||||
{{ .Render "single/header" }}
|
{{ .Render "single/header" }}
|
||||||
|
|
||||||
|
@@ -1,6 +1,24 @@
|
|||||||
|
<!--
|
||||||
|
Copyright © 2023 The Hinode Team / Mark Dumay. All rights reserved.
|
||||||
|
Use of this source code is governed by The MIT License (MIT) that can be found in the LICENSE file.
|
||||||
|
Visit gethinode.com/license for more details.
|
||||||
|
-->
|
||||||
|
|
||||||
|
{{ $error := false }}
|
||||||
|
|
||||||
|
<!-- Validate arguments -->
|
||||||
|
{{ if partial "utilities/IsInvalidArgs.html" (dict "structure" "breadcrumb" "args" . "group" "partial") }}
|
||||||
|
{{ errorf "Invalid arguments: %s" .Position -}}
|
||||||
|
{{ $error = true }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
<!-- Initialize arguments -->
|
||||||
|
{{ $page := .page }}
|
||||||
|
|
||||||
|
<!-- Main code -->
|
||||||
<nav aria-label="breadcrumb">
|
<nav aria-label="breadcrumb">
|
||||||
<ol class="breadcrumb">
|
<ol class="breadcrumb">
|
||||||
{{- range $index, $item := .Page.Ancestors.Reverse -}}
|
{{- range $index, $item := $page.Ancestors.Reverse -}}
|
||||||
{{- $title := .LinkTitle -}}
|
{{- $title := .LinkTitle -}}
|
||||||
{{- if .IsHome }}{{ $title = T "home" }}{{ end -}}
|
{{- if .IsHome }}{{ $title = T "home" }}{{ end -}}
|
||||||
{{- $address := or .RelPermalink (.Params.Redirect | relLangURL) -}}
|
{{- $address := or .RelPermalink (.Params.Redirect | relLangURL) -}}
|
||||||
@@ -10,6 +28,6 @@
|
|||||||
<li class="breadcrumb-item">{{ $title }}</li>
|
<li class="breadcrumb-item">{{ $title }}</li>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
<li class="breadcrumb-item active" aria-current="page">{{ .Page.LinkTitle }}</li>
|
<li class="breadcrumb-item active" aria-current="page">{{ $page.LinkTitle }}</li>
|
||||||
</ol>
|
</ol>
|
||||||
</nav>
|
</nav>
|
||||||
|
@@ -64,7 +64,7 @@
|
|||||||
<div class="container-fluid p-0 {{ with site.Params.home.feature.color }} bg-{{ . }} bg-opacity-{{ site.Params.style.themeOpacity | default "25" | safeHTML }}{{ end }}">
|
<div class="container-fluid p-0 {{ with site.Params.home.feature.color }} bg-{{ . }} bg-opacity-{{ site.Params.style.themeOpacity | default "25" | safeHTML }}{{ end }}">
|
||||||
<div class="container-xxl p-4 px-xxl-0 {{ if site.Params.home.fullCover }} fullcover{{ end }} d-flex flex-column">
|
<div class="container-xxl p-4 px-xxl-0 {{ if site.Params.home.fullCover }} fullcover{{ end }} d-flex flex-column">
|
||||||
{{ if $breadcrumb }}
|
{{ if $breadcrumb }}
|
||||||
<div>{{ partial "assets/breadcrumb.html" $page }}</div>
|
<div>{{ partial "assets/breadcrumb.html" (dict "page" $page) }}</div>
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
|
|
||||||
{{ if eq $orientation "stacked" }}
|
{{ if eq $orientation "stacked" }}
|
||||||
|
@@ -35,6 +35,8 @@
|
|||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
|
{{ $group := .group }}
|
||||||
|
|
||||||
{{ $namedArgs := true }}
|
{{ $namedArgs := true }}
|
||||||
|
|
||||||
{{ if not $error }}
|
{{ if not $error }}
|
||||||
@@ -111,7 +113,13 @@
|
|||||||
{{ $max := len $args }}
|
{{ $max := len $args }}
|
||||||
{{ $expected := 0 }}
|
{{ $expected := 0 }}
|
||||||
{{ range $key, $val := $definitions }}
|
{{ range $key, $val := $definitions }}
|
||||||
{{ if not $val.optional }}
|
{{ $skip := false }}
|
||||||
|
{{ $groups := slice | append $val.group }}
|
||||||
|
{{ if and $group $val.group }}
|
||||||
|
{{ $skip = not (in $groups $group )}}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{ if and (not $skip) (not $val.optional) }}
|
||||||
{{ if $namedArgs }}
|
{{ if $namedArgs }}
|
||||||
{{ if not (isset $args $key) }}
|
{{ if not (isset $args $key) }}
|
||||||
{{ warnf "[%s] argument '%s': expected value" $structure $key }}
|
{{ warnf "[%s] argument '%s': expected value" $structure $key }}
|
||||||
|
@@ -1,11 +1,20 @@
|
|||||||
<!--
|
<!--
|
||||||
Displays a breadcrum for a specific page. The shortcode supports the following arguments:
|
Copyright © 2023 The Hinode Team / Mark Dumay. All rights reserved.
|
||||||
"path" Optional path of the page, defaults to current page.
|
Use of this source code is governed by The MIT License (MIT) that can be found in the LICENSE file.
|
||||||
|
Visit gethinode.com/license for more details.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
{{- $error := false -}}
|
{{ $error := false }}
|
||||||
|
|
||||||
|
<!-- Validate arguments -->
|
||||||
|
{{ if partial "utilities/IsInvalidArgs.html" (dict "structure" "breadcrumb" "args" .Params "group" "shortcode") }}
|
||||||
|
{{ errorf "Invalid arguments: %s" .Position -}}
|
||||||
|
{{ $error = true }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
<!-- Initialize arguments -->
|
||||||
{{- $page := . -}}
|
{{- $page := . -}}
|
||||||
{{- $path := .Get "path" | default "" }}
|
{{- $path := .Get "path" }}
|
||||||
{{- if $path -}}
|
{{- if $path -}}
|
||||||
{{- $page = .Site.GetPage $path -}}
|
{{- $page = .Site.GetPage $path -}}
|
||||||
{{- if not $page -}}
|
{{- if not $page -}}
|
||||||
@@ -14,6 +23,7 @@
|
|||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
|
<!-- Main code -->
|
||||||
{{- if not $error -}}
|
{{- if not $error -}}
|
||||||
{{- partial "assets/breadcrumb.html" $page -}}
|
{{- partial "assets/breadcrumb.html" (dict "page" $page) -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
@@ -10,7 +10,7 @@
|
|||||||
<div class="col col-{{ $breakpoint.prev }}-12 col-{{ $breakpoint.current }}-8">
|
<div class="col col-{{ $breakpoint.prev }}-12 col-{{ $breakpoint.current }}-8">
|
||||||
{{- if ne $layout "featured" -}}
|
{{- if ne $layout "featured" -}}
|
||||||
{{ if and (not $page.IsHome) site.Params.navigation.breadcrumb }}
|
{{ if and (not $page.IsHome) site.Params.navigation.breadcrumb }}
|
||||||
<div>{{ partial "assets/breadcrumb.html" $page }}</div>
|
<div>{{ partial "assets/breadcrumb.html" (dict "page" $page) }}</div>
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user