Init
This commit is contained in:
@@ -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) -}}
|
||||
@@ -0,0 +1,3 @@
|
||||
<blockquote>
|
||||
{{ .Text }}
|
||||
</blockquote>
|
||||
@@ -0,0 +1,4 @@
|
||||
<pre class="mermaid hx:mt-6">
|
||||
{{ .Inner | htmlEscape | safeHTML }}
|
||||
</pre>
|
||||
{{- .Page.Store.Set "hasMermaid" true -}}
|
||||
13
themes/hextra/layouts/_markup/render-codeblock.html
Normal file
13
themes/hextra/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
themes/hextra/layouts/_markup/render-heading.html
Normal file
8
themes/hextra/layouts/_markup/render-heading.html
Normal file
@@ -0,0 +1,8 @@
|
||||
<h{{ .Level }} {{- with .Attributes.class }} class="{{ . }}" {{- end }}>
|
||||
{{- .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
themes/hextra/layouts/_markup/render-image.html
Normal file
43
themes/hextra/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 -}}
|
||||
25
themes/hextra/layouts/_markup/render-link.html
Normal file
25
themes/hextra/layouts/_markup/render-link.html
Normal file
@@ -0,0 +1,25 @@
|
||||
{{- $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 . -}}
|
||||
{{- $isExternal := strings.HasPrefix .Destination "http" -}}
|
||||
<a href="{{ $dest | safeURL }}"
|
||||
{{- with .Title -}}title="{{ . }}"{{- end -}}
|
||||
{{- if $isExternal -}}target="_blank" rel="noopener"{{- end -}}
|
||||
>
|
||||
{{- .Text | safeHTML -}}
|
||||
{{- if and .Page.Site.Params.externalLinkDecoration $isExternal -}}
|
||||
{{- partial "utils/icon.html" (dict "name" "arrow-up-right" "attributes" `class="hx:inline hx:rtl:rotate-270 hx:align-baseline" height="1em"`) -}}
|
||||
{{- end -}}
|
||||
</a>
|
||||
{{- end -}}
|
||||
20
themes/hextra/layouts/_markup/render-passthrough.html
Normal file
20
themes/hextra/layouts/_markup/render-passthrough.html
Normal file
@@ -0,0 +1,20 @@
|
||||
{{- $engine := site.Params.math.engine | default "katex" -}}
|
||||
{{- if eq $engine "katex" -}}
|
||||
{{- $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 }}
|
||||
{{- else -}}
|
||||
{{/* MathJax - need to add delimiters back in */}}
|
||||
{{- $.Page.Store.Set "hasMath" true }}
|
||||
{{- if eq .Type "block" -}}
|
||||
\[{{- .Inner -}}\]
|
||||
{{- else -}}
|
||||
\( {{- .Inner -}} \)
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
Reference in New Issue
Block a user