feat: add social link for RSS and some configs (#250)

This commit is contained in:
Dillon 2020-04-22 23:58:40 +08:00 committed by GitHub
parent f5fb31ec43
commit 07b669c826
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 199 additions and 67 deletions

View file

@ -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)

View file

@ -77,7 +77,7 @@
* 支持 **[Gravatar](https://gravatar.com)** 头像
* 支持本地**头像**
* 支持多达 **61** 种社交链接
* 支持多达 **62** 种社交链接
* 支持多达 **28** 种网站分享
* 支持 **[Disqus](https://disqus.com)** 评论系统
* 支持 **[Gitalk](https://github.com/gitalk/gitalk)** 评论系统

View file

@ -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
@ -190,6 +192,7 @@ enableEmoji = true
# XMPP = "xxxx"
# Matrix = "xxxx"
# Bilibili = "xxxx"
RSS = true
[languages.zh-cn]
weight = 2
@ -269,6 +272,8 @@ enableEmoji = true
searchKey = "b42948e51daaa93df92381c8e2ac0f93"
# 主页信息设置
[languages.zh-cn.params.home]
# RSS 文章数目
rss = 10
# 主页个人信息
[languages.zh-cn.params.home.profile]
enable = true
@ -355,6 +360,7 @@ enableEmoji = true
# XMPP = "xxxx@example.com"
# Matrix = "xxxx"
Bilibili = "xxxx"
RSS = true
[languages.fr]
weight = 3
@ -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
@ -520,6 +528,7 @@ enableEmoji = true
# XMPP = "xxxx"
# Matrix = "xxxx"
# Bilibili = "xxxx"
RSS = true
[params]
# LoveIt theme version
@ -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 (目录或标签) 页面配置
@ -593,6 +605,9 @@ enableEmoji = true
# date format (month and day)
# 日期格式 (月和日)
dateFormat = "01-02"
# amount of RSS pages
# RSS 文章数目
rss = 10
# Page config
# 文章页面配置
@ -903,6 +918,7 @@ enableEmoji = true
# 作者配置
[author]
name = "xxxx"
email = ""
link = ""
# Sitemap config

View file

@ -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)

View file

@ -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)

View file

@ -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)** 评论系统

View file

@ -244,6 +244,8 @@ 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]
@ -251,9 +253,13 @@ 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
# Home page config
[params.home]
# {{< version 0.2.0 >}} amount of RSS pages
rss = 10
# Home page profile
[params.home.profile]
enable = true
@ -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]
@ -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

View file

@ -249,6 +249,8 @@ 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]
@ -256,9 +258,13 @@ 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
# Home page config
[params.home]
# {{< version 0.2.0 >}} amount of RSS pages
rss = 10
# Home page profile
[params.home.profile]
enable = true
@ -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]
@ -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

View file

@ -247,6 +247,8 @@ hugo
paginate = 20
# 日期格式 (月和日)
dateFormat = "01-02"
# RSS 文章数目
rss = 10
# {{< version 0.2.0 >}} List (目录或标签) 页面配置
[params.list]
@ -254,9 +256,13 @@ hugo
paginate = 20
# 日期格式 (月和日)
dateFormat = "01-02"
# RSS 文章数目
rss = 10
# 主页配置
[params.home]
# {{< version 0.2.0 >}} RSS 文章数目
rss = 10
# 主页个人信息
[params.home.profile]
enable = true
@ -346,6 +352,7 @@ hugo
# XMPP = "xxxx"
# Matrix = "xxxx"
Bilibili = "xxxx"
RSS = true # {{< version 0.2.0 >}}
# {{< version 0.2.0 changed >}} 文章页面配置
[params.page]
@ -609,6 +616,7 @@ hugo
# 作者配置
[author]
name = "xxxx"
email = ""
link = ""
# 网站地图配置

View file

@ -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 -}}
@ -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 -}}
@ -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 -}}
@ -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 -}}

View file

@ -1,45 +0,0 @@
<feed xmlns="http://www.w3.org/2005/Atom">
{{- with .Title }}{{ . }} | {{ end }}{{ .Site.Title -}}
<link href="{{ .Permalink }}index.xml" rel="self"/>
<link href="{{ .Permalink }}"/>
{{- if not .Date.IsZero -}}
<updated>
{{- .Date.Format "02-01-2006T15:04:05-07:00" -}}
</updated>
{{- end -}}
<id>
{{- .Permalink -}}
</id>
<author>
{{- with .Site.Author.name -}}
<name>{{ . }}</name>
{{- end -}}
{{- with .Site.Author.email -}}
<email>{{ . }}</email>
{{- end -}}
</author>
<generator>Hugo -- gohugo.io</generator>
{{- range first 15 (where .Data.Pages "Type" "in" .Site.Params.mainSections) -}}
<entry>
<title type="html"><![CDATA[{{ .Title -}}]]></title>
<link href="{{ .Permalink }}"/>
<id>
{{- .Permalink -}}
</id>
{{- with .Site.Author.name -}}
<author>
<name>
{{- . -}}
</name>
</author>
{{- end -}}
<published>
{{- .Date.Format "2006-01-02T15:04:05-07:00" -}}
</published>
<updated>
{{- .Lastmod.Format "2006-01-02T15:04:05-07:00" -}}
</updated>
<content type="html"><![CDATA[{{- .Content -}}]]></content>
</entry>
{{- end -}}
</feed>

