diff --git a/README.md b/README.md index ca4fd5d..43deddb 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/README.zh-cn.md b/README.zh-cn.md index 99c61f7..a77b907 100644 --- a/README.zh-cn.md +++ b/README.zh-cn.md @@ -129,7 +129,7 @@ content/ │ ├── _content.gotmpl <-- content adapter │ └── _index.md data/ -└── projects.yml <-- project data +└── projects.yml <-- projects data ``` 然后,打开 `hugo.toml` 文件,配置的 `projectsAdapters` 选项,启用内容适配器: diff --git a/_content.gotmpl b/_content.gotmpl index 2e178bf..5bb58e2 100644 --- a/_content.gotmpl +++ b/_content.gotmpl @@ -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 @@ -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 diff --git a/projects.yml.example b/projects.yml.example index 66db8e3..a8ac4b6 100644 --- a/projects.yml.example +++ b/projects.yml.example @@ -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