Skip to content

Commit

Permalink
Feat: 使用仓库拥有者当作文章作者
Browse files Browse the repository at this point in the history
  • Loading branch information
Lruihao committed Oct 1, 2024
1 parent c8e7cdb commit b594a39
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 16 deletions.
3 changes: 2 additions & 1 deletion config/_default/hugo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ hasCJKLanguage = false

# default amount of posts in each pages
# 默认每页列表显示的文章数目
paginate = 12
# TODO deprecated: site config key paginate was deprecated in Hugo v0.128.0 and will be removed in a future release. Use pagination.pagerSize instead.
# paginate = 12
# copyright description used only for seo schema
# 版权描述,仅仅用于 SEO
copyright = ""
Expand Down
2 changes: 1 addition & 1 deletion config/_default/params.toml
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ disableThemeInject = false
enable = true
# Gravatar host, default: "www.gravatar.com"
# Gravatar 主机,默认:“www.gravatar.com”
host = "gravatar.lruihao.cn" # ["cravatar.cn", "gravatar.loli.net", ...]
host = "gravatar.loli.net" # ["cravatar.cn", "gravatar.loli.net", ...]
style = "mp" # ["", "mp", "identicon", "monsterid", "wavatar", "retro", "blank", "robohash"]

# Back to top
Expand Down
14 changes: 10 additions & 4 deletions content/en/components/_content.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
{{- end -}}
{{- $projectsAdapters.ignoreList -}}
{{- $repoAPI := printf "https://api.github.com/repos/%v" $repo -}}
{{- $repoInfo := partial "function/get-remote-json" (dict "URL" $repoAPI "OPTIONS" $headers ) -}}
{{- $repoInfo := partial "function/get-remote-json" (dict "URL" $repoAPI "OPTIONS" $headers) -}}
{{- $readmeAPI := printf "https://api.github.com/repos/%v/contents/README.%v.md" $repo $.Site.Language.Lang -}}
{{- $readme := partial "function/get-remote-json" (dict "URL" $readmeAPI "OPTIONS" $headers ) -}}
{{- $readme := partial "function/get-remote-json" (dict "URL" $readmeAPI "OPTIONS" $headers) -}}

{{- /* Get the default README if the multi-language README is not available */ -}}
{{- if not $readme -}}
{{- $readmeAPI = printf "https://api.github.com/repos/%v/readme" $repo -}}
{{- $readme = partial "function/get-remote-json" (dict "URL" $readmeAPI "OPTIONS" $headers ) -}}
{{- $readme = partial "function/get-remote-json" (dict "URL" $readmeAPI "OPTIONS" $headers) -}}
{{- end -}}

