hugo-theme-next/layouts/partials/init.html
2025-01-24 21:47:06 +08:00

194 lines
5.5 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{{/* Use to defind global variables */}}
{{ $majorVer := int (index (split hugo.Version ".") 1) }}
{{ if lt $majorVer 134 }}
{{ errorf "当前 Hugo 版本为 %s 小于 0.134.0,请到官方地址下载 Hugo 最新版本https://github.com/gohugoio/hugo/releases" hugo.Version }}
{{ errorf "Current Hugo version is %s less then 0.134.0, Please download the Hugo latest version from offical site: https://github.com/gohugoio/hugo/releases" hugo.Version }}
{{ end }}
{{ if not hugo.IsExtended }}
{{ errorf "Hugo NexT 主题使用了 SCSS 框架,请到官方地址下载 Hugo Extended 版本https://github.com/gohugoio/hugo/releases" }}
{{ errorf "Because that use SCSS framework in Hugo NexT, Please download the Hugo extended version from offical site: https://github.com/gohugoio/hugo/releases" }}
{{ end }}
{{ $globalVars := newScratch }}
{{ $pages := (where .Page.Site.RegularPages "Section" "in" .Site.Params.mainSections) }}
{{ $globalVars.Set "pages" $pages}}
{{ $globalVars.Set "postsCount" (len $pages)}}
{{ $globalVars.Set "catsCount" (len .Site.Taxonomies.categories) }}
{{ $globalVars.Set "tagsCount" (len .Site.Taxonomies.tags) }}
{{ $vendor := .Site.Params.vendors.plugins }}
{{ $router := dict }}
{{ if eq $vendor "local" }}
{{ $router = dict "url" (printf "%sjs/3rd" .Site.BaseURL) "name" $vendor "type" "modern" }}
{{ else }}
{{ range .Site.Data.resources.vendors }}
{{ if eq .name $vendor }}
{{ $router = . }}
{{ break }}
{{ end }}
{{ end }}
{{ end }}
{{ $globalVars.Set "vendor" $vendor }}
{{ $globalVars.Set "router" $router }}
{{ $config := dict
"hostname" .Site.BaseURL
"root" "/"
"lang" .Site.LanguageCode
"vendor" (dict "plugins" $vendor "router" $router)
"darkmode" .Site.Params.darkmode
"version" .Site.Data.config.version
"scheme" .Site.Params.scheme
"sidebar" .Site.Params.sidebar
"copybtn" .Site.Params.codeblock.copyBtn
"bookmark" .Site.Params.bookmark
"lazyload" .Site.Params.lazyload
"motion" .Site.Params.motion
"i18n" (dict
"enable" .Site.Params.footer.translate
"placeholder" (T "Search.placeholder")
"empty" (T "Search.empty")
"hits_time" (T "Search.time")
"hits" (T "Search.hits")
"ds_years" (T "DateSuffix.years")
"ds_days" (T "DateSuffix.days")
"ds_hours" (T "DateSuffix.hours")
"ds_mins" (T "DateSuffix.mins")
"ds_month" (T "DateSuffix.month")
"ds_day" (T "DateSuffix.day")
"ds_hour" (T "DateSuffix.hour")
"ds_min" (T "DateSuffix.min")
"ds_just" (T "DateSuffix.just")
)
}}
{{ if .Site.Params.localSearch.enable }}
{{ $localSearch := dict "localSearch" .Site.Params.localSearch }}
{{ $config = merge $config $localSearch }}
{{ end }}
{{ with .Site.Params.postMeta }}
{{ $postmeta := dict
"views" .views
"comments" .comments
}}
{{ $config = merge $config (dict "postmeta" $postmeta) }}
{{ else }}
{{ end }}
{{ if .Site.Params.algoliaSearch.enable }}
{{ $algoliaSearch := dict
"js" .Site.Data.resources.algolia
"instantjs" .Site.Data.resources.instant
"cfg" .Site.Params.algoliaSearch
}}
{{ $config = merge $config (dict "algolia" $algoliaSearch) }}
{{ end }}
{{ with .Site.Params.waline }}
{{ $waline := dict
"js" $.Site.Data.resources.waline.js
"css" $.Site.Data.resources.waline.css
"cfg" .
}}
{{ $config = merge $config (dict "waline" $waline) }}
{{ end }}
{{ with .Site.Params.waline3 }}
{{ $waline := dict
"js" $.Site.Data.resources.waline3.js
"css" $.Site.Data.resources.waline3.css
"cfg" .
}}
{{ $config = merge $config (dict "waline3" $waline) }}
{{ end }}
{{ with .Site.Params.giscus }}
{{ $giscus := dict
"js" $.Site.Data.resources.giscus.js
"cfg" .
}}
{{ $config = merge $config (dict "giscus" $giscus) }}
{{ end }}
{{ with .Site.Params.artalk }}
{{ $artalk := dict
"js" $.Site.Data.resources.artalk.js
"css" $.Site.Data.resources.artalk.css
"cfg" .
}}
{{ $config = merge $config (dict "artalk" $artalk) }}
{{ end }}
{{ with .Site.Params.livere }}
{{ $livere := dict "js" $.Site.Data.resources.livere.js }}
{{ $config = merge $config (dict "livere" $livere) }}
{{ end }}
{{ with .Site.Params.utterances }}
{{ $utterances := dict
"js" $.Site.Data.resources.utterances.js
"cfg" .
}}
{{ $config = merge $config (dict "utterances" $utterances) }}
{{ end }}
{{ with .Site.Params.share }}
{{ $share := dict "enable" .enable }}
{{ if isset . "sharethis" }}
{{ $sharethis := dict
"js" $.Site.Data.resources.share.sharethis.js
"id" .sharethis.id
}}
{{ $share = merge $share (dict "sharethis" $sharethis) }}
{{ end }}
{{ if isset . "addtoany" }}
{{ $addtoany := dict
"js" $.Site.Data.resources.share.addtoany.js
"locale" .addtoany.locale
"num" .addtoany.num_services
}}
{{ $share = merge $share (dict "addtoany" $addtoany) }}
{{ end }}
{{ $config = merge $config (dict "share" $share) }}
{{ end }}
{{ with .Site.Params.siteState.statistic }}
{{ $statis := dict "statis" . }}
{{ $config = merge $config $statis }}
{{ end }}
{{ with .Site.Params.analytics.laId }}
{{ $lawidget := dict
"js" $.Site.Data.resources.analytics.laWidget
"id" .
}}
{{ $config = merge $config (dict "lawidget" $lawidget) }}
{{ end }}
{{ $globalVars.Set "config" $config }}
{{ with .Site.Params.customFilePath }}
{{ range $k, $v := . }}
{{ $globalVars.Set $k $v }}
{{ end }}
{{ end }}
{{ $theme := "light" }}
{{ if .Site.Params.darkmode }}
{{ $theme = "dark" }}
{{ end }}
{{ $globalVars.Set "theme" $theme }}
{{ return $globalVars.Values }}