-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update theme to work with hugo v0.139.0
- Loading branch information
Showing
3 changed files
with
279 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,207 @@ | ||
{{- /* Desktop header */ -}} | ||
<header class="desktop" id="header-desktop"> | ||
<div class="header-wrapper"> | ||
<div class="header-title"> | ||
<a href="{{ .Site.Home.RelPermalink }}" title="{{ .Site.Title }}"> | ||
{{- with .Site.Params.header.title -}} | ||
{{- with .logo -}} | ||
{{- dict "Src" . "Class" "logo" | partial "plugin/image.html" -}} | ||
{{- end -}} | ||
{{- with .pre -}} | ||
<span class="header-title-pre">{{ . | safeHTML }}</span> | ||
{{- end -}} | ||
{{- if .typeit -}} | ||
{{- $id := dict "Content" .name "Scratch" $.Scratch "Id" "desktop-header-typeit" | partial "function/id.html" -}} | ||
<span id="{{ $id }}" class="typeit"></span> | ||
{{- dict $id (slice $id) | dict "typeitMap" | merge ($.Scratch.Get "this") | $.Scratch.Set "this" -}} | ||
{{- else -}} | ||
{{- .name -}} | ||
{{- end -}} | ||
{{- with .post -}} | ||
<span class="header-title-post">{{ . | safeHTML }}</span> | ||
{{- end -}} | ||
{{- else -}} | ||
{{- .Site.Title -}} | ||
{{- end -}} | ||
</a> | ||
</div> | ||
<div class="menu"> | ||
<div class="menu-inner"> | ||
{{- range .Site.Menus.main -}} | ||
{{- $url := .URL | relLangURL -}} | ||
{{- with .Page -}} | ||
{{- $url = .RelPermalink -}} | ||
{{- end -}} | ||
<a class="menu-item{{ if $.IsMenuCurrent `main` . | or ($.HasMenuCurrent `main` .) | or (eq $.RelPermalink $url) }} active{{ end }}" href="{{ $url }}"{{ with .Title }} title="{{ . }}"{{ end }}{{ if (urls.Parse $url).Host }} rel="noopener noreferrer" target="_blank"{{ end }}> | ||
{{- .Pre | safeHTML }} {{ .Name }} {{ .Post | safeHTML -}} | ||
</a> | ||
{{- end -}} | ||
{{- if .Site.Menus.main -}} | ||
<span class="menu-item delimiter"></span> | ||
{{- end -}} | ||
{{- if hugo.IsMultilingual -}} | ||
<a href="javascript:void(0);" class="menu-item language" title="{{ T "selectLanguage" }}"> | ||
{{- .Language.LanguageName -}} | ||
<i class="fas fa-chevron-right fa-fw"></i> | ||
<select class="language-select" title="{{ T "selectLanguage" }}" id="language-select-desktop" onchange="location = this.value;"> | ||
{{- if eq .Kind "404" -}} | ||
{{- /* https://github.com/dillonzq/LoveIt/issues/378 */ -}} | ||
{{- range .Sites -}} | ||
{{- $link := printf "%v/404.html" .LanguagePrefix -}} | ||
<option value="{{ $link }}"{{ if eq . $.Site }} selected{{ end }}> | ||
{{- .Language.LanguageName -}} | ||
</option> | ||
{{- end -}} | ||
{{- else -}} | ||
{{- range .AllTranslations -}} | ||
<option value="{{ .RelPermalink }}"{{ if eq .Lang $.Lang }} selected{{ end }}> | ||
{{- .Language.LanguageName -}} | ||
</option> | ||
{{- end -}} | ||
{{- end -}} | ||
</select> | ||
</a> | ||
{{- end -}} | ||
{{- if .Site.Params.search.enable -}} | ||
<span class="menu-item search" id="search-desktop"> | ||
<input type="text" placeholder="{{ .Site.Params.search.placeholder | default (T `searchPlaceholder`) }}" id="search-input-desktop"> | ||
<a href="javascript:void(0);" class="search-button search-toggle" id="search-toggle-desktop" title="{{ T `search` }}"> | ||
<i class="fas fa-search fa-fw"></i> | ||
</a> | ||
<a href="javascript:void(0);" class="search-button search-clear" id="search-clear-desktop" title="{{ T `clear` }}"> | ||
<i class="fas fa-times-circle fa-fw"></i> | ||
</a> | ||
<span class="search-button search-loading" id="search-loading-desktop"> | ||
<i class="fas fa-spinner fa-fw fa-spin"></i> | ||
</span> | ||
</span> | ||
{{- end -}} | ||
{{- if eq .Site.Params.header.themeChangeMode "select" -}} | ||
<a href="javascript:void(0);" class="menu-item theme-select" title="{{ T "switchTheme" }}"> | ||
<i class="fas fa-adjust fa-fw"></i> | ||
<select class="color-theme-select" id="theme-select-desktop" title="{{ T "switchTheme" }}"> | ||
<option value="light">{{ T "Light" }}</option> | ||
<option value="dark">{{ T "Dark" }}</option> | ||
<option value="black">{{ T "Black" }}</option> | ||
<option value="auto">{{ T "Auto" }}</option> | ||
</select> | ||
</a> | ||
{{- else -}} | ||
<a href="javascript:void(0);" class="menu-item theme-switch" title="{{ T "switchTheme" }}"> | ||
<i class="fas fa-adjust fa-fw"></i> | ||
</a> | ||
{{- end -}} | ||
</div> | ||
</div> | ||
</div> | ||
</header> | ||
|
||
{{- /* Mobile header */ -}} | ||
<header class="mobile" id="header-mobile"> | ||
<div class="header-container"> | ||
<div class="header-wrapper"> | ||
<div class="header-title"> | ||
<a href="{{ .Site.Home.RelPermalink }}" title="{{ .Site.Title }}"> | ||
{{- with .Site.Params.header.title -}} | ||
{{- with .logo -}} | ||
{{- dict "Src" . "Class" "logo" | partial "plugin/image.html" -}} | ||
{{- end -}} | ||
{{- with .pre -}} | ||
<span class="header-title-pre">{{ . | safeHTML }}</span> | ||
{{- end -}} | ||
{{- if .typeit -}} | ||
{{- $id := dict "Content" .name "Scratch" $.Scratch "Id" "mobile-header-typeit" | partial "function/id.html" -}} | ||
<span id="{{ $id }}" class="typeit"></span> | ||
{{- dict $id (slice $id) | dict "typeitMap" | merge ($.Scratch.Get "this") | $.Scratch.Set "this" -}} | ||
{{- else -}} | ||
{{- .name -}} | ||
{{- end -}} | ||
{{- with .post -}} | ||
<span class="header-title-post">{{ . | safeHTML }}</span> | ||
{{- end -}} | ||
{{- else -}} | ||
{{- .Site.Title -}} | ||
{{- end -}} | ||
</a> | ||
</div> | ||
<div class="menu-toggle" id="menu-toggle-mobile"> | ||
<span></span><span></span><span></span> | ||
</div> | ||
</div> | ||
<div class="menu" id="menu-mobile"> | ||
{{- if .Site.Params.search.enable -}} | ||
<div class="search-wrapper"> | ||
<div class="search mobile" id="search-mobile"> | ||
<input type="text" placeholder="{{ .Site.Params.search.placeholder | default (T `searchPlaceholder`) }}" id="search-input-mobile"> | ||
<a href="javascript:void(0);" class="search-button search-toggle" id="search-toggle-mobile" title="{{ T `search` }}"> | ||
<i class="fas fa-search fa-fw"></i> | ||
</a> | ||
<a href="javascript:void(0);" class="search-button search-clear" id="search-clear-mobile" title="{{ T `clear` }}"> | ||
<i class="fas fa-times-circle fa-fw"></i> | ||
</a> | ||
<span class="search-button search-loading" id="search-loading-mobile"> | ||
<i class="fas fa-spinner fa-fw fa-spin"></i> | ||
</span> | ||
</div> | ||
<a href="javascript:void(0);" class="search-cancel" id="search-cancel-mobile"> | ||
{{ T `cancel` }} | ||
</a> | ||
</div> | ||
{{- end -}} | ||
{{- $currentPage := . -}} | ||
{{- range .Site.Menus.main -}} | ||
{{- $url := .URL | relLangURL -}} | ||
{{- with .Page -}} | ||
{{- $url = .RelPermalink -}} | ||
{{- end -}} | ||
<a class="menu-item" href="{{ $url }}" title="{{ .Title }}"{{ if (urls.Parse $url).Host }} rel="noopener noreferrer" target="_blank"{{ end }}> | ||
{{- .Pre | safeHTML }}{{ .Name }}{{ .Post | safeHTML -}} | ||
</a> | ||
{{- end -}} | ||
{{- if eq .Site.Params.header.themeChangeMode "select" -}} | ||
<a href="javascript:void(0);" class="menu-item theme-select" title="{{ T "switchTheme" }}"> | ||
<i class="fas fa-adjust fa-fw"></i> | ||
<select class="color-theme-select" id="theme-select-mobile" title="{{ T "switchTheme" }}"> | ||
<option value="light">{{ T "Light" }}</option> | ||
<option value="dark">{{ T "Dark" }}</option> | ||
<option value="black">{{ T "Black" }}</option> | ||
<option value="auto">{{ T "Auto" }}</option> | ||
</select> | ||
</a> | ||
{{- else -}} | ||
<a href="javascript:void(0);" class="menu-item theme-switch" title="{{ T "switchTheme" }}"> | ||
<i class="fas fa-adjust fa-fw"></i> | ||
</a> | ||
{{- end -}} | ||
{{- if hugo.IsMultilingual -}} | ||
<a href="javascript:void(0);" class="menu-item" title="{{ T "selectLanguage" }}"> | ||
{{- .Language.LanguageName -}} | ||
<i class="fas fa-chevron-right fa-fw"></i> | ||
<select class="language-select" title="{{ T "selectLanguage" }}" onchange="location = this.value;"> | ||
{{- if eq .Kind "404" -}} | ||
{{- /* https://github.com/dillonzq/LoveIt/issues/378 */ -}} | ||
{{- range .Sites -}} | ||
{{- $link := printf "%v/404.html" .LanguagePrefix -}} | ||
<option value="{{ $link }}"{{ if eq . $.Site }} selected{{ end }}> | ||
{{- .Language.LanguageName -}} | ||
</option> | ||
{{- end -}} | ||
{{- else -}} | ||
{{- range .AllTranslations -}} | ||
<option value="{{ .RelPermalink }}"{{ if eq .Lang $.Lang }} selected{{ end }}> | ||
{{- .Language.LanguageName -}} | ||
</option> | ||
{{- end -}} | ||
{{- end -}} | ||
</select> | ||
</a> | ||
{{- end -}} | ||
</div> | ||
</div> | ||
</header> | ||
<div class="search-dropdown desktop"> | ||
<div id="search-dropdown-desktop"></div> | ||
</div> | ||
<div class="search-dropdown mobile"> | ||
<div id="search-dropdown-mobile"></div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
{{- .Scratch.Set "version" "0.4.0" -}} | ||
|
||
{{- /* DoIt theme version detection */ -}} | ||
{{/* {{- $VERSION := "0.3.X" -}} | ||
{{- if eq .Site .Sites.Default -}} | ||
{{- if not .Site.Params.version -}} | ||
{{- errorf "Configuration Error 配置文件错误\n\nYou haven't configured the DoIt version param correctly yet. See https://hugodoit.pages.dev/theme-documentation-basics/#basic-configuration\n你还没有正确配置 DoIt 的版本参数. 参考 https://hugodoit.pages.dev/zh-cn/theme-documentation-basics/#basic-configuration\n\n" -}} | ||
{{- else if ne .Site.Params.version $VERSION -}} | ||
{{- errorf (printf "Compatibility Error 兼容性错误\n\n%v -> %v:\nYou have an incompatible update. See https://github.com/HEIGE-PCloud/DoIt/releases\n你进行了一次不兼容的更新. 参考 https://github.com/HEIGE-PCloud/DoIt/releases\n\n" .Site.Params.version $VERSION) -}} | ||
{{- end -}} | ||
{{- end -}} */}} | ||
{{/* temporarily disabling the version check, 0.3.X does not really contain a breaking change */}} | ||
{{/* TODO: properly restore DoIt using semiVer */}} | ||
|
||
{{- /* Check Hugo version */ -}} | ||
{{- $OLDEST_SUPPORTED_HUGO_VERSION := "0.83.0" -}} | ||
{{- if lt hugo.Version "0.83.0" -}} | ||
{{- errorf "\n\nHugo version is too low.\nHugo 版本过低。\n\nCurrent Hugo version is %v, the oldest supported version is %v.\n目前使用的 Hugo 版本为 %v, DoIt 支持的最老的 Hugo 版本为 %v。\n\nIf you are running Hugo on your own computer, check out https://gohugo.io/getting-started/installing/#upgrade-hugo for upgrading guide.\n如果你正在自己的计算机上运行 Hugo,请访问 https://gohugo.io/getting-started/installing/#upgrade-hugo 以查阅升级指南。\n\nIf you are deploying on a third-party platform, please configure Hugo version accordingly.\n如果你正在第三方平台上部署,请按照相应文档配置 Hugo 版本。\n\n" hugo.Version $OLDEST_SUPPORTED_HUGO_VERSION hugo.Version $OLDEST_SUPPORTED_HUGO_VERSION -}} | ||
{{- end -}} | ||
|
||
{{- /* Check Hugo extend */ -}} | ||
{{- if eq hugo.IsExtended false -}} | ||
{{- warnf "\n\nThe Hugo Extended version is necessary for SCSS support.\n需要使用 Hugo Extended 版本来获得 SCSS 支持。\n\n" -}} | ||
{{- end -}} | ||
|
||
|
||
{{- $params := .Params | merge .Site.Params.page -}} | ||
|
||
{{- if eq hugo.Environment "production" -}} | ||
{{- $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 -}} | ||
{{- if hasPrefix $value "https://" -}} | ||
{{- $cdn = $value | dict $key | merge $cdn -}} | ||
{{- else -}} | ||
{{- $cdn = printf "%v%v" $prefix $value | dict $key | merge $cdn -}} | ||
{{- end -}} | ||
{{- 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.comment -}} | ||
{{- else if eq .Params.comment false -}} | ||
{{- .Scratch.Set "comment" dict -}} | ||
{{- end -}} | ||
{{- else if eq .Site .Sites.Default -}} | ||
{{- warnf "\n\nCurrent environment is \"development\". The \"comment system\", \"PWA\", \"CDN\" and \"fingerprint\" will be disabled.\n当前运行环境是 \"development\". \"评论系统\", \"PWA\", \"CDN\" 和 \"fingerprint\" 不会启用.\n\n" -}} | ||
{{- end -}} | ||
|
||
{{- .Scratch.Set "params" $params -}} | ||
{{- .Scratch.Set "this" dict -}} | ||
|
||
{{- partial "plugin/compatibility.html" . -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{{- $version := .Get 0 -}} | ||
{{- $url := printf "https://github.com/HEIGE-PCloud/DoIt/releases/tag/v%v" $version -}} | ||
{{- $type := .Get 1 | default "new" | lower -}} | ||
{{- $label := T $type -}} | ||
{{- $color := cond (eq $type "changed") "ff9101" "00b1ff" | cond (eq $type "deleted") "ff5252" -}} | ||
{{- $pathTemplate := cond hugo.IsMultilingual (printf "svg/version/%%v-%%v.%v.svg" .Page.Language.Lang) "svg/version/%v-%v.svg" -}} | ||
{{- $path := printf $pathTemplate $version $type -}} | ||
{{- $resource := resources.Get "svg/version.template.svg" -}} | ||
{{- $resource = $resource | resources.ExecuteAsTemplate $path (dict "version" $version "label" $label "color" $color) | minify -}} | ||
{{- $alt := printf "DoIt %v | %v" $label $version -}} | ||
<a href="{{ $url }}" rel="noopener noreferrer" target="_blank"> | ||
{{- dict "Src" $resource.RelPermalink "Alt" $alt "Class" "version" | partial "plugin/image.html" -}} | ||
</a> |