Skip to content

Commit

Permalink
Merge pull request #372 from paskal/author-param
Browse files Browse the repository at this point in the history
  • Loading branch information
xianmin authored Jan 5, 2024
2 parents cf15722 + 4ddfbc3 commit 05c77cd
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 30 deletions.
13 changes: 6 additions & 7 deletions dev-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ paginate = 5 # 首页每页显示
rssLimit = 20 # Limit Entry Count to Rss file # 限制 Rss 文章输出数量
disqusShortname = "xianmin12" # disqus_shortname
googleAnalytics = "G-4SFSR6JRVT" # G-********
copyright = "" # default: author.name ↓ # 默认为下面配置的author.name ↓
copyright = "" # default: params.author.name ↓ # 默认为下面配置的params.author.name ↓
enableGitInfo = true # use git commit log to generate lastmod record # 可根据 Git 中的提交生成最近更新记录。
# uglyURLs = true

# language support en / zh-cn / other... translations present in i18n/
defaultContentLanguage = "en" # Default language to use (if you setup multilingual support)
[langusges]
[languages]
[languages.en]
title = "Jane - A simple theme for Hugo"
languageName = "English"
Expand Down Expand Up @@ -99,11 +99,6 @@ defaultContentLanguage = "en" # Default language to use (if you setup multiling
weight = 50
url = "https://gohugo.io"


[author]
name = "Jane" # essential # 必需
url = "/about" # optional # 可选

[sitemap] # essential # 必需
changefreq = "weekly"
priority = 0.5
Expand All @@ -116,6 +111,10 @@ defaultContentLanguage = "en" # Default language to use (if you setup multiling
homeFullContent = false # if false, show post summaries on home page. Otherwise show full content.
rssFullContent = true # if false, Rss feed instead of the summary

[params.author]
name = "Jane" # essential # 必需
url = "/about" # optional # 可选

# site info (optional) # 站点信息(可选,不需要的可以直接注释掉)
logoTitle = "Jane" # default: the title value # 默认值: 上面设置的title值
keywords = ["Hugo", "theme","jane"]
Expand Down
11 changes: 6 additions & 5 deletions exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,13 @@ paginate = 3 # Number of articles displayed on the homepage # 首
rssLimit = 20 # Limit Entry Count to Rss file # 限制 Rss 文章输出数量
disqusShortname = "" # disqus_shortname
googleAnalytics = "" # UA-XXXXXXXX-X
copyright = "" # default: author.name ↓ # 默认为下面配置的author.name ↓
copyright = "" # default: params.author.name ↓ # 默认为下面配置的params.author.name ↓

# language support # en / zh-cn / other... translations present in i18n/
defaultContentLanguage = "en" # Default language to use
[languages.en]
languageCode = "en"

[author]
name = "xianmin" # essential # 必需
url = "/about" # optional # 可选

[sitemap] # essential # 必需
changefreq = "weekly"
priority = 0.5
Expand Down Expand Up @@ -60,6 +56,11 @@ defaultContentLanguage = "en" # Default language to use
homeFullContent = false # if false, show post summaries on home page. Otherwise show full content.
rssFullContent = true # if false, Rss feed instead of the summary

[params.author]
name = "xianmin" # essential # 必需
email = "me@example.com" # optional, for RSS # 可选
url = "/about" # optional # 可选

# site info (optional) # 站点信息(可选,不需要的可以直接注释掉)
logoTitle = "Jane" # default: the title value # 默认值: 上面设置的title值
keywords = ["Hugo", "theme","jane"]
Expand Down
11 changes: 6 additions & 5 deletions exampleSite/full-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ paginate = 3 # Number of articles displayed on the homepage # 首
rssLimit = 20 # Limit Entry Count to Rss file # 限制 Rss 文章输出数量
disqusShortname = "" # disqus_shortname
googleAnalytics = "" # UA-XXXXXXXX-X
copyright = "" # default: author.name ↓ # 默认为下面配置的author.name ↓
copyright = "" # default: params.author.name ↓ # 默认为下面配置的params.author.name ↓
enableGitInfo = true # use git commit log to generate lastmod record # 可根据 Git 中的提交生成最近更新记录。
# uglyURLs = true # more info: https://gohugo.io/content-management/urls/#ugly-urls

Expand All @@ -24,10 +24,6 @@ defaultContentLanguage = "en" # Default language to use
[languages.en]
languageCode = "en"

[author]
name = "xianmin" # essential # 必需
url = "/about" # optional # 可选

[sitemap] # essential # 必需
changefreq = "weekly"
priority = 0.5
Expand Down Expand Up @@ -66,6 +62,11 @@ defaultContentLanguage = "en" # Default language to use
rssFullContent = true # if false, Rss feed instead of the summary
mainSections = ["post"]

[params.author]
name = "xianmin" # essential # 必需
email = "me@example.com" # optional, for RSS # 可选
url = "/about" # optional # 可选

# site info (optional) # 站点信息(可选,不需要的可以直接注释掉)
logoTitle = "Jane" # default: the title value # 默认值: 上面设置的title值
keywords = ["Hugo", "theme","jane"]
Expand Down
4 changes: 2 additions & 2 deletions layouts/_default/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ <h1 class="post-title">{{ .Title }}</h1>
</article>

