Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/uPagge/uBlogger.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDillon <dillonzq@outlook.com>2020-03-16 16:35:16 +0300
committerGitHub <noreply@github.com>2020-03-16 16:35:16 +0300
commit41c2d3a38e77b5a0db8ff9d8d3f49730355f554c (patch)
tree92a82ec8f17bf17a32a08af9cb2826e833ce097d /layouts
parent9a7189c2a3f52792dfa5bbd96aaa7c8626ed457c (diff)
feat: add detection of the theme version and Hugo version (#173)
* feat: add detection of the theme version and Hugo version * fix: hugo.IsProduction is incompatible in Hugo v0.62.0
Diffstat (limited to 'layouts')
-rw-r--r--layouts/_default/baseof.html16
-rw-r--r--layouts/partials/assets.html2
-rw-r--r--layouts/partials/comment.html2
-rw-r--r--layouts/partials/footer.html5
-rw-r--r--layouts/partials/head/meta.html1
-rw-r--r--layouts/posts/single.html2
-rw-r--r--layouts/shortcodes/version.html1
7 files changed, 19 insertions, 10 deletions
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html
index d40eaf9..9a50e83 100644
--- a/layouts/_default/baseof.html
+++ b/layouts/_default/baseof.html
@@ -1,16 +1,20 @@
-{{- /* LoveIt theme version detection */ -}}
-{{- if ne .Site.Params.version "0.1.X" -}}
- {{- errorf "\n\nThere are two possible situations that led to this error:\n 1. You haven't copied the config.toml yet. See https://github.com/dillonzq/LoveIt#installation \n 2. You have an incompatible update. See https://github.com//dillonzq/LoveIt/blob/master/CHANGELOG.md \n\n有两种可能的情况会导致这个错误发生:\n 1. 你还没有复制 config.toml 参考 https://github.com/dillonzq/LoveIt#installation \n 2. 你进行了一次不兼容的更新 参考 https://github.com//dillonzq/LoveIt/blob/master/CHANGELOG.md \n" -}}
-{{- end -}}
-
{{- $scratch := newScratch -}}
{{- .Scratch.Set "scratch" $scratch -}}
{{- if eq hugo.Environment "production" -}}
- {{- $scratch.Set "production" true -}}
{{- $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" -}}
+
+{{- /* 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")) -}}
+{{- end -}}
+
<!DOCTYPE html>
<html lang="{{ .Site.LanguageCode }}">
<head>
diff --git a/layouts/partials/assets.html b/layouts/partials/assets.html
index a7c39b4..4beb7f2 100644
--- a/layouts/partials/assets.html
+++ b/layouts/partials/assets.html
@@ -243,6 +243,6 @@
{{- end -}}
{{- /* Google analytics async */ -}}
-{{- if $scratch.Get "production" | and .Site.GoogleAnalytics -}}
+{{- if eq hugo.Environment "production" | and .Site.GoogleAnalytics -}}
{{- template "_internal/google_analytics_async.html" . -}}
{{- end -}}
diff --git a/layouts/partials/comment.html b/layouts/partials/comment.html
index 0c9d64e..262d340 100644
--- a/layouts/partials/comment.html
+++ b/layouts/partials/comment.html
@@ -1,6 +1,6 @@
{{- $scratch := .Scratch.Get "scratch" -}}
-{{- if $scratch.Get "production" | and (ne .Site.Params.comment.enable false) | and (ne .Params.comment false) -}}
+{{- if eq hugo.Environment "production" | and (ne .Site.Params.comment.enable false) | and (ne .Params.comment false) -}}
{{- $CDN := $scratch.Get "CDN" -}}
{{- /* Disqus Comment System */ -}}
diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html
index d6c72e4..f3489d8 100644
--- a/layouts/partials/footer.html
+++ b/layouts/partials/footer.html
@@ -1,8 +1,11 @@
+{{- $scratch := .Scratch.Get "scratch" -}}
+
<footer class="footer">
<div class="copyright">
{{- /* Hugo and LoveIt */ -}}
<div class="copyright-line">
- {{- printf (T "poweredBySome") `<a href="https://gohugo.io/" target="_blank" rel="external nofollow noopener noreffer">Hugo</a>` | safeHTML }} | {{ T "theme" }} - <a href="https://github.com/dillonzq/LoveIt" target="_blank" rel="external nofollow noopener noreffer"><i class="far fa-heart fa-fw"></i> LoveIt</a>
+ {{- $hugo := printf `<a href="https://gohugo.io/" target="_blank" rel="noopener noreffer" title="Hugo %s">Hugo</a>` hugo.Version -}}
+ {{- printf (T "poweredBySome") $hugo | safeHTML }} | {{ T "theme" }} - <a href="https://github.com/dillonzq/LoveIt" target="_blank" rel="noopener noreffer" title="LoveIt v{{ $scratch.Get "version" }}"><i class="far fa-heart fa-fw"></i> LoveIt</a>
</div>
<div class="copyright-line">
diff --git a/layouts/partials/head/meta.html b/layouts/partials/head/meta.html
index a85d74f..56fcd32 100644
--- a/layouts/partials/head/meta.html
+++ b/layouts/partials/head/meta.html
@@ -1,5 +1,6 @@
{{- template "_internal/opengraph.html" . -}}
{{- template "_internal/twitter_cards.html" . -}}
+{{- hugo.Generator -}}
<meta name="theme-color" content="#ffffff">
<meta name="msapplication-TileColor" content="#da532c">
diff --git a/layouts/posts/single.html b/layouts/posts/single.html
index 6c58599..4877b1b 100644
--- a/layouts/posts/single.html
+++ b/layouts/posts/single.html
@@ -37,7 +37,7 @@
<i class="far fa-calendar-alt fa-fw"></i><time datetime={{ $publish_date }}>{{ $publish_date }}</time>&nbsp;
<i class="fas fa-pencil-alt fa-fw"></i>{{ T "wordCount" .WordCount }}&nbsp;
<i class="far fa-clock fa-fw"></i>{{ T "readingTime" .ReadingTime }}&nbsp;
- {{- if $scratch.Get "production" | and .Site.Params.comment.valine.enable | and .Site.Params.comment.valine.visitor -}}
+ {{- if eq hugo.Environment "production" | and .Site.Params.comment.valine.enable | and .Site.Params.comment.valine.visitor -}}
<span id="{{ .RelPermalink | relURL }}" class="leancloud_visitors" data-flag-title="{{ .Title }}">
<i class="far fa-eye fa-fw"></i><span class=leancloud-visitors-count></span>&nbsp;{{ T "views" }}
</span>&nbsp;
diff --git a/layouts/shortcodes/version.html b/layouts/shortcodes/version.html
new file mode 100644
index 0000000..c115cd2
--- /dev/null
+++ b/layouts/shortcodes/version.html
@@ -0,0 +1 @@
+<span class="version"><i class="far fa-heart fa-fw"></i> LoveIt <i class="fas fa-greater-than-equal fa-fw"></i> <a href="https://github.com/dillonzq/LoveIt/releases/tag/v{{ .Get 0 }}" rel="noopener noreffer" target="_blank" title="LoveIt v{{ .Get 0 }}">{{ .Get 0 }}</a></span> \ No newline at end of file