View file

@ -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 -}}

View file

@ -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 -}}

View file

@ -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 -}}

View file

@ -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 -}}

64
layouts/posts/rss.xml Normal file
View file

@ -0,0 +1,64 @@
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
<channel>
<title>
{{- T .Section | default .Section | printf (T "allSome") }} | {{ .Site.Title -}}
</title>
<link>
{{- .Permalink -}}
</link>
<description>
{{- T .Section | default .Section | printf (T "allSome") }} | {{ .Site.Title -}}
</description>
<generator>Hugo -- gohugo.io</generator>
{{- with .Site.LanguageCode -}}
<language>
{{- . -}}
</language>
{{- end -}}
{{- with .Site.Author.email -}}
<managingEditor>
{{- . }}{{ with $.Site.Author.name }} ({{ . }}){{ end -}}
</managingEditor>
<webMaster>
{{- . }}{{ with $.Site.Author.name }} ({{ . }}){{ end -}}
</webMaster>
{{- end -}}
{{- with .Site.Copyright -}}
<copyright>
{{- . -}}
</copyright>
{{- end -}}
{{- if not .Date.IsZero -}}
<lastBuildDate>
{{- .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" -}}
</lastBuildDate>
{{- end -}}
<atom:link href="{{ .Permalink }}" rel="self" type="application/rss+xml" />
{{- range .Pages | first (.Site.Params.section.rss | default 10) -}}
<item>
<title>
{{- .Title -}}
</title>
<link>
{{- .Permalink -}}
</link>
<pubDate>
{{- .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" -}}
</pubDate>
<author>
{{- .Params.author | default $.Site.Author.name | default (T "author") -}}
</author>
<guid>
{{- .Permalink -}}
</guid>
<description>
{{- with .Summary -}}
{{- dict "content" . "ruby" true "fraction" true "fontawesome" true | partial "function/content.html" | plainify -}}
{{- else -}}
{{- .Description | plainify -}}
{{- end -}}
</description>
</item>
{{- end -}}
</channel>
</rss>

View file

@ -34,7 +34,7 @@
{{- with .Get "list-max-height" }} list-max-height="{{ . }}"{{ end -}}
></meting-js>
{{- end -}}
{{- else if strings.HasSuffix (.Get 0) "http" -}}
{{- else if (.Get 0 | urls.Parse).Host -}}
<meting-js auto="{{ .Get 0 }}" theme="{{ $theme }}"></meting-js>
{{- else -}}
<meting-js server="{{ .Get 0 }}" type="{{ .Get 1 }}" id="{{ .Get 2 }}" theme="{{ $theme }}"></meting-js>

64
layouts/taxonomy/rss.xml Normal file
View file

@ -0,0 +1,64 @@
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
<channel>
<title>
{{- .Title }} | {{ T .Data.Singular | default (humanize .Data.Singular) }} | {{ .Site.Title -}}
</title>
<link>
{{- .Permalink -}}
</link>
<description>
{{- .Title }} | {{ T .Data.Singular | default (humanize .Data.Singular) }} | {{ .Site.Title -}}
</description>
<generator>Hugo -- gohugo.io</generator>
{{- with .Site.LanguageCode -}}
<language>
{{- . -}}
</language>
{{- end -}}
{{- with .Site.Author.email -}}
<managingEditor>
{{- . }}{{ with $.Site.Author.name }} ({{ . }}){{ end -}}
</managingEditor>
<webMaster>
{{- . }}{{ with $.Site.Author.name }} ({{ . }}){{ end -}}
</webMaster>
{{- end -}}
{{- with .Site.Copyright -}}
<copyright>
{{- . -}}
</copyright>
{{- end -}}
{{- if not .Date.IsZero -}}
<lastBuildDate>
{{- .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" -}}
</lastBuildDate>
{{- end -}}
<atom:link href="{{ .Permalink }}" rel="self" type="application/rss+xml" />
{{- range .Pages | first (.Site.Params.list.rss | default 10) -}}
<item>
<title>
{{- .Title -}}
</title>
<link>
{{- .Permalink -}}
</link>
<pubDate>
{{- .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" -}}
</pubDate>
<author>
{{- .Params.author | default $.Site.Author.name | default (T "author") -}}
</author>
<guid>
{{- .Permalink -}}
</guid>
<description>
{{- with .Summary -}}
{{- dict "content" . "ruby" true "fraction" true "fontawesome" true | partial "function/content.html" | plainify -}}
{{- else -}}
{{- .Description | plainify -}}
{{- end -}}
</description>
</item>
{{- end -}}
</channel>
</rss>