mirror of
https://github.com/CaiJimmy/hugo-theme-stack.git
synced 2024-11-27 04:03:48 +01:00
feat: add data/external.yaml (#140)
* feat: add data/external.yaml Manage all external resources URL in one file * style: format data/external * style(helper/external): error message * remove whitespace
This commit is contained in:
parent
326c052a24
commit
8b17b8a4ee
5 changed files with 72 additions and 19 deletions
38
data/external.yaml
Normal file
38
data/external.yaml
Normal file
|
@ -0,0 +1,38 @@
|
|||
Vibrant:
|
||||
- src: https://cdn.jsdelivr.net/npm/node-vibrant@3.1.5/dist/vibrant.min.js
|
||||
integrity: sha256-5NovOZc4iwiAWTYIFiIM7DxKUXKWvpVEuMEPLzcm5/g=
|
||||
type: script
|
||||
|
||||
PhotoSwipe:
|
||||
- src: https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.js
|
||||
integrity: sha256-ePwmChbbvXbsO02lbM3HoHbSHTHFAeChekF1xKJdleo=
|
||||
type: script
|
||||
defer: true
|
||||
|
||||
- src: https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe-ui-default.min.js
|
||||
integrity: sha256-UKkzOn/w1mBxRmLLGrSeyB4e1xbrp4xylgAWb3M42pU=
|
||||
type: script
|
||||
defer: true
|
||||
|
||||
- src: https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/default-skin/default-skin.css
|
||||
integrity: sha256-c0uckgykQ9v5k+IqViZOZKc47Jn7KQil4/MP3ySA3F8=
|
||||
type: style
|
||||
|
||||
- src: https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.css
|
||||
integrity: sha256-SBLU4vv6CA6lHsZ1XyTdhyjJxCjPif/TRkjnsyGAGnE=
|
||||
type: style
|
||||
|
||||
KaTeX:
|
||||
- src: https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.css
|
||||
integrity: sha384-AfEj0r4/OFrOo5t7NnNe46zW/tFgW6x/bCJG8FqQCEo3+Aro6EYUG4+cU+KJWu/X
|
||||
type: style
|
||||
|
||||
- src: https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.js
|
||||
integrity: sha384-g7c+Jr9ZivxKLnZTDUhnkOnsh30B4H0rpLUpJ4jAIKs4fnJI+sEnkvrMWph2EDg4
|
||||
type: script
|
||||
defer: true
|
||||
|
||||
- src: https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/contrib/auto-render.min.js
|
||||
integrity: sha384-mll67QQFJfxn0IYznZYonOWZ644AWYC+Pt2cHqMaRhXVrursRwvLnLaebdGIlYNa
|
||||
type: script
|
||||
defer: true
|
|
@ -1,14 +1,6 @@
|
|||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.css"
|
||||
integrity="sha384-AfEj0r4/OFrOo5t7NnNe46zW/tFgW6x/bCJG8FqQCEo3+Aro6EYUG4+cU+KJWu/X" crossorigin="anonymous">
|
||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.js"
|
||||
integrity="sha384-g7c+Jr9ZivxKLnZTDUhnkOnsh30B4H0rpLUpJ4jAIKs4fnJI+sEnkvrMWph2EDg4"
|
||||
crossorigin="anonymous"></script>
|
||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/contrib/auto-render.min.js"
|
||||
integrity="sha384-mll67QQFJfxn0IYznZYonOWZ644AWYC+Pt2cHqMaRhXVrursRwvLnLaebdGIlYNa" crossorigin="anonymous"
|
||||
onload="StackLaTeX()"></script>
|
||||
|
||||
{{- partial "helper/external" (dict "Context" . "Namespace" "KaTeX") -}}
|
||||
<script>
|
||||
function StackLaTeX() {
|
||||
window.addEventListener("DOMContentLoaded", () => {
|
||||
renderMathInElement(document.querySelector(`.article-content`), {
|
||||
delimiters: [
|
||||
{ left: "$$", right: "$$", display: true },
|
||||
|
@ -16,6 +8,5 @@
|
|||
{ left: "\\(", right: "\\)", display: false },
|
||||
{ left: "\\[", right: "\\]", display: true }
|
||||
]
|
||||
});
|
||||
}
|
||||
});})
|
||||
</script>
|
|
@ -65,8 +65,4 @@
|
|||
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe-ui-default.min.js"></script>
|
||||
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/default-skin/default-skin.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.css">
|
||||
{{- partial "helper/external" (dict "Context" . "Namespace" "PhotoSwipe") -}}
|
|
@ -1,5 +1,4 @@
|
|||
<script src="https://cdn.jsdelivr.net/npm/node-vibrant@3.1.5/dist/vibrant.min.js"
|
||||
integrity="sha256-5NovOZc4iwiAWTYIFiIM7DxKUXKWvpVEuMEPLzcm5/g=" crossorigin="anonymous"></script>
|
||||
{{- partial "helper/external" (dict "Context" . "Namespace" "Vibrant") -}}
|
||||
|
||||
{{- $opts := dict "minify" hugo.IsProduction -}}
|
||||
{{- $script := resources.Get "ts/main.ts" | js.Build $opts -}}
|
||||
|
|
29
layouts/partials/helper/external.html
Normal file
29
layouts/partials/helper/external.html
Normal file
|
@ -0,0 +1,29 @@
|
|||
{{- $List := index .Context.Site.Data.external .Namespace -}}
|
||||
{{- with $List -}}
|
||||
{{- range . -}}
|
||||
{{- if eq .type "script" -}}
|
||||
<script
|
||||
src="{{ .src }}"
|
||||
{{- with .integrity -}}
|
||||
integrity="{{ . }}"
|
||||
{{- end -}}
|
||||
crossorigin="anonymous"
|
||||
defer="{{ default false .defer }}"
|
||||
>
|
||||
</script>
|
||||
{{- else if eq .type "style" -}}
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="{{ .src }}"
|
||||
{{- with .integrity -}}
|
||||
integrity="{{ . }}"
|
||||
{{- end -}}
|
||||
crossorigin="anonymous"
|
||||
>
|
||||
{{- else -}}
|
||||
{{- errorf "Error: unknown external resource type: %s" .type -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- errorf "Error: external resource '%s' is not found" .Namespace -}}
|
||||
{{- end -}}
|
Loading…
Reference in a new issue