feat: improve configuration (#245)
* feat: improve configuration * fix: fix partials/footer.html error
This commit is contained in:
@@ -1,20 +1,26 @@
|
||||
{{- $scratch := newScratch -}}
|
||||
{{- .Scratch.Set "scratch" $scratch -}}
|
||||
{{- if eq hugo.Environment "production" -}}
|
||||
{{- $scratch.Set "CDN" .Site.Params.cdn -}}
|
||||
{{- $scratch.Set "fingerprint" .Site.Params.fingerprint -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $scratch.Set "major-version" "0.2.X" -}}
|
||||
{{- $scratch.Set "version" "0.2.0" -}}
|
||||
{{- $version := "0.2.X" -}}
|
||||
|
||||
{{- /* LoveIt theme version detection */ -}}
|
||||
{{- if not .Site.Params.version -}}
|
||||
{{- errorf "\n\nYou haven't configured the LoveIt version param correctly yet. See https://hugoloveit.com/theme-documentation-basics/#basic-configuration \n你还没有正确配置 LoveIt 的版本参数 参考 https://hugoloveit.com/zh-cn/theme-documentation-basics/#basic-configuration \n" -}}
|
||||
{{- else if ne .Site.Params.version ($scratch.Get "major-version") -}}
|
||||
{{- errorf (printf "\n\n%s -> %s:\nYou have an incompatible update. See https://github.com/dillonzq/LoveIt/releases \n你进行了一次不兼容的更新 参考 https://github.com/dillonzq/LoveIt/releases \n" .Site.Params.version ($scratch.Get "major-version")) -}}
|
||||
{{- else if ne .Site.Params.version $version -}}
|
||||
{{- errorf (printf "\n\n%s -> %s:\nYou have an incompatible update. See https://github.com/dillonzq/LoveIt/releases \n你进行了一次不兼容的更新 参考 https://github.com/dillonzq/LoveIt/releases \n" .Site.Params.version $version) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $params := .Params | merge .Site.Params.page -}}
|
||||
{{- .Scratch.Set "version" "0.2.0" -}}
|
||||
|
||||
{{- if eq hugo.Environment "production" -}}
|
||||
{{- .Scratch.Set "cdn" .Site.Params.cdn -}}
|
||||
{{- .Scratch.Set "fingerprint" .Site.Params.fingerprint -}}
|
||||
{{- else -}}
|
||||
{{- $params = dict "comment" nil | merge $params -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- .Scratch.Set "params" $params -}}
|
||||
{{- $this := dict "desktop" .Site.Params.header.desktopMode "mobile" .Site.Params.header.mobileMode | dict "headerMode" | dict "config" -}}
|
||||
{{- .Scratch.Set "this" $this -}}
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="{{ .Site.LanguageCode }}">
|
||||
<head>
|
||||
@@ -25,7 +31,7 @@
|
||||
<title>
|
||||
{{- block "title" . }}{{ .Site.Title }}{{ end -}}
|
||||
</title>
|
||||
<meta name="Description" content="{{ .Params.description | default .Site.Params.description }}">
|
||||
<meta name="Description" content="{{ $params.description | default .Site.Params.description }}">
|
||||
|
||||
{{- partial "head/meta.html" . -}}
|
||||
{{- partial "head/link.html" . -}}
|
||||
@@ -33,8 +39,8 @@
|
||||
</head>
|
||||
<body>
|
||||
{{- /* Check theme isDark before body rendering */ -}}
|
||||
{{- $theme := .Site.Params.defaultTheme -}}
|
||||
<script type="text/javascript">(window.localStorage && localStorage.getItem('theme') ? localStorage.getItem('theme') === 'dark' : ('{{ .Site.Params.defaultTheme }}' === 'auto' ? window.matchMedia('(prefers-color-scheme: dark)').matches : '{{ .Site.Params.defaultTheme }}' === 'dark')) && document.body.classList.add('dark');</script>
|
||||
{{- $theme := .Site.Params.defaulttheme -}}
|
||||
<script type="text/javascript">(window.localStorage && localStorage.getItem('theme') ? localStorage.getItem('theme') === 'dark' : ('{{ $theme }}' === 'auto' ? window.matchMedia('(prefers-color-scheme: dark)').matches : '{{ $theme }}' === 'dark')) && document.body.classList.add('dark');</script>
|
||||
|
||||
<div id="mask"></div>
|
||||
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
</h2>
|
||||
|
||||
{{- /* Paginate */ -}}
|
||||
{{- range (.Paginate (.Pages.GroupByDate "2006")).PageGroups -}}
|
||||
{{- $pages := .Pages.GroupByDate "2006" -}}
|
||||
{{- range (.Site.Params.section.paginate | default .Site.Params.paginate | .Paginate $pages).PageGroups -}}
|
||||
<h3>{{ .Key }}</h3>
|
||||
{{- range .Pages -}}
|
||||
<article class="archive-item">
|
||||
@@ -18,7 +19,7 @@
|
||||
{{- .Title -}}
|
||||
</a>
|
||||
<span class="archive-item-date">
|
||||
{{- .Date.Format (.Site.Params.dateFormatToUse | default "01-02") -}}
|
||||
{{- .Date.Format ($.Site.Params.section.dateFormat | default "01-02") -}}
|
||||
</span>
|
||||
</article>
|
||||
{{- end -}}
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
{{- define "title" }}{{ .Title }} | {{ .Site.Title }}{{ end -}}
|
||||
|
||||
{{- define "content" -}}
|
||||
{{- $params := .Scratch.Get "params" -}}
|
||||
<div class="page single special">
|
||||
{{- /* Title */ -}}
|
||||
<h1 class="single-title animated pulse faster">
|
||||
{{- .Title -}}
|
||||
</h1>
|
||||
{{- with .Params.subtitle -}}
|
||||
|
||||
{{- /* Subtitle */ -}}
|
||||
{{- with $params.subtitle -}}
|
||||
<h2 class="single-subtitle">{{ . }}</h2>
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Content */ -}}
|
||||
<div class="content" id="content">
|
||||
{{- partial "function/content.html" .Content | safeHTML -}}
|
||||
{{- dict "content" .Content "ruby" $params.ruby "fraction" $params.fraction "fontawesome" $params.fontawesome | partial "function/content.html" | safeHTML -}}
|
||||
</div>
|
||||
</div>
|
||||
{{- end -}}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
{{- $scratch := .Scratch.Get "scratch" -}}
|
||||
|
||||
{{- $params := .Params | merge .Site.Params.page -}}
|
||||
<article class="single summary" itemscope itemtype="http://schema.org/Article">
|
||||
{{- /* Featured image */ -}}
|
||||
{{- with .Params.featuredImage -}}
|
||||
{{- with $params.featuredimage -}}
|
||||
<div class="featured-image-preview">
|
||||
{{- $image := $.Params.featuredImagePreview | default . -}}
|
||||
{{- $image := $params.featuredimagepreview | default . -}}
|
||||
{{- partial "plugin/image.html" (dict "src" $image "alt" $.Description "large" true) -}}
|
||||
</div>
|
||||
{{- end -}}
|
||||
@@ -16,19 +15,19 @@
|
||||
|
||||
{{- /* Meta */ -}}
|
||||
<div class="post-meta">
|
||||
{{- $author := .Params.author | default .Site.Author.name | default (T "author") -}}
|
||||
{{- $authorLink := .Params.authorLink | default .Site.Author.link | default (relLangURL "/") -}}
|
||||
{{- $author := $params.author | default .Site.Author.name | default (T "author") -}}
|
||||
{{- $authorLink := $params.authorlink | default .Site.Author.link | default (relLangURL "/") -}}
|
||||
<span class="post-author">
|
||||
{{- $options := dict "class" "author" "href" $authorLink "title" "Author" "rel" "author" "icon" (dict "class" "fas fa-user-circle fa-fw") "content" $author -}}
|
||||
{{- partial "plugin/link.html" $options -}}
|
||||
</span>
|
||||
|
||||
{{- $publish_date := .PublishDate.Format (.Site.Params.dateFormatToUse | default "2006-01-02") -}}
|
||||
{{- $publish_date := .PublishDate.Format (.Site.Params.dateFormat | default "2006-01-02") -}}
|
||||
<span class="post-publish">
|
||||
{{ T "publish" }} <time datetime={{ $publish_date }}>{{ $publish_date }}</time>
|
||||
</span>
|
||||
|
||||
{{- with .Params.categories -}}
|
||||
{{- with $params.categories -}}
|
||||
|
||||
<span class="post-category">
|
||||
{{- T "included" -}}
|
||||
@@ -45,7 +44,7 @@
|
||||
{{- /* Summary content */ -}}
|
||||
<div class="content">
|
||||
{{- with .Summary -}}
|
||||
{{- partial "function/content.html" . | safeHTML -}}
|
||||
{{- dict "content" . "ruby" $params.ruby "fraction" $params.fraction "fontawesome" $params.fontawesome | partial "function/content.html" | safeHTML -}}
|
||||
{{- else -}}
|
||||
{{- .Description | safeHTML -}}
|
||||
{{- end -}}
|
||||
@@ -54,7 +53,7 @@
|
||||
{{- /* Footer */ -}}
|
||||
<div class="post-footer">
|
||||
<a href="{{ .RelPermalink }}">{{ T "readMore" }}</a>
|
||||
{{- with .Params.tags -}}
|
||||
{{- with $params.tags -}}
|
||||
<div class="post-tags">
|
||||
<i class="fas fa-tags fa-fw"></i>
|
||||
{{- range $index, $value := . -}}
|
||||
|
||||
Reference in New Issue
Block a user