chore: adapt theme to new template system (#696)

* Adapted theme's layout to [Hugo v0.146.0](https://gohugo.io/templates/new-templatesystem-overview/)
* Bumped minimal Hugo version to v0.146.0
This commit is contained in:
yuri
2025-06-01 01:25:39 +02:00
committed by GitHub
parent c8a231b650
commit a44de285b2
81 changed files with 7 additions and 7 deletions

View File

@ -0,0 +1,9 @@
{{- if not (in (slice "note" "tip" "important" "warning" "caution") .AlertType) -}}
{{- warnf "Alert type %s is not supported" .AlertType -}}
{{- end -}}
{{- $content := .Text -}}
{{- $alertType := .AlertType -}}
{{- $alertTitle := .AlertTitle -}}
{{- partial "components/github-style-alert.html" (dict "content" $content "alertType" $alertType "alertTitle" $alertTitle) -}}

View File

@ -0,0 +1,3 @@
<blockquote>
{{ .Text }}
</blockquote>

View File

@ -0,0 +1,4 @@
<pre class="mermaid hx:mt-6">
{{ .Inner | htmlEscape | safeHTML }}
</pre>
{{- .Page.Store.Set "hasMermaid" true -}}

View File

@ -0,0 +1,13 @@
{{- $class := .Attributes.class | default "" -}}
{{- $filename := .Attributes.filename | default "" -}}
{{- $base_url := .Attributes.base_url | default "" -}}
{{- $lang := .Attributes.lang | default .Type -}}
<div class="hextra-code-block hx:relative hx:mt-6 hx:first:mt-0 hx:group/code">
{{- partial "components/codeblock" (dict "filename" $filename "lang" $lang "base_url" $base_url "content" .Inner "options" .Options) -}}
{{- if or (eq site.Params.highlight.copy.enable nil) (site.Params.highlight.copy.enable) -}}
{{- partialCached "components/codeblock-copy-button" (dict "filename" $filename) $filename -}}
{{- end -}}
</div>

View File

@ -0,0 +1,8 @@
<h{{ .Level }}>
{{- .Text | safeHTML -}}
{{- if gt .Level 1 -}}
<span class="hx:absolute hx:-mt-20" id="{{ .Anchor | safeURL }}"></span>
<a href="#{{ .Anchor | safeURL }}" class="subheading-anchor" aria-label="Permalink for this section"></a>
{{- end -}}
</h{{ .Level }}>
{{- /* Drop trailing newlines */ -}}

View File

@ -0,0 +1,43 @@
{{- $alt := .PlainText | safeHTML -}}
{{- $lazyLoading := .Page.Site.Params.enableImageLazyLoading | default true -}}
{{- $dest := .Destination -}}
{{- $url := urls.Parse $dest -}}
{{- $isLocal := not $url.Scheme -}}
{{- $isPage := and (eq .Page.Kind "page") (not .Page.BundleType) -}}
{{- $startsWithSlash := hasPrefix $dest "/" -}}
{{- $startsWithRelative := hasPrefix $dest "../" -}}
{{- if and $dest $isLocal -}}
{{- if $startsWithSlash -}}
{{- with or (.PageInner.Resources.Get $url.Path) (resources.Get $url.Path) -}}
{{/* Images under assets directory */}}
{{- $query := cond $url.RawQuery (printf "?%s" $url.RawQuery) "" -}}
{{- $fragment := cond $url.Fragment (printf "#%s" $url.Fragment) "" -}}
{{- $dest = printf "%s%s%s" .RelPermalink $query $fragment -}}
{{- else -}}
{{/* Images under static directory */}}
{{- $dest = (relURL (strings.TrimPrefix "/" $dest)) -}}
{{- end -}}
{{- else if and $isPage (not $startsWithRelative) -}}
{{/* Images that are sibling to the individual page file */}}
{{ $dest = (printf "../%s" $dest) }}
{{- end -}}
{{- end -}}
{{- $attributes := "" -}}
{{- range $key, $value := .Attributes -}}
{{- if $value -}}
{{- $pair := printf "%s=%q" $key ($value | transform.HTMLEscape) -}}
{{- $attributes = printf "%s %s" $attributes $pair -}}
{{- end -}}
{{- end -}}
{{- with .Title -}}
<figure>
<img src="{{ $dest | safeURL }}" title="{{ . }}" alt="{{ $alt }}" {{ $attributes | safeHTMLAttr }} {{ if $lazyLoading }}loading="lazy"{{ end }} />
<figcaption>{{ . }}</figcaption>
</figure>
{{- else -}}
<img src="{{ $dest | safeURL }}" alt="{{ $alt }}" {{ $attributes | safeHTMLAttr }} {{ if $lazyLoading }}loading="lazy"{{ end }} />
{{- end -}}

View File

@ -0,0 +1,16 @@
{{- $dest := .Destination -}}
{{- $url := urls.Parse $dest -}}
{{- if and $dest (hasPrefix $dest "/") -}}
{{- with or (.PageInner.GetPage $url.Path) (.PageInner.Resources.Get $url.Path) (resources.Get $url.Path) -}}
{{- $query := cond $url.RawQuery (printf "?%s" $url.RawQuery) "" -}}
{{- $fragment := cond $url.Fragment (printf "#%s" $url.Fragment) "" -}}
{{- $dest = printf "%s%s%s" .RelPermalink $query $fragment -}}
{{- else -}}
{{- $dest = (relURL (strings.TrimPrefix "/" $dest)) -}}
{{- end -}}
{{- end -}}
{{- with . -}}
<a href="{{ $dest | safeURL }}" {{ with .Title }}title="{{ . }}"{{ end }}{{ if strings.HasPrefix .Destination "http" }}target="_blank" rel="noopener"{{ end }}>{{ .Text | safeHTML }}</a>
{{- end -}}

View File

@ -0,0 +1,9 @@
{{- $opts := dict "output" "htmlAndMathml" "displayMode" (eq .Type "block") }}
{{- with try (transform.ToMath .Inner $opts) }}
{{- with .Err }}
{{ errorf "Unable to render mathematical markup to HTML using the transform.ToMath function. The KaTeX display engine threw the following error: %s: see %s." . $.Position }}
{{- else }}
{{- .Value }}
{{- $.Page.Store.Set "hasMath" true }}
{{- end }}
{{- end -}}