Files
hugo-theme-chirpy/layouts/partials/topbar.html
2025-04-20 18:43:02 +08:00

75 lines
2.4 KiB
HTML

<!-- The Top Bar -->
<header id="topbar-wrapper" class="flex-shrink-0" aria-label="Top Bar">
<div id="topbar" class="d-flex align-items-center justify-content-between px-lg-3 h-100">
<nav id="breadcrumb" aria-label="Breadcrumb">
{{ $page := . }}
{{ $url := .RelPermalink }}
{{ $paths := split (trim $url "/") "/" }}
{{ if or (eq $url "/") (eq $url (relLangURL "/")) }}
<!-- index page -->
<span>{{ T "tabs.home" | title }}</span>
{{ else }}
{{ range $index, $item := $paths }}
{{ if eq $index 0 }}
<span>
<a href="{{ "/" | relLangURL }}">
{{- T "tabs.home" | title -}}
</a>
</span>
{{ $currentMenuEntry := "" }}
{{ range site.Menus.main }}
{{ if eq .URL $page.RelPermalink }}
{{ $currentMenuEntry = . }}
{{ end }}
{{ end }}
<!-- 显示逻辑 -->
{{ if $currentMenuEntry }}
<span>{{ $currentMenuEntry.Name }}</span>
{{ else }}
<span>{{ $page.Title }}</span> <!-- 使用保存的页面对象 -->
{{ end }}
{{ end }}
{{ end }}
{{ end }}
</nav>
<!-- endof #breadcrumb -->
<button type="button" id="sidebar-trigger" class="btn btn-link" aria-label="Sidebar">
<i class="fas fa-bars fa-fw"></i>
</button>
<div id="topbar-title">
{{ if eq .Layout "home" }}
{{- .Site.Title -}}
{{ else if or (eq .Type "tabs") (eq .Kind "page") }}
{{- T (printf "tabs.%s" (path.Base $url)) | default .Title -}}
{{ else }}
{{- T (printf "layout.%s" .Layout) | default (.Layout | title) -}}
{{ end }}
</div>
<button type="button" id="search-trigger" class="btn btn-link" aria-label="Search">
<i class="fas fa-search fa-fw"></i>
</button>
<search id="search" class="align-items-center ms-3 ms-lg-0">
<i class="fas fa-search fa-fw"></i>
<input
class="form-control"
id="search-input"
type="search"
aria-label="search"
autocomplete="off"
placeholder="{{ T "search.hint" | title }}..."
>
</search>
<button type="button" class="btn btn-link text-decoration-none" id="search-cancel">
{{- T "search.cancel" -}}
</button>
</div>
</header>