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 a5af407 commit 2a67ddd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# component-projects

👉 English README | [简体中文说明](README.zh-cn.md)
👉 English README | [简体中文说明](/README.zh-cn.md)

A Hugo theme component with layout `projects` and shortcodes to display GitHub pinned card style repositories.

Expand Down
2 changes: 1 addition & 1 deletion README.zh-cn.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# component-projects

👉 [English README](README.md) | 简体中文说明
👉 [English README](/README.md) | 简体中文说明

一个包含有 `projects` 布局和 shortcode 的 Hugo 主题组件,用于显示 GitHub 固定卡片样式存储库。

Expand Down
14 changes: 10 additions & 4 deletions _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

0 comments on commit 2a67ddd

Please sign in to comment.