Files
FixIt/layouts/_partials/init/detection-version.html
T
Cell 5322a15ceb docs(layouts): add header comments to undocumented partials
Add `{{/* ... */}}` header comments to 25 partials that had no documentation,
enabling `pnpm gen:docs` to generate their reference docs. Also fix
base/head/index.html leading blank line that prevented parser matching.

Groups covered: base/, feed/, function/, home/, init/, plugin/, single/, store/, (root).
2026-07-23 12:56:40 +08:00

51 lines
2.3 KiB
HTML

{{- /*
Version detection and update checking partial.
Validates Hugo minimum version, checks Hugo Extended edition, detects the
FixIt theme version from params, warns about dev versions, and optionally
checks for newer releases via the GitHub API.
*/ -}}
{{- $version := hugo.Store.Get "version" -}}
{{- $latest := $version -}}
{{- $devOpts := .Site.Store.Get "devOpts" -}}
{{- /* Check Hugo version */ -}}
{{- $MINIMAL_HUGO_VERSION := "0.161.0" -}}
{{- if lt hugo.Version $MINIMAL_HUGO_VERSION -}}
{{- errorf "\n\n%v\n\n" (dict "Current" hugo.Version "Minimal" $MINIMAL_HUGO_VERSION | T "init.hugoVersionError") -}}
{{- end -}}
{{- /* Check Hugo extend */ -}}
{{- if eq hugo.IsExtended false -}}
{{- warnf "\n\n%v\n\n" (T "init.hugoExtendedWarn") -}}
{{- end -}}
{{- /* Check for updates */ -}}
{{- if $devOpts.c4u -}}
{{- $url := "https://api.github.com/repos/hugo-fixit/FixIt/releases/latest" -}}
{{- $options := dict "headers" (hugo.Store.Get "githubTokenHeader") -}}
{{- $latest = (partial "function/get-remote-json" (dict "URL" $url "OPTIONS" $options )).tag_name -}}
{{- end -}}
{{- /* FixIt theme version detection */ -}}
{{- if .Site.Language.IsDefault -}}
{{- if not .Site.Params.version -}}
{{- errorf "FixIt %v\n%v\n\n" $version (T "init.configurationError") -}}
{{- else if gt "0.2.0" (strings.TrimPrefix "v" .Site.Params.version) -}}
{{- errorf "FixIt %v\n%v\n\n" $version (dict "From" .Site.Params.version "To" $version | T "init.compatibilityError") -}}
{{- end -}}
{{- if gt (len (findRE "^v[0-9]+\\.[0-9]+\\.[0-9]+-[0-9a-f]+$" $version)) 0 -}}
{{- warnidf "warning-dev-version" "FixIt %v\n%v" $version (T "init.devVersionWarn") -}}
{{- end -}}
{{- if (gt $latest $version) | and $devOpts.c4u -}}
{{- warnf "FixIt %v (⬆️ %v)\n%v`git submodule update --remote --merge`\n\n" $version $latest (T "init.quicklyUpgrade") -}}
{{- end -}}
{{- /* [todo] remove this temporary warning after v1.0.0 release */ -}}
{{- if hasPrefix $version "v1." -}}
{{- warnidf "warning-v1-dev" "FixIt %v\n⚠️ You are using a v1.0.0 development version, which may contain breaking changes.\nIt is recommended to use the latest stable release v0.4.5: https://github.com/hugo-fixit/FixIt/releases/tag/v0.4.5\n" $version -}}
{{- end -}}
{{- end -}}
{{- hugo.Store.Set "latest" $latest -}}