diff --git a/fetch-static.sh b/fetch-static.sh deleted file mode 100755 index d346405ad6..0000000000 --- a/fetch-static.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh -# -# Fetch local copies of the remote CSS and JS files. - -cd $(dirname "$0")/static - -set -e - -curl -o "js/jsquery-3.6.3.min.js" "https://code.jquery.com/jquery-3.6.3.min.js" -curl -o "js/lunr-2.3.9.min.js" "https://unpkg.com/lunr@2.3.9/lunr.min.js" - -# we just grab the latest version of markmap-autoloader, since that's what the upstream source does -curl -o "js/markmap-autoloader.js" "https://cdn.jsdelivr.net/npm/markmap-autoloader" - -katex_version=0.16.4 -mkdir -p "css/katex@${katex_version}/dist" "js/katex@${katex_version}/dist/contrib" -curl -o "css/katex@${katex_version}/dist/katex.min.css" "https://cdn.jsdelivr.net/npm/katex@${katex_version}/dist/katex.min.css" -curl -o "js/katex@${katex_version}/dist/katex.min.js" "https://cdn.jsdelivr.net/npm/katex@${katex_version}/dist/katex.min.js" -curl -o "js/katex@${katex_version}/dist/contrib/mhchem.min.js" "https://cdn.jsdelivr.net/npm/katex@${katex_version}/dist/contrib/mhchem.min.js" -curl -o "js/katex@${katex_version}/dist/contrib/auto-render.min.js" "https://cdn.jsdelivr.net/npm/katex@${katex_version}/dist/contrib/auto-render.min.js" - -curl -o "js/mermaid-9.3.0.min.js" "https://cdn.jsdelivr.net/npm/mermaid@9.3.0/dist/mermaid.min.js" -curl -o "js/docsearch-3.5.2.min.js" "https://cdn.jsdelivr.net/npm/@docsearch/js@3.5.2" -curl -o "css/docsearch-3.5.2.min.css" "https://cdn.jsdelivr.net/npm/@docsearch/css@3.5.2" - diff --git a/layouts/partials/dl-asset.html b/layouts/partials/dl-asset.html new file mode 100644 index 0000000000..69352880ac --- /dev/null +++ b/layouts/partials/dl-asset.html @@ -0,0 +1,19 @@ +{{/* + + A partial to download an asset from a CDN at build time and serve it from our + server. It outputs a string which is the relative path to the asset. + + It accepts a string, which is the URL of the asset to download. + +*/}} +{{- $url := . -}} + +{{ with resources.GetRemote $url -}} + {{ with .Err -}} + {{ errorf "Could not retrieve asset at '%s' from CDN. Reason: %s." $url . -}} + {{ else -}} + {{ .RelPermalink -}} + {{ end -}} +{{ else -}} + {{ errorf "Could not find asset at '%s' on the CDN." $url -}} +{{ end -}} diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 57045cb2b4..0b319094ed 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -26,12 +26,12 @@ {{ template "_internal/twitter_cards.html" . -}} {{ partialCached "head-css.html" . "asdf" -}} {{ if .Site.Params.offlineSearch -}} {{ end -}} @@ -57,7 +57,7 @@ {{ define "algolia/head" -}} {{ if and .Site.Params.search (isset .Site.Params.search "algolia") -}} - {{ end -}} diff --git a/layouts/partials/scripts.html b/layouts/partials/scripts.html index dfa362c2d8..5a1e07ede3 100644 --- a/layouts/partials/scripts.html +++ b/layouts/partials/scripts.html @@ -32,7 +32,7 @@ }, }; - + {{ end -}} {{ if .Site.Params.plantuml.enable -}} @@ -41,22 +41,22 @@ {{ if $needKaTeX -}} {{/* load stylesheet and scripts for KaTeX support */ -}} - {{/* The loading of KaTeX is deferred to speed up page rendering */ -}} - {{ if $needmhchem -}} {{/* To add support for displaying chemical equations and physical units, load the mhchem extension: */ -}} - {{ end -}} {{/* To automatically render math in text elements, include the auto-render extension: */ -}} - @@ -78,7 +78,7 @@ {{ if $needmermaid -}} {{ $jsArray = $jsArray | append $jsMermaid -}} - + {{ end -}} {{ $js := $jsArray | resources.Concat "js/main.js" -}} @@ -108,7 +108,7 @@ {{ partial "hooks/body-end.html" . -}} {{ define "algolia/scripts" -}} -