mirror of
https://github.com/imfing/hextra.git
synced 2025-06-19 10:14:08 -04:00
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:
9
layouts/_markup/render-blockquote-alert.html
Normal file
9
layouts/_markup/render-blockquote-alert.html
Normal 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) -}}
|
3
layouts/_markup/render-blockquote-regular.html
Normal file
3
layouts/_markup/render-blockquote-regular.html
Normal file
@ -0,0 +1,3 @@
|
||||
<blockquote>
|
||||
{{ .Text }}
|
||||
</blockquote>
|
4
layouts/_markup/render-codeblock-mermaid.html
Normal file
4
layouts/_markup/render-codeblock-mermaid.html
Normal file
@ -0,0 +1,4 @@
|
||||
<pre class="mermaid hx:mt-6">
|
||||
{{ .Inner | htmlEscape | safeHTML }}
|
||||
</pre>
|
||||
{{- .Page.Store.Set "hasMermaid" true -}}
|
13
layouts/_markup/render-codeblock.html
Normal file
13
layouts/_markup/render-codeblock.html
Normal 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>
|
8
layouts/_markup/render-heading.html
Normal file
8
layouts/_markup/render-heading.html
Normal 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 */ -}}
|
43
layouts/_markup/render-image.html
Normal file
43
layouts/_markup/render-image.html
Normal 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 -}}
|
16
layouts/_markup/render-link.html
Normal file
16
layouts/_markup/render-link.html
Normal 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 -}}
|
9
layouts/_markup/render-passthrough.html
Normal file
9
layouts/_markup/render-passthrough.html
Normal 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 -}}
|
Reference in New Issue
Block a user