Skip to content

Commit

Permalink
Perf: 代码优化
Browse files Browse the repository at this point in the history
  • Loading branch information
Lruihao committed Oct 6, 2024
1 parent 0b4ee31 commit a4d4061
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ Create `_content.gotmpl` in projects section folder, add the following code:
{{- partial "adapters/projects.html" . -}}
```

Directory structure:

```plain
content/
├── projects/
Expand Down
2 changes: 2 additions & 0 deletions README.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ Some text to display at the start of the page.
{{- partial "adapters/projects.html" . -}}
```

目录结构如下:

```plain
content/
├── projects/
Expand Down
15 changes: 8 additions & 7 deletions layouts/partials/adapters/projects.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,18 @@
* @author Lruihao (https://lruihao.cn)
*/ -}}

{{- $auth := dict "Authorization" "" -}}
{{- with (getenv "HUGO_PARAMS_GHTOKEN") -}}
{{- $auth = dict "Authorization" (printf "token %v" .) -}}
{{- end -}}
{{- $headers := dict "headers" $auth -}}
{{- $projectsAdapters := .Site.Params.projectsAdapters -}}
{{- $data := index .Site.Data (printf "projects.%v" .Site.Language.Lang) | default .Site.Data.projects -}}
{{- $renderedRepos := slice -}}

{{- if $projectsAdapters.enable -}}
{{- warnf "component-projects\n%v" (T "projects.warningAdapter") -}}
{{- $data := index .Site.Data (printf "projects.%v" .Site.Language.Lang) | default .Site.Data.projects -}}
{{- $renderedRepos := slice -}}
{{- $auth := dict "Authorization" "" -}}
{{- with (getenv "HUGO_PARAMS_GHTOKEN") -}}
{{- $auth = dict "Authorization" (printf "token %v" .) -}}
{{- end -}}
{{- $headers := dict "headers" $auth -}}

{{- /* Loop through the data and create a post for each repo */ -}}
{{- range $group := $data -}}
{{- if eq $group.contentAdapters false -}}
Expand Down

0 comments on commit a4d4061

Please sign in to comment.