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

Commit

Permalink
feat: add social link for RSS and some configs (#250)
Browse files Browse the repository at this point in the history
  • Loading branch information
dillonzq authored Apr 22, 2020
1 parent f5fb31e commit 07b669c
Show file tree
Hide file tree
Showing 18 changed files with 199 additions and 67 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ I hope you will LoveIt ❤️!

* **Gravatar** supported by [Gravatar](https://gravatar.com)
* Local **Avatar** supported
* Up to **61** social links supported
* Up to **62** social links supported
* Up to **28** share sites supported
* **Disqus** comment system supported by [Disqus](https://disqus.com)
* **Gitalk** comment system supported by [Gitalk](https://github.com/gitalk/gitalk)
Expand Down
2 changes: 1 addition & 1 deletion README.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@

* 支持 **[Gravatar](https://gravatar.com)** 头像
* 支持本地**头像**
* 支持多达 **61** 种社交链接
* 支持多达 **62** 种社交链接
* 支持多达 **28** 种网站分享
* 支持 **[Disqus](https://disqus.com)** 评论系统
* 支持 **[Gitalk](https://github.com/gitalk/gitalk)** 评论系统
Expand Down
16 changes: 16 additions & 0 deletions exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ enableEmoji = true
searchKey = "b42948e51daaa93df92381c8e2ac0f93"
# Home page config
[languages.en.params.home]
# amount of RSS pages
rss = 10
# Home page profile
[languages.en.params.home.profile]
enable = true
Expand Down Expand Up @@ -190,6 +192,7 @@ enableEmoji = true
# XMPP = "xxxx"
# Matrix = "xxxx"
# Bilibili = "xxxx"
RSS = true

[languages.zh-cn]
weight = 2
Expand Down Expand Up @@ -269,6 +272,8 @@ enableEmoji = true
searchKey = "b42948e51daaa93df92381c8e2ac0f93"
# 主页信息设置
[languages.zh-cn.params.home]
# RSS 文章数目
rss = 10
# 主页个人信息
[languages.zh-cn.params.home.profile]
enable = true
Expand Down Expand Up @@ -355,6 +360,7 @@ enableEmoji = true
# XMPP = "[email protected]"
# Matrix = "xxxx"
Bilibili = "xxxx"
RSS = true

[languages.fr]
weight = 3
Expand Down Expand Up @@ -434,6 +440,8 @@ enableEmoji = true
searchKey = "b42948e51daaa93df92381c8e2ac0f93"
# Home page config
[languages.fr.params.home]
# amount of RSS pages
rss = 10
# Home page profile
[languages.fr.params.home.profile]
enable = true
Expand Down Expand Up @@ -520,6 +528,7 @@ enableEmoji = true
# XMPP = "xxxx"
# Matrix = "xxxx"
# Bilibili = "xxxx"
RSS = true

[params]
# LoveIt theme version
Expand Down Expand Up @@ -583,6 +592,9 @@ enableEmoji = true
# date format (month and day)
# 日期格式 (月和日)
dateFormat = "01-02"
# amount of RSS pages
# RSS 文章数目
rss = 10

# List (category or tag) page config
# List (目录或标签) 页面配置
Expand All @@ -593,6 +605,9 @@ enableEmoji = true
# date format (month and day)
# 日期格式 (月和日)
dateFormat = "01-02"
# amount of RSS pages
# RSS 文章数目
rss = 10

# Page config
# 文章页面配置
Expand Down Expand Up @@ -903,6 +918,7 @@ enableEmoji = true
# 作者配置
[author]
name = "xxxx"
email = ""
link = ""

# Sitemap config
Expand Down
2 changes: 1 addition & 1 deletion exampleSite/content/about.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ It is based on the original [LeaveIt Theme](https://github.com/liuzc/LeaveIt/) a

* :(far fa-user): **Gravatar** supported by [Gravatar](https://gravatar.com)
* :(fas fa-user-circle): Local **Avatar** supported
* :(far fa-id-card): Up to **61** social links supported
* :(far fa-id-card): Up to **62** social links supported
* :(fas fa-share-square): Up to **28** share sites supported
* :(far fa-comment): **Disqus** comment system supported by [Disqus](https://disqus.com)
* :(far fa-comment-dots): **Gitalk** comment system supported by [Gitalk](https://github.com/gitalk/gitalk)
Expand Down
2 changes: 1 addition & 1 deletion exampleSite/content/about.fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ It is based on the original [LeaveIt Theme](https://github.com/liuzc/LeaveIt/) a

* :(far fa-user): **Gravatar** supported by [Gravatar](https://gravatar.com)
* :(fas fa-user-circle): Local **Avatar** supported
* :(far fa-id-card): Up to **61** social links supported
* :(far fa-id-card): Up to **62** social links supported
* :(fas fa-share-square): Up to **28** share sites supported
* :(far fa-comment): **Disqus** comment system supported by [Disqus](https://disqus.com)
* :(far fa-comment-dots): **Gitalk** comment system supported by [Gitalk](https://github.com/gitalk/gitalk)
Expand Down
2 changes: 1 addition & 1 deletion exampleSite/content/about.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ lightgallery: true

* :(far fa-user): 支持 **[Gravatar](https://gravatar.com)** 头像
* :(fas fa-user-circle): 支持本地**头像**
* :(far fa-id-card): 支持多达 **61** 种社交链接
* :(far fa-id-card): 支持多达 **62** 种社交链接
* :(fas fa-share-square): 支持多达 **28** 种网站分享
* :(far fa-comment): 支持 **[Disqus](https://disqus.com)** 评论系统
* :(far fa-comment-dots): 支持 **[Gitalk](https://github.com/gitalk/gitalk)** 评论系统
Expand Down
8 changes: 8 additions & 0 deletions exampleSite/content/posts/theme-documentation-basics.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,16 +244,22 @@ Note that some of these parameters are explained in details in other sections of
paginate = 20
# date format (month and day)
dateFormat = "01-02"
# amount of RSS pages
rss = 10

# {{< version 0.2.0 >}} List (category or tag) page config
[params.list]
# special amount of posts in each list page
paginate = 20
# date format (month and day)
dateFormat = "01-02"
# amount of RSS pages
rss = 10

# Home page config
[params.home]
# {{< version 0.2.0 >}} amount of RSS pages
rss = 10
# Home page profile
[params.home.profile]
enable = true
Expand Down Expand Up @@ -343,6 +349,7 @@ Note that some of these parameters are explained in details in other sections of
# XMPP = "xxxx"
# Matrix = "xxxx"
# Bilibili = "xxxx"
RSS = true # {{< version 0.2.0 >}}

# {{< version 0.2.0 changed >}} Page config
[params.page]
Expand Down Expand Up @@ -606,6 +613,7 @@ Note that some of these parameters are explained in details in other sections of
# Author config
[author]
name = "xxxx"
email = ""
link = ""

# Sitemap config
Expand Down
8 changes: 8 additions & 0 deletions exampleSite/content/posts/theme-documentation-basics.fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,16 +249,22 @@ Note that some of these parameters are explained in details in other sections of
paginate = 20
# date format (month and day)
dateFormat = "01-02"
# amount of RSS pages
rss = 10

# {{< version 0.2.0 >}} List (category or tag) page config
[params.list]
# special amount of posts in each list page
paginate = 20
# date format (month and day)
dateFormat = "01-02"
# amount of RSS pages
rss = 10

# Home page config
[params.home]
# {{< version 0.2.0 >}} amount of RSS pages
rss = 10
# Home page profile
[params.home.profile]
enable = true
Expand Down Expand Up @@ -348,6 +354,7 @@ Note that some of these parameters are explained in details in other sections of
# XMPP = "xxxx"
# Matrix = "xxxx"
# Bilibili = "xxxx"
RSS = true # {{< version 0.2.0 >}}

# {{< version 0.2.0 changed >}} Page config
[params.page]
Expand Down Expand Up @@ -611,6 +618,7 @@ Note that some of these parameters are explained in details in other sections of
# Author config
[author]
name = "xxxx"
email = ""
link = ""

# Sitemap config
Expand Down
8 changes: 8 additions & 0 deletions exampleSite/content/posts/theme-documentation-basics.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,16 +247,22 @@ hugo
paginate = 20
# 日期格式 (月和日)
dateFormat = "01-02"
# RSS 文章数目
rss = 10

# {{< version 0.2.0 >}} List (目录或标签) 页面配置
[params.list]
# list 页面每页显示文章数量
paginate = 20
# 日期格式 (月和日)
dateFormat = "01-02"
# RSS 文章数目
rss = 10

# 主页配置
[params.home]
# {{< version 0.2.0 >}} RSS 文章数目
rss = 10
# 主页个人信息
[params.home.profile]
enable = true
Expand Down Expand Up @@ -346,6 +352,7 @@ hugo
# XMPP = "xxxx"
# Matrix = "xxxx"
Bilibili = "xxxx"
RSS = true # {{< version 0.2.0 >}}

# {{< version 0.2.0 changed >}} 文章页面配置
[params.page]
Expand Down Expand Up @@ -609,6 +616,7 @@ hugo
# 作者配置
[author]
name = "xxxx"
email = ""
link = ""

# 网站地图配置
Expand Down
28 changes: 15 additions & 13 deletions layouts/rss.xml → layouts/inde.rss.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
<channel>
<title>
{{- with .Title }}{{ . }} | {{ end }}{{ .Site.Title -}}
{{- .Site.Title -}}
</title>
<link>
{{- .Permalink -}}
</link>
<description>
{{- with .Title }}{{ . }} | {{ end }}{{ .Site.Title -}}
{{- .Site.Params.description | default .Site.Title -}}
</description>
<generator>Hugo -- gohugo.io</generator>
{{- with .Site.LanguageCode -}}
Expand All @@ -17,10 +17,10 @@
{{- end -}}
{{- with .Site.Author.email -}}
<managingEditor>
{{- . }}{{ with .Site.Author.name }} ({{ . }}){{ end -}}
{{- . }}{{ with $.Site.Author.name }} ({{ . }}){{ end -}}
</managingEditor>
<webMaster>
{{- . }}{{ with .Site.Author.name }} ({{ . }}){{ end -}}
{{- . }}{{ with $.Site.Author.name }} ({{ . }}){{ end -}}
</webMaster>
{{- end -}}
{{- with .Site.Copyright -}}
Expand All @@ -33,8 +33,8 @@
{{- .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" -}}
</lastBuildDate>
{{- end -}}
<atom:link href="{{.Permalink}}" rel="self" type="application/rss+xml" />
{{- range first 15 (where .Data.Pages "Type" "!=" "home") -}}
<atom:link href="{{ .Permalink }}" rel="self" type="application/rss+xml" />
{{- range where .Site.RegularPages "Type" "posts" | first (.Site.Params.home.rss | default 10) -}}
<item>
<title>
{{- .Title -}}
Expand All @@ -45,16 +45,18 @@
<pubDate>
{{- .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" -}}
</pubDate>
{{- with .Site.Author.email -}}
<author>
{{- . }}{{ with .Site.Author.name }} ({{ . }}){{ end -}}
</author>
{{- end -}}
<author>
{{- .Params.author | default $.Site.Author.name | default (T "author") -}}
</author>
<guid>
{{- .Permalink -}}
</guid>
<description>
{{- .Content | html -}}
{{- with .Summary -}}
{{- dict "content" . "ruby" true "fraction" true "fontawesome" true | partial "function/content.html" | plainify -}}
{{- else -}}
{{- .Description | plainify -}}
{{- end -}}
</description>
</item>
{{- end -}}
Expand Down
45 changes: 0 additions & 45 deletions layouts/index.atom.xml

This file was deleted.

2 changes: 1 addition & 1 deletion layouts/partials/plugin/link.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- $rel := "" -}}
<a href="{{ .href }}"{{ with .title }} title="{{ . }}"{{ end }}{{ if strings.HasPrefix .href "http" }}{{ $rel = "noopener noreffer" }} target="_blank"{{ end }} rel="{{ $rel }}{{ with .rel }} {{ . }}{{ end }}"{{ with .class }} class="{{ . }}"{{ end }}>
<a href="{{ .href }}"{{ with .title }} title="{{ . }}"{{ end }}{{ if (urls.Parse .href).Host | or .newtab }}{{ $rel = "noopener noreffer" }} target="_blank"{{ end }} rel="{{ $rel }}{{ with .rel }} {{ . }}{{ end }}"{{ with .class }} class="{{ . }}"{{ end }}>
{{- with .icon -}}
{{- partial "plugin/icon.html" . -}}
{{- end -}}
Expand Down
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" | or (strings.HasPrefix $src "//") | not -}}
{{- if (urls.Parse $src).Host | not -}}
{{- $res := resources.Get $src -}}
{{- with .template -}}
{{- $res = $res | resources.ExecuteAsTemplate . $.context -}}
Expand Down
7 changes: 7 additions & 0 deletions layouts/partials/plugin/social.html
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,13 @@
{{- partial "plugin/link.html" $options -}}
{{- end -}}

{{- /* 062: RSS */ -}}
{{- if .social.rss -}}
{{- $options := dict "href" (relLangURL "/index.xml") "title" "RSS" "newtab" true "rel" "me" -}}
{{- $options = dict "icon" (dict "class" "fas fa-rss fa-fw") | merge $options -}}
{{- partial "plugin/link.html" $options -}}
{{- end -}}

{{- /* Custom */ -}}
{{- with .social.Custom -}}
{{- . | safeHTML -}}
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/plugin/stylesheet.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{{- else -}}
{{- $href := .source -}}
{{- $integrity := .integrity -}}
{{- if strings.HasPrefix $href "http" | not -}}
{{- if (urls.Parse $href).Host | not -}}
{{- $res := resources.Get $href -}}
{{- with .template -}}
{{- $res = $res | resources.ExecuteAsTemplate . $.context -}}
Expand Down
Loading

0 comments on commit 07b669c

Please sign in to comment.