Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/wangchucheng/hugo-eureka.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWang Chucheng <ccwangchn@gmail.com>2020-11-21 18:59:46 +0300
committerWang Chucheng <ccwangchn@gmail.com>2020-11-21 18:59:46 +0300
commitb346260f352021a98e9596b2e2c404c25c5887bd (patch)
tree8b2be8a472d4648d90c57b1093198a8916ad744f /layouts
parent1fc544b7cd8c578f4fc9daf810e42761b7a1e8c5 (diff)
feat: KaTeX support
Closes #9
Diffstat (limited to 'layouts')
-rw-r--r--layouts/partials/head.html51
1 files changed, 47 insertions, 4 deletions
diff --git a/layouts/partials/head.html b/layouts/partials/head.html
index bc0fd74..489402e 100644
--- a/layouts/partials/head.html
+++ b/layouts/partials/head.html
@@ -42,14 +42,57 @@
<link rel="preconnect" href="https://www.google-analytics.com" crossorigin>
<script async src="https://www.googletagmanager.com/gtag/js?id={{ . }}"></script>
<script>
- window.dataLayer = window.dataLayer || [];
- function gtag(){dataLayer.push(arguments);}
- gtag('js', new Date());
+ window.dataLayer = window.dataLayer || [];
+ function gtag(){dataLayer.push(arguments);}
+ gtag('js', new Date());
- gtag('config', '{{ . }}');
+ gtag('config', '{{ . }}');
</script>
{{ end }}
+{{ define "partials/get_bundles" }}
+{{ $currentPage := . }}
+{{ $bundles := slice $currentPage }}
+{{ if ne $currentPage $currentPage.FirstSection }}
+{{ $currentPage = $currentPage.Parent }}
+{{ $bundles = $bundles | append $currentPage }}
+{{ end }}
+{{ return $bundles.Reverse }}
+{{ end }}
+
+{{- $assets := .Site.Data.assets -}}
+{{- $enableMath := false }}
+{{- if .Site.Params.math.handler -}}
+{{- $bundles := partial "get_bundles" . -}}
+{{- $enableMath = true }}
+{{- range $bundles -}}
+{{- if and (ne .Params.math nil) (ne .Params.math "") -}}
+{{- $enableMath = .Params.math -}}
+{{- end -}}
+{{- end -}}
+{{- end -}}
+
+{{- if and (eq .Site.Params.math.handler "katex") $enableMath -}}
+<link rel="stylesheet" href="{{ printf $assets.katex.css.url $assets.katex.version }}"
+ {{- with $assets.katex.css.sri -}} integrity="{{ . }}" {{- end -}} media="print"
+ onload="this.media='all';this.onload=null" crossorigin>
+<script defer src="{{ printf $assets.katex.js.url $assets.katex.version }}" {{- with $assets.katex.js.sri -}}
+ integrity="{{ . }}" {{- end -}} crossorigin></script>
+<script defer src="{{ printf $assets.katex.autoRender.url $assets.katex.version }}"
+ {{- with $assets.katex.autoRender.sri -}} integrity="{{ . }}" {{- end -}} crossorigin></script>
+<script>
+ document.addEventListener("DOMContentLoaded", function() {
+ renderMathInElement(document.body{{- with .Site.Params.math.katex -}}, {
+ {{- range $key, $value := . -}}
+ {{- if $value -}}
+ {{- $key | safeJS -}}: {{- $value | safeJS -}}
+ {{- end -}}
+ {{- end -}}
+ }{{- end -}});
+ });
+</script>
+{{- end -}}
+
{{ with .Site.Params.icon }}
<link rel="icon" type="image/png" sizes="32x32" href="{{ (partial "get_icon" (dict "icon" . "size" 32)).Permalink }}">
<link rel="apple-touch-icon" sizes="180x180" href="{{ (partial "get_icon" (dict "icon" . "size" 180)).Permalink }}">