hugo-theme-next/layouts/partials/scripts.html

46 lines
1.8 KiB
HTML
Raw Normal View History

<!-- Plugin scripts files -->
{{- $jsRes := .Site.Data.resources.js }}
{{- $vendor := .Site.Params.vendors.plugins }}
{{- $vendorCDN := .Scratch.Get "pluginCDN" }}
{{- range $js := $jsRes }}
{{- $pluginJS := $vendorCDN }}
{{- $npm := $js.name }}
{{- $file := $js.file }}
{{- if eq $vendor "cdnjs" }}
{{- with $js.alias }}
{{- $npm = . }}
{{- end }}
{{- $file = replaceRE `(dist|lib|source\/js)\/` "" $js.file }}
{{- end }}
{{- $pluginJS = replace $pluginJS "${name}" $npm }}
{{- $pluginJS = replace $pluginJS "${version}" $js.version }}
{{- $pluginJS = replace $pluginJS "${file}" $file }}
<script type="text/javascript" src="{{ $pluginJS }}" defer></script>
{{- end }}
{{- $config := resources.Get "js/config.js" | resources.ExecuteAsTemplate "config.js" . }}
{{- $motion := resources.Get "js/motion.js" }}
{{- $boot := resources.Get "js/next-boot.js" }}
{{- $utils := resources.Get "js/utils.js" }}
{{- $nextjs := (slice $config $utils $boot ) }}
{{- if .Site.Params.motion.enable }}
{{ $motionjs := resources.Get "js/motion.js" }}
{{ $nextjs = $nextjs | append $motionjs }}
{{- end }}
{{- if or (eq .Site.Params.shceme "Muse") (eq .Site.Params.shceme "Mist") }}
{{ $musejs := resources.Get "js/schemes/muse.js" }}
{{ $nextjs = $nextjs | append $musejs }}
{{- end }}
{{- if .Site.Params.bookmark.enable }}
{{- $bookmarkjs := resources.Get "js/bookmark.js" }}
{{- $nextjs = $nextjs | append $bookmarkjs }}
{{- end }}
{{- if .Site.Params.pjax }}
{{- $pjaxjs := resources.Get "js/pjax.js" }}
{{- $nextjs = $nextjs | append $pjaxjs }}
{{- end }}
{{- $nextjs = $nextjs | resources.Concat "js/hugo-next.js"}}
{{ if hugo.IsProduction }}
{{- $nextjs = $nextjs | minify | fingerprint }}
{{ end }}
<script type="text/javascript" src="{{ $nextjs.RelPermalink }}" defer></script>