Skip to content
This repository was archived by the owner on Mar 9, 2022. It is now read-only.

Commit

Permalink
feat(home): add custom content for home page (#248)
Browse files Browse the repository at this point in the history
  • Loading branch information
dillonzq authored Apr 22, 2020
1 parent a0ab272 commit 3c38d54
Show file tree
Hide file tree
Showing 20 changed files with 148 additions and 47 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:

Expand Down
3 changes: 2 additions & 1 deletion README.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) 自动转换图片为**懒加载**
Expand Down Expand Up @@ -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 主题中用到了以下项目,感谢它们的作者:

Expand Down
2 changes: 1 addition & 1 deletion assets/js/theme.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/theme.min.js.map

Large diffs are not rendered by default.

38 changes: 32 additions & 6 deletions exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ enableEmoji = true
# date format
# 日期格式
dateFormat = "2006-01-02"

# Header config
# 页面头部导航栏配置
[params.header]
Expand All @@ -546,6 +547,7 @@ enableEmoji = true
# mobile header mode ("fixed", "normal", "auto")
# 移动端导航栏模式 ("fixed", "normal", "auto")
mobileMode = "auto"

# Footer config
# 页面底部信息配置
[params.footer]
Expand All @@ -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]
Expand All @@ -580,6 +583,7 @@ enableEmoji = true
# date format (month and day)
# 日期格式 (月和日)
dateFormat = "01-02"

# List (category or tag) page config
# List (目录或标签) 页面配置
[params.list]
Expand All @@ -589,6 +593,7 @@ enableEmoji = true
# date format (month and day)
# 日期格式 (月和日)
dateFormat = "01-02"

# Page config
# 文章页面配置
[params.page]
Expand Down Expand Up @@ -774,18 +779,35 @@ 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 = ""
bing = ""
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 设置
Expand Down Expand Up @@ -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

Expand Down
5 changes: 3 additions & 2 deletions exampleSite/content/about.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.

Expand Down
5 changes: 3 additions & 2 deletions exampleSite/content/about.fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.

Expand Down
3 changes: 2 additions & 1 deletion exampleSite/content/about.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) 自动转换图片为**懒加载**
Expand Down Expand Up @@ -76,7 +77,7 @@ lightgallery: true

### 许可协议

LoveIt 根据 MIT 许可协议授权。
LoveIt 根据 **MIT** 许可协议授权。

更多信息请查看 [LICENSE 文件](https://github.com/dillonzq/LoveIt/blob/master/LICENSE)

Expand Down
21 changes: 20 additions & 1 deletion exampleSite/content/posts/theme-documentation-basics.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
21 changes: 20 additions & 1 deletion exampleSite/content/posts/theme-documentation-basics.fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
21 changes: 20 additions & 1 deletion exampleSite/content/posts/theme-documentation-basics.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
Expand Down
10 changes: 10 additions & 0 deletions layouts/index.html
Original file line number Diff line number Diff line change
@@ -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 */ -}}
Expand Down
11 changes: 3 additions & 8 deletions layouts/partials/assets.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
2 changes: 1 addition & 1 deletion layouts/partials/comment.html
Original file line number Diff line number Diff line change
@@ -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 -}}
Expand Down
22 changes: 22 additions & 0 deletions layouts/partials/plugin/analytics.html
Original file line number Diff line number Diff line change
@@ -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 -}}
13 changes: 0 additions & 13 deletions layouts/partials/plugin/analytics/fathom.html

This file was deleted.

2 changes: 1 addition & 1 deletion layouts/partials/plugin/script.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
Expand Down
Loading

0 comments on commit 3c38d54

Please sign in to comment.