aboutsummaryrefslogtreecommitdiff
path: root/forged/templates/_header.tmpl
diff options
context:
space:
mode:
Diffstat (limited to 'forged/templates/_header.tmpl')
-rw-r--r--forged/templates/_header.tmpl35
1 files changed, 35 insertions, 0 deletions
diff --git a/forged/templates/_header.tmpl b/forged/templates/_header.tmpl
new file mode 100644
index 0000000..340a2ac
--- /dev/null
+++ b/forged/templates/_header.tmpl
@@ -0,0 +1,35 @@
+{{/*
+ SPDX-License-Identifier: AGPL-3.0-only
+ SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org>
+*/}}
+{{- define "header" -}}
+<header id="main-header">
+ <div id="main-header-forge-title">
+ <a href="/">{{- .global.forge_title -}}</a>
+ </div>
+ <nav id="breadcrumb-nav">
+ {{- $path := "" -}}
+ {{- $url_segments := .url_segments -}}
+ {{- $dir_mode := .dir_mode -}}
+ {{- $ref_type := .ref_type -}}
+ {{- $ref := .ref_name -}}
+ {{- $separator_index := .separator_index -}}
+ {{- if eq $separator_index -1 -}}
+ {{- $separator_index = len $url_segments -}}
+ {{- end -}}
+ {{- range $i := $separator_index -}}
+ {{- $segment := index $url_segments $i -}}
+ {{- $path = printf "%s/%s" $path $segment -}}
+ <span class="breadcrumb-separator">/</span>
+ <a href="{{ $path }}{{ if or (ne $i (minus (len $url_segments) 1)) $dir_mode }}/{{ end }}{{- if $ref_type -}}?{{- $ref_type -}}={{- $ref -}}{{- end -}}">{{ $segment }}</a>
+ {{- end -}}
+ </nav>
+ <div id="main-header-user">
+ {{- if ne .user_id_string "" -}}
+ <a href="/-/users/{{- .user_id_string -}}">{{- .username -}}</a>
+ {{- else -}}
+ <a href="/-/login/">Login</a>
+ {{- end -}}
+ </div>
+</header>
+{{- end -}}