feat(home): add custom content for home page (#248)

This commit is contained in:
Dillon 2020-04-22 17:50:30 +08:00 committed by GitHub
parent a0ab272f7d
commit 3c38d54a87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 148 additions and 47 deletions

View file

@ -62,8 +62,8 @@ I hope you will LoveIt ❤️!
* Optimized for **performance**: 99/100 on mobile and 100/100 on desktop in [Google PageSpeed Insights](https://developers.google.com/speed/pagespeed/insights)
* Optimized SEO performance with a correct **SEO SCHEMA** based on JSON-LD
* [**Google Analytics**](https://analytics.google.com/analytics) supported
* [**Fathom Analytics**](https://usefathom.com/) supported
* **[Google Analytics](https://analytics.google.com/analytics)** supported
* **[Fathom Analytics](https://usefathom.com/)** supported
* Search engine **verification** supported (Google, Bind, Yandex and Baidu)
* **CDN** for third-party libraries supported
* Automatically converted images with **Lazy Load** by [lazysizes](https://github.com/aFarkas/lazysizes)
@ -136,7 +136,7 @@ All feedback is welcome! Head over to the [issue tracker](https://github.com/dil
## License
LoveIt is licensed under the MIT license. Check the [LICENSE file](https://github.com/dillonzq/LoveIt/blob/master/LICENSE) for details.
LoveIt is licensed under the **MIT** license. Check the [LICENSE file](https://github.com/dillonzq/LoveIt/blob/master/LICENSE) for details.
Thanks to the authors of following resources included in the theme:

View file

@ -58,6 +58,7 @@
* **性能**优化:在 [Google PageSpeed Insights](https://developers.google.com/speed/pagespeed/insights) 中, 99/100 的移动设备得分和 100/100 的桌面设备得分
* 使用基于 JSON-LD 格式 的 **SEO SCHEMA** 文件进行 SEO 优化
* 支持 **[Google Analytics](https://analytics.google.com/analytics)**
* 支持 **[Fathom Analytics](https://usefathom.com/)**
* 支持搜索引擎的**网站验证** (Google, Bind, Yandex and Baidu)
* 支持所有第三方库的 **CDN**
* 基于 [lazysizes](https://github.com/aFarkas/lazysizes) 自动转换图片为**懒加载**
@ -130,7 +131,7 @@ LoveIt 支持下列语言:
## 许可协议
LoveIt 根据 MIT 许可协议授权。 更多信息请查看 [LICENSE 文件](https://github.com/dillonzq/LoveIt/blob/master/LICENSE)。
LoveIt 根据 **MIT** 许可协议授权。 更多信息请查看 [LICENSE 文件](https://github.com/dillonzq/LoveIt/blob/master/LICENSE)。
LoveIt 主题中用到了以下项目,感谢它们的作者:

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -537,6 +537,7 @@ enableEmoji = true
# date format
# 日期格式
dateFormat = "2006-01-02"
# Header config
# 页面头部导航栏配置
[params.header]
@ -546,6 +547,7 @@ enableEmoji = true
# mobile header mode ("fixed", "normal", "auto")
# 移动端导航栏模式 ("fixed", "normal", "auto")
mobileMode = "auto"
# Footer config
# 页面底部信息配置
[params.footer]
@ -571,6 +573,7 @@ enableEmoji = true
# license info (HTML format is supported)
# 许可协议信息 (支持 HTML 格式)
license= '<a rel="license external nofollow noopener noreffer" href="https://creativecommons.org/licenses/by-nc/4.0/" target="_blank">CC BY-NC 4.0</a>'
# Section (all posts) page config
# Section (所有文章) 页面配置
[params.section]
@ -580,6 +583,7 @@ enableEmoji = true
# date format (month and day)
# 日期格式 (月和日)
dateFormat = "01-02"
# List (category or tag) page config
# List (目录或标签) 页面配置
[params.list]
@ -589,6 +593,7 @@ enableEmoji = true
# date format (month and day)
# 日期格式 (月和日)
dateFormat = "01-02"
# Page config
# 文章页面配置
[params.page]
@ -774,7 +779,8 @@ enableEmoji = true
url = "cover.png"
width = 800
height = 600
# site verification code for Google/Bing/Yandex/Pinterest/Baidu
# Site verification code for Google/Bing/Yandex/Pinterest/Baidu
# 网站验证代码,用于 Google/Bing/Yandex/Pinterest/Baidu
[params.verification]
google = ""
@ -782,10 +788,26 @@ enableEmoji = true
yandex = ""
pinterest = ""
baidu = ""
[params.fathomAnalytics]
# siteID = "ABC123"
# If you're self hosting use this for your tracker
# serverURL = "https://example.com"
# Analytics config
# 网站分析配置
[params.analytics]
enable = false
# Google Analytics
[params.analytics.google]
id = ""
# whether to anonymize IP
# 是否匿名化用户 IP
anonymizeIP = true
# whether to use cookie
# 是否使用 cookie
cookie = false
# Fathom Analytics
[params.analytics.fathom]
id = ""
# server url for your tracker if you're self hosting
# 自行托管追踪器时的主机路径
server = ""
# CSS and JS Files CDN
# CSS 和 JS 文件的 CDN 设置
@ -899,8 +921,12 @@ enableEmoji = true
# Privacy config (https://gohugo.io/about/hugo-and-gdpr/)
# 隐私信息配置 (https://gohugo.io/about/hugo-and-gdpr/)
[privacy]
# privacy of the Google Analytics (replaced by params.analytics.google)
# Google Analytics 相关隐私 (被 params.analytics.google 替代)
[privacy.googleAnalytics]
anonymizeIP = true
# ...
[privacy.twitter]
enableDNT = true
[privacy.youtube]
privacyEnhanced = true

View file

@ -26,7 +26,8 @@ It is based on the original [LeaveIt Theme](https://github.com/liuzc/LeaveIt/) a
* :(fas fa-rocket): Optimized for **performance**: [99]/[100] on mobile and [100]/[100] on desktop in [Google PageSpeed Insights](https://developers.google.com/speed/pagespeed/insights)
* :(fab fa-searchengin): Optimized SEO performance with a correct **SEO SCHEMA** based on JSON-LD
* :(fab fa-google): [**Google Analytics**](https://analytics.google.com/analytics) supported
* :(fab fa-google): **[Google Analytics](https://analytics.google.com/analytics)** supported
* :(far fa-chart-bar): **[Fathom Analytics](https://usefathom.com/)** supported
* :(fas fa-search): Search engine **verification** supported (Google, Bind, Yandex and Baidu)
* :(fas fa-tachometer-alt): **CDN** for third-party libraries supported
* :(fas fa-cloud-download-alt): Automatically converted images with **Lazy Load** by [lazysizes](https://github.com/aFarkas/lazysizes)
@ -76,7 +77,7 @@ It is based on the original [LeaveIt Theme](https://github.com/liuzc/LeaveIt/) a
### License
LoveIt is licensed under the MIT license.
LoveIt is licensed under the **MIT** license.
Check the [LICENSE file](https://github.com/dillonzq/LoveIt/blob/master/LICENSE) for details.

View file

@ -31,7 +31,8 @@ It is based on the original [LeaveIt Theme](https://github.com/liuzc/LeaveIt/) a
* :(fas fa-rocket): Optimized for **performance**: [99]/[100] on mobile and [100]/[100] on desktop in [Google PageSpeed Insights](https://developers.google.com/speed/pagespeed/insights)
* :(fab fa-searchengin): Optimized SEO performance with a correct **SEO SCHEMA** based on JSON-LD
* :(fab fa-google): [**Google Analytics**](https://analytics.google.com/analytics) supported
* :(fab fa-google): **[Google Analytics](https://analytics.google.com/analytics)** supported
* :(far fa-chart-bar): **[Fathom Analytics](https://usefathom.com/)** supported
* :(fas fa-search): Search engine **verification** supported (Google, Bind, Yandex and Baidu)
* :(fas fa-tachometer-alt): **CDN** for third-party libraries supported
* :(fas fa-cloud-download-alt): Automatically converted images with **Lazy Load** by [lazysizes](https://github.com/aFarkas/lazysizes)
@ -81,7 +82,7 @@ It is based on the original [LeaveIt Theme](https://github.com/liuzc/LeaveIt/) a
### License
LoveIt is licensed under the MIT license.
LoveIt is licensed under the **MIT** license.
Check the [LICENSE file](https://github.com/dillonzq/LoveIt/blob/master/LICENSE) for details.

View file

@ -27,6 +27,7 @@ lightgallery: true
* :(fas fa-rocket): **性能**优化:在 [Google PageSpeed Insights](https://developers.google.com/speed/pagespeed/insights) 中, [99]/[100] 的移动设备得分和 [100]/[100] 的桌面设备得分
* :(fab fa-searchengin): 使用基于 JSON-LD 格式 的 **SEO SCHEMA** 文件进行 SEO 优化
* :(fab fa-google): 支持 **[Google Analytics](https://analytics.google.com/analytics)**
* :(far fa-chart-bar): 支持 **[Fathom Analytics](https://usefathom.com/)**
* :(fas fa-search): 支持搜索引擎的**网站验证** (Google, Bind, Yandex and Baidu)
* :(fas fa-tachometer-alt): 支持所有第三方库的 **CDN**
* :(fas fa-cloud-download-alt): 基于 [lazysizes](https://github.com/aFarkas/lazysizes) 自动转换图片为**懒加载**
@ -76,7 +77,7 @@ lightgallery: true
### 许可协议
LoveIt 根据 MIT 许可协议授权。
LoveIt 根据 **MIT** 许可协议授权。
更多信息请查看 [LICENSE 文件](https://github.com/dillonzq/LoveIt/blob/master/LICENSE)。

View file

@ -503,6 +503,22 @@ Note that some of these parameters are explained in details in other sections of
pinterest = ""
baidu = ""
# {{< version 0.2.0 >}} Analytics config
[params.analytics]
enable = false
# Google Analytics
[params.analytics.google]
id = ""
# whether to anonymize IP
anonymizeIP = true
# whether to use cookie
cookie = false
# Fathom Analytics
[params.analytics.fathom]
id = ""
# server url for your tracker if you're self hosting
server = ""
# CSS and JS Files CDN config
[params.cdn]
# {{< version 0.2.0 >}} {{< link "https://github.com/necolas/normalize.css" "normalize.css" >}}@8.0.1
@ -605,8 +621,11 @@ Note that some of these parameters are explained in details in other sections of
# {{< link "https://gohugo.io/about/hugo-and-gdpr/" "Privacy config" >}}
[privacy]
# {{< version 0.2.0 deleted >}} privacy of the Google Analytics (replaced by params.analytics.google)
[privacy.googleAnalytics]
anonymizeIP = true
# ...
[privacy.twitter]
enableDNT = true
[privacy.youtube]
privacyEnhanced = true

View file

@ -508,6 +508,22 @@ Note that some of these parameters are explained in details in other sections of
pinterest = ""
baidu = ""
# {{< version 0.2.0 >}} Analytics config
[params.analytics]
enable = false
# Google Analytics
[params.analytics.google]
id = ""
# whether to anonymize IP
anonymizeIP = true
# whether to use cookie
cookie = false
# Fathom Analytics
[params.analytics.fathom]
id = ""
# server url for your tracker if you're self hosting
server = ""
# CSS and JS Files CDN config
[params.cdn]
# {{< version 0.2.0 >}} {{< link "https://github.com/necolas/normalize.css" "normalize.css" >}}@8.0.1
@ -610,8 +626,11 @@ Note that some of these parameters are explained in details in other sections of
# {{< link "https://gohugo.io/about/hugo-and-gdpr/" "Privacy config" >}}
[privacy]
# {{< version 0.2.0 deleted >}} privacy of the Google Analytics (replaced by params.analytics.google)
[privacy.googleAnalytics]
anonymizeIP = true
# ...
[privacy.twitter]
enableDNT = true
[privacy.youtube]
privacyEnhanced = true

View file

@ -506,6 +506,22 @@ hugo
pinterest = ""
baidu = ""
# {{< version 0.2.0 >}} 网站分析配置
[params.analytics]
enable = false
# Google Analytics
[params.analytics.google]
id = ""
# 是否匿名化用户 IP
anonymizeIP = true
# 是否使用 cookie
cookie = false
# Fathom Analytics
[params.analytics.fathom]
id = ""
# 自行托管追踪器时的主机路径
server = ""
# CSS 和 JS 文件的 CDN 设置
[params.cdn]
# {{< version 0.2.0 >}} {{< link "https://github.com/necolas/normalize.css" "normalize.css" >}}@8.0.1
@ -608,8 +624,11 @@ hugo
# {{< link "https://gohugo.io/about/hugo-and-gdpr/" "隐私信息配置" >}}
[privacy]
# {{< version 0.2.0 deleted >}} Google Analytics 相关隐私 (被 params.analytics.google 替代)
[privacy.googleAnalytics]
anonymizeIP = true
# ...
[privacy.twitter]
enableDNT = true
[privacy.youtube]
privacyEnhanced = true

View file

@ -13,8 +13,8 @@
{{- if eq hugo.Environment "production" -}}
{{- .Scratch.Set "cdn" .Site.Params.cdn -}}
{{- .Scratch.Set "fingerprint" .Site.Params.fingerprint -}}
{{- else -}}
{{- $params = dict "comment" nil | merge $params -}}
{{- .Scratch.Set "analytics" .Site.Params.analytics -}}
{{- .Scratch.Set "comment" $params.comment -}}
{{- end -}}
{{- .Scratch.Set "params" $params -}}

View file

@ -1,10 +1,20 @@
{{- define "content" -}}
{{- $params := .Scratch.Get "params" -}}
<div class="page home">
{{- /* Profile */ -}}
{{- if ne .Site.Params.home.profile.enable false -}}
{{- partial "home/profile.html" . -}}
{{- end -}}
{{- /* Content */ -}}
{{- if .Content -}}
<div class="single">
<div class="content" id="content">
{{- dict "content" .Content "ruby" $params.ruby "fraction" $params.fraction "fontawesome" $params.fontawesome | partial "function/content.html" | safeHTML -}}
</div>
</div>
{{- end -}}
{{- /* Posts */ -}}
{{- if ne .Site.Params.home.posts.enable false -}}
{{- /* Paginate */ -}}

View file

@ -261,11 +261,6 @@
{{- partial "plugin/script.html" . -}}
{{- end -}}
{{- /* Google analytics async */ -}}
{{- if eq hugo.Environment "production" | and .Site.GoogleAnalytics -}}
{{- template "_internal/google_analytics_async.html" . -}}
{{ if and .Site.Params.fathomAnalytics .Site.Params.fathomAnalytics.siteID }}
{{- partial "plugin/analytics/fathom" . -}}
{{ end }}
{{- end -}}
{{- with .Scratch.Get "analytics" -}}
{{- partial "plugin/analytics.html" . -}}
{{- end -}}

View file

@ -1,6 +1,6 @@
{{- $cdn := .Scratch.Get "cdn" | default dict -}}
{{- $fingerprint := .Scratch.Get "fingerprint" -}}
{{- $comment := (.Scratch.Get "params").comment | default dict -}}
{{- $comment := .Scratch.Get "comment" | default dict -}}
{{- $commentConfig := dict -}}
{{- if $comment.enable -}}

View file

@ -0,0 +1,22 @@
{{- if .enable -}}
{{- /* Google Analytics */ -}}
{{- with .google.id -}}
<script type="text/javascript">
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
ga('create', '{{ . }}', {{- if $.google.cookie }}'auto'{{ else }}{ 'storage': 'none' }{{ end }});
{{- if $.google.anonymizeIP }}ga('set', 'anonymizeIp', true);{{ end -}}
ga('send', 'pageview');
</script>
{{- dict "source" "https://www.google-analytics.com/analytics.js" "async" true | partial "plugin/script.html" -}}
{{- end -}}
{{- /* Fathom Analytics */ -}}
{{- with .fathom.id -}}
<script type="text/javascript">
window.fathom=window.fathom||function(){(fathom.q=fathom.q||[]).push(arguments)};
fathom('set', 'siteId', '{{ . }}');
fathom('trackPageview');
</script>
{{- dict "source" ($.fathom.server | default "cdn.usefathom.com" | printf "https://%s/tracker.js") "async" true "attr" "id=fathom-script" | partial "plugin/script.html" -}}
{{- end -}}
{{- end -}}

View file

@ -1,13 +0,0 @@
<script>
(function(f, a, t, h, o, m){
a[h]=a[h]||function(){
(a[h].q=a[h].q||[]).push(arguments)
};
o=f.createElement('script'),
m=f.getElementsByTagName('script')[0];
o.async=1; o.src=t; o.id='fathom-script';
m.parentNode.insertBefore(o,m)
})(document, window, '//{{ .Site.Params.fathomAnalytics.serverURL | default "cdn.usefathom.com" }}/tracker.js', 'fathom');
fathom('set', 'siteId', '{{ .Site.Params.fathomAnalytics.siteID }}');
fathom('trackPageview');
</script>

View file

@ -3,7 +3,7 @@
{{- else -}}
{{- $src := .source -}}
{{- $integrity := .integrity -}}
{{- if strings.HasPrefix $src "http" | not -}}
{{- if strings.HasPrefix $src "http" | or (strings.HasPrefix $src "||") | not -}}
{{- $res := resources.Get $src -}}
{{- with .template -}}
{{- $res = $res | resources.ExecuteAsTemplate . $.context -}}

View file

@ -48,7 +48,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;
{{- $comment := $params.comment | default dict -}}
{{- $comment := .Scratch.Get "comment" | default dict -}}
{{- if $comment.enable | and $comment.valine.enable | and $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" }}

View file

@ -325,7 +325,7 @@ class Theme {
initHeaderLink() {
for (let num = 1; num <= 6; num++) {
this.util.forEach(document.querySelectorAll('.page.single .content > h' + num), $header => {
this.util.forEach(document.querySelectorAll('.single .content > h' + num), $header => {
$header.classList.add('headerLink');
$header.innerHTML = `<a href="#${$header.id}" class="header-mark"></a>${$header.innerHTML}`;
});