{{- /* Skip if the repo info or README is not available */ -}}
Expand All @@ -52,13 +52,19 @@
"lastmod" (time.AsTime $repoInfo.updated_at)
-}}
{{- /* Post params from repo info (equivalent to the front matter of posts) */ -}}
{{- $author := dict
"name" $repoInfo.owner.login
"link" $repoInfo.owner.html_url
"avatar" $repoInfo.owner.avatar_url
-}}
{{- $params := dict
"fromAdapters" "projects"
"author" $author
"categories" $projectsAdapters.categories
"collections" $projectsAdapters.collections
"tags" $repoInfo.topics
"lightgallery" true
"breadcrumb" (dict "capitalize" false)
"capitalizeTitles" false
"toc" (dict "ordered" false)
"subtitle" ($repoInfo.homepage | default $repoInfo.html_url)
"sourceURL" (add $readme.html_url "?plain=1")
Expand Down
14 changes: 10 additions & 4 deletions content/zh-cn/components/_content.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
{{- end -}}
{{- $projectsAdapters.ignoreList -}}
{{- $repoAPI := printf "https://api.github.com/repos/%v" $repo -}}
{{- $repoInfo := partial "function/get-remote-json" (dict "URL" $repoAPI "OPTIONS" $headers ) -}}
{{- $repoInfo := partial "function/get-remote-json" (dict "URL" $repoAPI "OPTIONS" $headers) -}}
{{- $readmeAPI := printf "https://api.github.com/repos/%v/contents/README.%v.md" $repo $.Site.Language.Lang -}}
{{- $readme := partial "function/get-remote-json" (dict "URL" $readmeAPI "OPTIONS" $headers ) -}}
{{- $readme := partial "function/get-remote-json" (dict "URL" $readmeAPI "OPTIONS" $headers) -}}

{{- /* Get the default README if the multi-language README is not available */ -}}
{{- if not $readme -}}
{{- $readmeAPI = printf "https://api.github.com/repos/%v/readme" $repo -}}
{{- $readme = partial "function/get-remote-json" (dict "URL" $readmeAPI "OPTIONS" $headers ) -}}
{{- $readme = partial "function/get-remote-json" (dict "URL" $readmeAPI "OPTIONS" $headers) -}}
{{- end -}}

{{- /* Skip if the repo info or README is not available */ -}}
Expand All @@ -52,13 +52,19 @@
"lastmod" (time.AsTime $repoInfo.updated_at)
-}}
{{- /* Post params from repo info (equivalent to the front matter of posts) */ -}}
{{- $author := dict
"name" $repoInfo.owner.login
"link" $repoInfo.owner.html_url
"avatar" $repoInfo.owner.avatar_url
-}}
{{- $params := dict
"fromAdapters" "projects"
"author" $author
"categories" $projectsAdapters.categories
"collections" $projectsAdapters.collections
"tags" $repoInfo.topics
"lightgallery" true
"breadcrumb" (dict "capitalize" false)
"capitalizeTitles" false
"toc" (dict "ordered" false)
"subtitle" ($repoInfo.homepage | default $repoInfo.html_url)
"sourceURL" (add $readme.html_url "?plain=1")
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/hugo-fixit/docs
go 1.20

require (
github.com/hugo-fixit/FixIt v0.3.13-0.20241001115042-e9edbba217d9 // indirect
github.com/hugo-fixit/component-projects v1.2.0 // indirect
github.com/hugo-fixit/FixIt v0.3.13-0.20241001175419-9c440df3d081 // indirect
github.com/hugo-fixit/component-projects v1.2.2 // indirect
github.com/hugo-fixit/shortcode-caniuse v1.1.3 // indirect
github.com/hugo-fixit/shortcode-rewards v1.0.4 // indirect
)
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
github.com/hugo-fixit/FixIt v0.3.13-0.20241001115042-e9edbba217d9 h1:0TXHvCynxnJRIaAnJ5oIcj0AHxKLQ3+WlSjNSsJkejc=
github.com/hugo-fixit/FixIt v0.3.13-0.20241001115042-e9edbba217d9/go.mod h1:3XIRedrqakO7/a4ZnhE46haMRF8HgsT0N0B5j5D2iRU=
github.com/hugo-fixit/component-projects v1.2.0 h1:CxAjX/tUsgbn9NivUnDqE4ocbawKGh8Bmb4PnTHMEjw=
github.com/hugo-fixit/component-projects v1.2.0/go.mod h1:nXW0R37REwpfwUD1I4RtB5QW71vw66nRyB9uEpYxr+c=
github.com/hugo-fixit/FixIt v0.3.13-0.20241001175419-9c440df3d081 h1:6DHB2n0WzNe+wa8ZbnS0aUb2+C5MS2ZKzJPKjDjYIAc=
github.com/hugo-fixit/FixIt v0.3.13-0.20241001175419-9c440df3d081/go.mod h1:3XIRedrqakO7/a4ZnhE46haMRF8HgsT0N0B5j5D2iRU=
github.com/hugo-fixit/component-projects v1.2.2 h1:s6Mm48B3N/qiM2mxLFeRKlrMSzK3mWh7Fw0r+8Q+a04=
github.com/hugo-fixit/component-projects v1.2.2/go.mod h1:nXW0R37REwpfwUD1I4RtB5QW71vw66nRyB9uEpYxr+c=
github.com/hugo-fixit/shortcode-caniuse v1.1.3 h1:U1YBJz5SI/d1BBQhHcD0eVgJdCcpzK2usSizPiu+a4w=
github.com/hugo-fixit/shortcode-caniuse v1.1.3/go.mod h1:RoPLFt+7uLui5rjvkC/qFGeo4nly5AzzwIID9SoDKNc=
github.com/hugo-fixit/shortcode-rewards v1.0.4 h1:62qCmcGvAJf+qa+8ofRX6jwMUXo6Q4+PQvlOtu0ZGBA=
Expand Down

0 comments on commit b594a39

Please sign in to comment.