mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 15:28:57 +00:00
🚚 Perf: subdivide FixIt initialization
This commit is contained in:
@@ -17,6 +17,7 @@ All notable changes to this project will be documented in this file.
|
||||
- :bug: Fix: Giscus comments invalid config `inputPosition`
|
||||
- :bug: Fix: busuanzi logic error
|
||||
- :bug: Fix: close comment system logic error when the article was expired
|
||||
- :truck: Perf: subdivide FixIt initialization
|
||||
- :art: Style: add theme colors variables and add common color styles
|
||||
- :art: Style: add scroll bar for auto toc ([#136](https://github.com/Lruihao/FixIt/issues/136))
|
||||
- :wrench: Feat(cdn): add unpkg cdn support
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{{- partial "init.html" . -}}
|
||||
{{- partial "init/index.html" . -}}
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="{{ .Site.LanguageCode }}">
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
{{- $version := "v0.2.15-RC" -}}
|
||||
{{ $latest := (getJSON "https://api.github.com/repos/Lruihao/FixIt/releases/latest").tag_name | default $version }}
|
||||
{{- $VERSION := "0.2.X" -}}
|
||||
|
||||
{{- /* FixIt theme version detection */ -}}
|
||||
{{- if eq .Site .Sites.First -}}
|
||||
{{- if (strings.HasSuffix $version "RC") -}}
|
||||
{{- warnf "FixIt %v\n%v" $version (T "RCVersionWarn") -}}
|
||||
{{- end -}}
|
||||
{{- if not .Site.Params.version -}}
|
||||
{{- errorf "FixIt %v\n%v" $version (T "configurationError") -}}
|
||||
{{- else if ne .Site.Params.version $VERSION -}}
|
||||
{{- errorf "FixIt %v\n%v" $version (dict "From" .Site.Params.version "To" $VERSION | T "compatibilityError") -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $params := .Params | merge .Site.Params.page -}}
|
||||
{{- $toc := $params.toc -}}
|
||||
{{- if eq $toc true -}}
|
||||
{{- $toc = .Site.Params.page.toc | default dict -}}
|
||||
{{- else if eq $toc false -}}
|
||||
{{- $toc = dict "enable" false -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if hugo.IsProduction -}}
|
||||
{{- $cdn := .Site.Params.cdn -}}
|
||||
{{- with $cdn.data -}}
|
||||
{{- $cdnData := printf "data/cdn/%v" . | resources.Get | transform.Unmarshal -}}
|
||||
{{- $cdn = dict "simpleIconsPrefix" $cdnData.prefix.simpleIcons -}}
|
||||
{{- $prefix := $cdnData.prefix.libFiles | default "" -}}
|
||||
{{- range $key, $value := $cdnData.libFiles -}}
|
||||
{{- $cdn = printf "%v%v" $prefix $value | dict $key | merge $cdn -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- .Scratch.Set "cdn" $cdn -}}
|
||||
{{- .Scratch.Set "fingerprint" .Site.Params.fingerprint -}}
|
||||
{{- .Scratch.Set "analytics" .Site.Params.analytics -}}
|
||||
{{- .Scratch.Set "comment" $params.comment -}}
|
||||
{{- if eq .Params.comment true -}}
|
||||
{{- .Scratch.Set "comment" .Site.Params.page.comment -}}
|
||||
{{- else if eq .Params.comment false -}}
|
||||
{{- .Scratch.Set "comment" dict -}}
|
||||
{{- end -}}
|
||||
{{- else if eq .Site .Sites.First -}}
|
||||
{{- warnf "FixIt %v\n%v" $version (T "devEnvWarn") -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Deprecated parameter detection */ -}}
|
||||
{{- $warnErrors := slice -}}
|
||||
{{- with .Site.Params.home.profile.gravatarSite -}}
|
||||
{{- $warnErrors = $warnErrors | append "The parameter `home.profile.gravatarSite` is deprecated since v0.2.14, use `gravatar.host` instead." -}}
|
||||
{{- end -}}
|
||||
{{- with .Site.Params.ibruce.siteTime -}}
|
||||
{{- $warnErrors = $warnErrors | append "The parameter `ibruce.siteTime` is deprecated since v0.2.14, use `footer.siteTime` instead." -}}
|
||||
{{- end -}}
|
||||
{{- if len $warnErrors -}}
|
||||
{{- warnf "Deprecated parameter detection until %v\n - %v" $version (delimit $warnErrors "\n - ") -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- .Scratch.Set "version" $version -}}
|
||||
{{- .Scratch.Set "latest" $latest -}}
|
||||
{{- .Scratch.Set "params" $params -}}
|
||||
{{- .Scratch.Set "toc" $toc -}}
|
||||
{{- .Scratch.Set "this" dict -}}
|
||||
|
||||
{{- partial "plugin/compatibility.html" . -}}
|
||||
@@ -0,0 +1,12 @@
|
||||
{{- /* Deprecated parameter detection */ -}}
|
||||
|
||||
{{- $warnErrors := slice -}}
|
||||
{{- with .Site.Params.home.profile.gravatarSite -}}
|
||||
{{- $warnErrors = $warnErrors | append "The parameter `home.profile.gravatarSite` is deprecated since v0.2.14, use `gravatar.host` instead." -}}
|
||||
{{- end -}}
|
||||
{{- with .Site.Params.ibruce.siteTime -}}
|
||||
{{- $warnErrors = $warnErrors | append "The parameter `ibruce.siteTime` is deprecated since v0.2.14, use `footer.siteTime` instead." -}}
|
||||
{{- end -}}
|
||||
{{- if len $warnErrors -}}
|
||||
{{- warnf "Deprecated parameter detection until %v\n - %v" (.Scratch.Get "version") (delimit $warnErrors "\n - ") -}}
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,26 @@
|
||||
{{- /* FixIt theme environment detection */ -}}
|
||||
|
||||
{{- $params := .Scratch.Get "params" -}}
|
||||
|
||||
{{- if hugo.IsProduction -}}
|
||||
{{- $cdn := .Site.Params.cdn -}}
|
||||
{{- with $cdn.data -}}
|
||||
{{- $cdnData := printf "data/cdn/%v" . | resources.Get | transform.Unmarshal -}}
|
||||
{{- $cdn = dict "simpleIconsPrefix" $cdnData.prefix.simpleIcons -}}
|
||||
{{- $prefix := $cdnData.prefix.libFiles | default "" -}}
|
||||
{{- range $key, $value := $cdnData.libFiles -}}
|
||||
{{- $cdn = printf "%v%v" $prefix $value | dict $key | merge $cdn -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- .Scratch.Set "cdn" $cdn -}}
|
||||
{{- .Scratch.Set "fingerprint" .Site.Params.fingerprint -}}
|
||||
{{- .Scratch.Set "analytics" .Site.Params.analytics -}}
|
||||
{{- .Scratch.Set "comment" $params.comment -}}
|
||||
{{- if eq .Params.comment true -}}
|
||||
{{- .Scratch.Set "comment" .Site.Params.page.comment -}}
|
||||
{{- else if eq .Params.comment false -}}
|
||||
{{- .Scratch.Set "comment" dict -}}
|
||||
{{- end -}}
|
||||
{{- else if eq .Site .Sites.First -}}
|
||||
{{- warnf "FixIt %v\n%v" (.Scratch.Get "version") (T "devEnvWarn") -}}
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,19 @@
|
||||
{{- /* FixIt theme version detection */ -}}
|
||||
|
||||
{{- $version := "v0.2.15-RC" -}}
|
||||
{{ $header := dict "Authorization" "token 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" }}
|
||||
{{ $latest := (getJSON "https://api.github.com/repos/Lruihao/FixIt/releases/latest" $header).tag_name }}
|
||||
|
||||
{{- if eq .Site .Sites.First -}}
|
||||
{{- if (strings.HasSuffix $version "RC") -}}
|
||||
{{- warnf "FixIt %v\n%v" $version (T "RCVersionWarn") -}}
|
||||
{{- end -}}
|
||||
{{- if not .Site.Params.version -}}
|
||||
{{- errorf "FixIt %v\n%v" $version (T "configurationError") -}}
|
||||
{{- else if gt "0.2.0" (strings.TrimPrefix "v" .Site.Params.version) -}}
|
||||
{{- errorf "FixIt %v\n%v" $version (dict "From" .Site.Params.version "To" $version | T "compatibilityError") -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- .Scratch.Set "version" $version -}}
|
||||
{{- .Scratch.Set "latest" $latest -}}
|
||||
@@ -0,0 +1,9 @@
|
||||
{{- .Scratch.Set "params" (.Params | merge .Site.Params.page) -}}
|
||||
{{- .Scratch.Set "this" dict -}}
|
||||
|
||||
{{- partial "init/detection-version.html" . -}}
|
||||
{{- partial "init/detection-env.html" . -}}
|
||||
{{- partial "init/detection-deprecated.html" . -}}
|
||||
{{- partial "init/patch.html" . -}}
|
||||
|
||||
{{- partial "plugin/compatibility.html" . -}}
|
||||
@@ -0,0 +1,10 @@
|
||||
{{- $params := .Scratch.Get "params" -}}
|
||||
|
||||
{{- /* FixIt theme toc patch */ -}}
|
||||
{{- $toc := $params.toc -}}
|
||||
{{- if eq $toc true -}}
|
||||
{{- $toc = .Site.Params.page.toc | default dict -}}
|
||||
{{- else if eq $toc false -}}
|
||||
{{- $toc = dict "enable" false -}}
|
||||
{{- end -}}
|
||||
{{- .Scratch.Set "toc" $toc -}}
|
||||
Reference in New Issue
Block a user