mirror of
https://github.com/maikka39/Personal-Website.git
synced 2026-10-02 14:46:25 +00:00
Add breadcrumbs and cleanup writeup ui
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
{{- $breadcrumbs := slice }}
|
||||
{{- $path := .page.RelPermalink }}
|
||||
{{- $path = trim $path "/" }}
|
||||
{{- $currentPath := "" }}
|
||||
{{- range split $path "/" }}
|
||||
{{- $currentPath = printf "%s/%s" $currentPath . }}
|
||||
{{- $page := $.page.GetPage $currentPath }}
|
||||
{{- if ne (trim $currentPath "/") $path }}
|
||||
{{- $title := $page.Title }}
|
||||
{{- with $page.Params.breadcrumb }}
|
||||
{{- $title = . }}
|
||||
{{- end }}
|
||||
{{- $breadcrumbs = $breadcrumbs | append (dict "name" $title "url" $page.Permalink) }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- $breadcrumbs = after (int .page.IsPage) $breadcrumbs}}
|
||||
{{- if ne .page.Type "page"}}
|
||||
{{- if lt (default 0 .min) (len $breadcrumbs) }}
|
||||
{{- range $index, $breadcrumb := $breadcrumbs }}
|
||||
<a href="{{ $breadcrumb.url }}">{{ $breadcrumb.name }}</a>{{ if ne $index (sub (len $breadcrumbs) 1) }}<span> > </span>{{ end }}
|
||||
{{- end }}
|
||||
{{- if and $breadcrumbs .end }}
|
||||
{{ .end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
@@ -21,6 +21,9 @@
|
||||
{{- $breadcrumbs = $breadcrumbs | append (dict "name" "Not Found" "url" (printf "%s%s" $.Site.BaseURL (strings.TrimLeft "/" $currentPath))) }}
|
||||
{{- else }}
|
||||
{{- $title := $page.Title }}
|
||||
{{- with $page.Params.breadcrumb }}
|
||||
{{- $title = . }}
|
||||
{{- end }}
|
||||
{{- if eq (trim $currentPath "/") $path }}
|
||||
{{- $breadcrumbs = $breadcrumbs | append (dict "name" $visiblePage.Title "url" $visiblePage.Permalink) }}
|
||||
{{- else }}
|
||||
|
||||
Reference in New Issue
Block a user