diff --git a/layouts/partials/css.html b/layouts/partials/css.html new file mode 100644 index 0000000..80d2ff2 --- /dev/null +++ b/layouts/partials/css.html @@ -0,0 +1,61 @@ + +{{- $page := . -}} + +{{- $inServerMode := hugo.IsServer -}} +{{- $serverOpts := cond ($inServerMode) (dict "enableSourceMap" true) (dict "outputStyle" "compressed") -}} +{{- $sassCompiler := dict "transpiler" "dartsass" -}} +{{- $cssOpts := collections.Merge $sassCompiler $serverOpts -}} + + +{{ with $fonts := .Site.Params.fonts -}} + + + +{{ range $fonts }} +{{- $fontFace := replace .name " " "+" -}} +{{- $fontSizes := delimit (.weights | default (slice 300 400 600 700)) ";" -}} +{{- $fontUrl := printf "https://fonts.googleapis.com/css2?family=%s:wght@%s" $fontFace $fontSizes -}} + +{{- end }} +{{- end }} + + + + +{{- $sass := append (resources.Get "theme-css/sphinx-design/index.scss") + (resources.Get "theme-css/pst/bootstrap.scss") + (resources.Get "theme-css/pst/pydata-sphinx-theme.scss") + (resources.Get "theme-css/spht/index.scss") + (resources.Match "theme-css/*.scss") + | append (resources.Match "css/*.scss") -}} + +{{- range $sass -}} + {{ with . }} + {{- $targetFile := printf "%s.css" .RelPermalink -}} + {{- if $inServerMode -}} + {{ $css := resources.ExecuteAsTemplate $targetFile $page . | toCSS $cssOpts -}} + + {{ else }} + {{ $css := resources.ExecuteAsTemplate $targetFile $page . | toCSS $cssOpts | minify | fingerprint -}} + + {{- end -}} + {{- end -}} +{{- end -}} + + +{{- $themeCssFiles := resources.Match "theme-css/*.css" -}} +{{- $userCssFiles := resources.Match "css/*.css" -}} +{{- $cssFiles := $themeCssFiles | append $userCssFiles }} + +{{- range $cssFiles -}} + {{ if $inServerMode -}} + {{ $custom_style := . | resources.ExecuteAsTemplate . $page -}} + + {{ else }} + {{ $custom_style := . | resources.ExecuteAsTemplate . $page | minify | fingerprint -}} + + {{- end -}} +{{- end -}} diff --git a/layouts/partials/javascript.html b/layouts/partials/javascript.html new file mode 100644 index 0000000..084d7b5 --- /dev/null +++ b/layouts/partials/javascript.html @@ -0,0 +1,48 @@ +{{- $inServerMode := hugo.IsServer -}} + + + + + + + +{{- $jsFiles := collections.Sort (resources.Match "js/*.js") "Name" -}} +{{- if $inServerMode -}} +{{- $js := $jsFiles | resources.Concat "js/bundle.js" }} + +{{ else }} +{{- $js := $jsFiles | resources.Concat "js/bundle.js" | resources.Minify }} + +{{- end -}} + + + +{{- if .HasShortcode "youtube" }} + +{{ end -}} + +{{- if .Page.Store.Get "hasMermaid" }} + +{{ end -}}