update head.html
This commit is contained in:
@ -26,5 +26,5 @@ $code-icon-width: 1.75rem !default;
|
||||
|
||||
/* fonts */
|
||||
|
||||
$font-family-base: 'Source Sans 3', 'Microsoft Yahei', sans-serif !default;
|
||||
$font-family-base: 'Source Sans Pro', 'Microsoft Yahei', sans-serif !default;
|
||||
$font-family-heading: Lato, 'Microsoft Yahei', sans-serif !default;
|
||||
|
@ -1,5 +1,2 @@
|
||||
@use 'bootstrap/bootstrap';
|
||||
@use 'main';
|
||||
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css');
|
||||
@import url('https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&display=swap');
|
||||
@import url('https://fonts.googleapis.com/css2?family=Source+Sans+3:ital,wght@0,200..900;1,200..900&display=swap');
|
@ -23,7 +23,7 @@ path = "github.com/gohugoio/hugo-mod-bootstrap-scss/v5"
|
||||
toc = true
|
||||
|
||||
[params.assets]
|
||||
self_host = true
|
||||
self_host = false
|
||||
|
||||
[params.social]
|
||||
name = "Yifan"
|
||||
|
@ -8,11 +8,9 @@
|
||||
{{ $sass := resources.Get "scss/main.bundle.scss" }}
|
||||
{{ $style := $sass | toCSS $opts | minify | fingerprint }}
|
||||
<link rel="stylesheet" href="{{ $style.Permalink }}">
|
||||
{{ $jsFiles := resources.Match "js/**/*.js" }}
|
||||
{{ $jsBundle := $jsFiles | resources.Concat "js/bundle.js" | minify | fingerprint }}
|
||||
<script src="{{ $jsBundle.RelPermalink }}" integrity="{{ $jsBundle.Data.Integrity }}" type="module" defer></script>
|
||||
</head>
|
||||
<html>
|
||||
{{ partial "head.html" . }}
|
||||
<body>
|
||||
{{ partial "sidebar.html" . }}
|
||||
<div id="main-wrapper" class="d-flex justify-content-center">
|
||||
|
@ -1,5 +1,11 @@
|
||||
{{ $origin := cond (eq .Site.Params.self_host true) "basic" "cors" }}
|
||||
{{ $data := index .Site.Data.origin $origin }}
|
||||
{{- $jsOpts := dict
|
||||
"target" "es2015"
|
||||
"minify" (eq hugo.Environment "production")
|
||||
-}}
|
||||
{{- $themeOpts := merge $jsOpts (dict "global" "Theme") -}}
|
||||
{{- $theme := resources.Get "js/modules/theme.js" | js.Build $themeOpts -}}
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta name="theme-color" media="(prefers-color-scheme: light)" content="#f7f7f7">
|
||||
@ -47,7 +53,7 @@
|
||||
{{ if not site.Params.assets.self_host }}
|
||||
{{ range site.Data.origin.cors.resource_hints }}
|
||||
{{ range .links }}
|
||||
<link rel="{{ .rel }}" href="{{ .url }}" {{ delimit .opts " " | safeHTMLAttr }}>
|
||||
<link rel="{{ .rel }}" href="{{ .url }}" {{ if isset . "opts" }}{{ delimit .opts " " | safeHTMLAttr }}{{ end }}>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
@ -88,7 +94,7 @@
|
||||
{{ end }}
|
||||
|
||||
<!-- Scripts -->
|
||||
<script src="{{ "/assets/js/dist/theme.min.js" | relURL }}"></script>
|
||||
<script src="{{ $theme.RelPermalink }}"></script>
|
||||
|
||||
{{ partial "js-selector.html" . }}
|
||||
|
||||
|
105
layouts/partials/js-selector.html
Normal file
105
layouts/partials/js-selector.html
Normal file
@ -0,0 +1,105 @@
|
||||
{{ $origin := cond (eq .Site.Params.self_host true) "basic" "cors" }}
|
||||
{{ $data := index .Site.Data.origin $origin }}
|
||||
{{ $is_home := false }}
|
||||
{{ if or (eq .RelPermalink "/") (eq .RelPermalink (relLangURL "/")) }}
|
||||
{{ $is_home = true }}
|
||||
{{ end }}
|
||||
{{- $jsOpts := dict
|
||||
"target" "es2015"
|
||||
"minify" (eq hugo.Environment "production")
|
||||
-}}
|
||||
|
||||
{{ $urls := slice }}
|
||||
|
||||
|
||||
{{ $urls = $urls | append $data.search.js }}
|
||||
|
||||
|
||||
<!-- layout specified -->
|
||||
{{ if or (eq .Type "post") (eq .Type "page") $is_home }}
|
||||
{{ with $data.lazyPolyfill.js }}
|
||||
{{ $urls = $urls | append . }}
|
||||
{{ end }}
|
||||
|
||||
{{ if not $is_home }}
|
||||
<!-- image lazy-loading & popup & clipboard -->
|
||||
{{ with $data.glightbox.js }}
|
||||
{{ $urls = $urls | append . }}
|
||||
{{ end }}
|
||||
{{ with $data.clipboard.js }}
|
||||
{{ $urls = $urls | append . }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ if or $is_home (eq .Type "post") (eq .Type "archives") (eq .Type "category") (eq .Type "tag") }}
|
||||
{{ $locale := strings.TrimSuffix (path.Ext .Lang) .Lang }}
|
||||
|
||||
{{ with $data.dayjs.js.common }}
|
||||
{{ $urls = $urls | append . }}
|
||||
{{ end }}
|
||||
{{ with replace $data.dayjs.js.locale ":LOCALE" $locale }}
|
||||
{{ $urls = $urls | append . }}
|
||||
{{ end }}
|
||||
{{ with $data.dayjs.js.relativeTime }}
|
||||
{{ $urls = $urls | append . }}
|
||||
{{ end }}
|
||||
{{ with $data.dayjs.js.localizedFormat }}
|
||||
{{ $urls = $urls | append . }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ if or (strings.Contains .Content "<h2") (strings.Contains .Content "<h3") }}
|
||||
{{ if and site.Params.toc (default true .Params.toc) }}
|
||||
{{ with $data.toc.js }}
|
||||
{{ $urls = $urls | append . }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ if .Params.mermaid }}
|
||||
{{ with $data.mermaid.js }}
|
||||
{{ $urls = $urls | append . }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ range $urls }}
|
||||
<script src="{{ . }}"></script>
|
||||
{{ end }}
|
||||
|
||||
{{ $js := "commons" }}
|
||||
{{ if $is_home }}
|
||||
{{ $js = "home" }}
|
||||
{{ else if eq .Type "categories" }}
|
||||
{{ $js = "categories" }}
|
||||
{{ else if eq .Type "post" }}
|
||||
{{ $js = "post" }}
|
||||
{{ else if eq .Type "page" }}
|
||||
{{ $js = "page" }}
|
||||
{{ else if or (eq .Type "archives") (eq .Type "category") (eq .Type "tag") }}
|
||||
{{ $js = "misc" }}
|
||||
{{ end }}
|
||||
|
||||
{{- $script := resources.Get (printf "js/%s.js" $js) | js.Build $jsOpts -}}
|
||||
<script defer src="{{ $script.RelPermalink }}"></script>
|
||||
|
||||
{{ if .Params.math }}
|
||||
<!-- MathJax -->
|
||||
{{ $mathjaxConfig := resources.Get "js/data/mathjax.js" | minify | fingerprint }}
|
||||
<script async src="{{ $mathjaxConfig.RelPermalink }}"></script>
|
||||
<script async src="https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js?features=es6"></script>
|
||||
{{ $mathjax := (index site.Data.origin site.Params.cdn).mathjax.js }}
|
||||
<script id="MathJax-script" async src="{{ $mathjax }}"></script>
|
||||
{{ end }}
|
||||
|
||||
<!-- Pageviews -->
|
||||
{{ if eq .Type "post" }}
|
||||
{{ $provider := site.Params.pageviews.provider }}
|
||||
{{ if and $provider (ne $provider "") }}
|
||||
{{ if eq $provider "goatcounter" }}
|
||||
{{ if and site.Params.analytics.goatcounter.id (ne site.Params.analytics.goatcounter.id "") }}
|
||||
{{ partial (printf "pageviews/%s.html" $provider) . }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
Reference in New Issue
Block a user