2022-07-02 22:22:46 +08:00
{{/* Use to defind global variables */}}
2022-07-27 11:21:03 +08:00
{{ $version := int (index (split hugo.Version ".") 1) }}
{{ if lt $version 89 }}
2022-07-30 17:39:57 +08:00
{{ warnf "当前 Hugo 版本小于 0.89.0,请到官方地址下载 Hugo 最新版本: https://github.com/gohugoio/hugo/releases" }}
{{ errorf "Current Hugo version is less then 0.89.0, Please download Hugo latest version on offical site: https://github.com/gohugoio/hugo/releases" }}
{{ end }}
{{ if not hugo.IsExtended }}
{{ warnf "Hugo NexT 主题使用了 SCSS 框架,请到官方地址下载 Hugo Extended 版本: https://github.com/gohugoio/hugo/releases" }}
{{ errorf "Because that use SCSS framework in Hugo NexT, Please download Hugo extended version on offical site: https://github.com/gohugoio/hugo/releases" }}
2022-07-27 11:21:03 +08:00
{{ end }}
2022-07-30 17:39:57 +08:00
2022-07-22 17:16:34 +08:00
{{ $globalVars := newScratch }}
2022-07-20 15:42:01 +08:00
2023-06-24 11:08:17 +08:00
{{ $pages := (where .Page.Site.RegularPages "Section" "in" .Site.Params.mainSections) }}
{{ $globalVars.Set "pages" $pages}}
{{ $globalVars.Set "postsCount" (len $pages)}}
2022-07-22 17:16:34 +08:00
{{ $globalVars.Set "catsCount" (len .Site.Taxonomies.categories) }}
{{ $globalVars.Set "tagsCount" (len .Site.Taxonomies.tags) }}
2022-07-20 15:42:01 +08:00
2022-07-22 17:16:34 +08:00
{{ $vendor := .Site.Params.vendors.plugins }}
{{ $router := index .Site.Data.resources.vendors $vendor }}
2022-09-19 21:57:23 +08:00
{{ $globalVars.Set "vendor" $vendor }}
2022-07-22 17:16:34 +08:00
{{ $globalVars.Set "router" $router }}
2022-07-20 15:42:01 +08:00
2022-07-22 17:16:34 +08:00
{{ $config := dict
2022-07-31 11:02:55 +08:00
"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
2023-01-02 20:08:48 +08:00
"placeholder" (T "Search.placeholder")
"empty" (T "Search.empty")
"hits_time" (T "Search.time")
"hits" (T "Search.hits")
2022-09-12 10:22:22 +08:00
"ds_years" (T "DateSuffix.years")
"ds_days" (T "DateSuffix.days")
"ds_hours" (T "DateSuffix.hours")
"ds_mins" (T "DateSuffix.mins")
2022-09-11 22:40:38 +08:00
"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")
2022-07-31 11:02:55 +08:00
)
2022-07-22 17:16:34 +08:00
}}
2022-07-22 18:35:04 +08:00
2022-07-31 18:01:57 +08:00
{{ if .Site.Params.localSearch.enable }}
{{ $localSearch := dict "localSearch" .Site.Params.localSearch }}
{{ $config = merge $config $localSearch }}
{{ end }}
2023-04-05 12:16:05 +08:00
{{ with .Site.Params.postMeta }}
{{ $postmeta := dict
"views" .views
"comments" .comments
}}
{{ $config = merge $config (dict "postmeta" $postmeta) }}
{{ else }}
{{ end }}
2022-07-31 18:01:57 +08:00
{{ 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 }}
2022-07-22 18:35:04 +08:00
{{ 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.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.addThisId }}
{{ $addthis := dict
"js" $.Site.Data.resources.addthis.js
"cfg" (dict "pubid" .)
}}
{{ $config = merge $config (dict "addthis" $addthis) }}
{{ end }}
2022-10-27 17:29:18 +08:00
{{ with .Site.Params.siteState.statistic }}
{{ $statis := dict "statis" . }}
{{ $config = merge $config $statis }}
{{ end }}
2022-10-27 15:57:42 +08:00
{{ with .Site.Params.analytics.laId }}
{{ $lawidget := dict
"js" $.Site.Data.resources.analytics.laWidget
"id" .
}}
{{ $config = merge $config (dict "lawidget" $lawidget) }}
{{ end }}
2022-07-22 17:16:34 +08:00
{{ $globalVars.Set "config" $config }}
2022-09-10 21:41:33 +08:00
{{ with .Site.Params.customFilePath }}
{{ range $k, $v := . }}
{{ $globalVars.Set $k $v }}
{{ end }}
{{ end }}
2022-10-23 16:05:23 +08:00
{{ $theme := "light" }}
{{ if .Site.Params.darkmode }}
{{ $theme = "dark" }}
{{ end }}
{{ $globalVars.Set "theme" $theme }}
2022-07-22 17:16:34 +08:00
{{ return $globalVars.Values }}