<!-- Author Info -->
{{ if and (.Params.author | default .Site.Author.name) (.Params.showAuthorInfo | default .Site.Params.showAuthorInfo) }}
{{ partial "author_info.html" (dict "author" (.Params.author | default .Site.Author.name) "context" $) }}
{{ if and (.Site.Params.author.name | default .Site.Author.name) (.Params.showAuthorInfo | default .Site.Params.showAuthorInfo) }}
{{ partial "author_info.html" (dict "author" (.Site.Params.author.name | default .Site.Author.name) "context" $) }}
{{ end }}


Expand Down
4 changes: 2 additions & 2 deletions layouts/partials/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
{{ partial "svg/heart.svg" }}
</i>
</span>
{{- if or .Site.Copyright .Site.Author.name -}}
{{- if or .Site.Copyright (or .Site.Params.author.name .Site.Author.name) -}}
<span class="author">
{{if .Site.Copyright }}{{ .Site.Copyright | safeHTML }}
{{ else }}{{ .Site.Author.name | safeHTML }}
{{ else }}{{ or .Site.Params.author.name .Site.Author.name | safeHTML }}
{{ end }}
</span>
{{- end -}}
Expand Down
4 changes: 2 additions & 2 deletions layouts/partials/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
<meta name="mobile-web-app-capable" content="yes">

<!-- author & description & keywords -->
{{- if or .Params.author .Site.Author.name -}}
{{- $author_id := .Params.author | default .Site.Author.name -}}
{{- if or .Site.Params.author.name .Site.Author.name -}}
{{- $author_id := .Site.Params.author.name | default .Site.Author.name -}}
{{- $author := (index ($.Site.Data.authors | default dict) $author_id) -}}
{{- $author_lang := (index ($author | default dict) .Site.Language.Lang) -}}
{{- $author_name := $author_lang.name.display | default $author.name.display | default $author_id -}}
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/post/copyright.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<p class="copyright-item">
<span class="item-title">{{ i18n "author" }}</span>
<span class="item-content">
{{- $author_id := .Params.author | default .Site.Author.name -}}
{{- $author_id := .Site.Params.author.name | default .Site.Author.name -}}
{{- $author := (index ($.Site.Data.authors | default dict) $author_id) -}}
{{- $author_lang := (index ($author | default dict) .Site.Language.Lang) -}}
{{- $author_name := $author_lang.name.display | default $author.name.display | default $author_id -}}
Expand Down
8 changes: 6 additions & 2 deletions layouts/partials/post/meta.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
{{- /* Deprecate Params.author in favor of Params.author.name */}}
{{- if not (reflect.IsMap .Site.Params.author) -}}
{{- warnf "The author key in site configuration is deprecated. Use params.author.name instead." }}
{{- end -}}
<div class="post-meta">
<div class="post-meta-author">
by
{{- $author_id := .Params.author | default .Site.Author.name -}}
{{- $author_id := .Site.Params.author.name | default .Site.Author.name -}}
{{- $author := (index ($.Site.Data.authors | default dict) $author_id) -}}
{{- $author_lang := (index ($author | default dict) .Site.Language.Lang) -}}
{{- $author_name := $author_lang.name.display | default $author.name.display | default $author_id -}}
{{- $author_url := $author_lang.url | default $author.url | default .Site.Author.url -}}
{{- $author_url := $author_lang.url | default $author.url | default .Site.Params.author.url | default .Site.Author.url -}}
{{ if $author_url }}
<a href="{{ $author_url | relLangURL | safeURL }}">
<span class="post-meta-author-name">
Expand Down
8 changes: 4 additions & 4 deletions layouts/rss.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
<link>{{ .Permalink }}</link>
<description>Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ .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>{{end}}{{ with .Site.Author.email }}
<webMaster>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</webMaster>{{end}}{{ with .Site.Copyright }}
<language>{{.}}</language>{{end}}{{ with default .Site.Author.email .Site.Params.author.email }}
<managingEditor>{{.}}{{ with default $.Site.Author.name $.Site.Params.author.name }} ({{.}}){{end}}</managingEditor>{{end}}{{ with default .Site.Author.email .Site.Params.author.email }}
<webMaster>{{.}}{{ with default $.Site.Author.name $.Site.Params.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" | safeHTML }}</lastBuildDate>{{ end }}
{{ with .OutputFormats.Get "RSS" }}
Expand All @@ -25,7 +25,7 @@
<title>{{ .Title }}</title>
<link>{{ .Permalink }}</link>
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
{{ with .Site.Author.email }}<author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author>{{end}}
{{ with default .Site.Author.email .Site.Params.author.email }}<author>{{.}}{{ with default $.Site.Author.name $.Site.Params.author.name }} ({{.}}){{end}}</author>{{end}}
<guid>{{ .Permalink }}</guid>
{{ if .Site.Params.rssFullContent }}
<description>{{ .Content | html }}</description>
Expand Down

0 comments on commit 05c77cd

Please sign in to comment.