Skip to content

Commit

Permalink
Feat: 支持按分组设置文章分类和合集
Browse files Browse the repository at this point in the history
  • Loading branch information
Lruihao committed Oct 2, 2024
1 parent c9298c9 commit b994f3b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ content/
│ ├── _content.gotmpl <-- content adapter
│ └── _index.md
data/
└── projects.yml <-- project data
└── projects.yml <-- projects data
```

Then, open the `hugo.toml` file and configure the `projectsAdapters` option to enable the content adapter:
Expand Down
2 changes: 1 addition & 1 deletion README.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ content/
│ ├── _content.gotmpl <-- content adapter
│ └── _index.md
data/
└── projects.yml <-- project data
└── projects.yml <-- projects data
```

然后,打开 `hugo.toml` 文件,配置的 `projectsAdapters` 选项,启用内容适配器:
Expand Down
8 changes: 5 additions & 3 deletions _content.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,13 @@
"link" $repoInfo.owner.html_url
"avatar" $repoInfo.owner.avatar_url
-}}
{{- $categories := $group.categories | default $projectsAdapters.categories -}}
{{- $collections := $group.collections | default $projectsAdapters.collections -}}
{{- $params := dict
"fromAdapters" "projects"
"author" $author
"categories" $projectsAdapters.categories
"collections" $projectsAdapters.collections
"categories" $categories
"collections" $collections
"tags" $repoInfo.topics
"lightgallery" true
"capitalizeTitles" false
Expand All @@ -78,7 +80,7 @@
{{- /* Convert relative links to absolute links in the README content */ -}}
{{- $replacement := printf "$1[$2](%v$4)" (printf "https://raw.githubusercontent.com/%v/refs/heads/%v/$3" $repoInfo.full_name $repoInfo.default_branch) -}}
{{- /* Oops! Lookahead regular lookup is not supported in Golang, e.g `(?!http)` */ -}}
{{- $markdown = replaceRE `([!]?)\[(.*?)\]\((/.*).*?(\s+".*?")?\)` $replacement $markdown -}}
{{- $markdown = replaceRE `([!]?)\[(.*?)\]\(([/|\./].*).*?(\s+".*?")?\)` $replacement $markdown -}}
{{- $content := dict
"mediaType" "text/markdown"
"value" $markdown
Expand Down
8 changes: 8 additions & 0 deletions projects.yml.example
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
- title: My developed
description: Below are some open source works I have developed.
contentAdapters: false
categories:
- foo
collections:
- developed
totalStars: false # whether to count total stars
repos:
- hugo-fixit/FixIt
- title: My contributed
description: Below are some open source works I have contributed to.
contentAdapters: false
categories:
- bar
collections:
- contributed
totalStars: false
repos:
- gohugoio/hugo

0 comments on commit b994f3b

Please sign in to comment.