diff --git a/README.md b/README.md index 59d39b7..f9aed71 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ A Hugo theme component with layout `projects` and shortcodes to display GitHub p ## Requirements -- [FixIt](https://github.com/hugo-fixit) v0.3.5 or higher +- [FixIt](https://github.com/hugo-fixit) v0.3.7 or higher ## Installation @@ -30,6 +30,14 @@ Next edit `hugo.toml` of your project and add this theme component to your theme theme = ["FixIt", "component-projects"] ``` +Finally, inject the theme component's assets in `layouts/partials/custom.html` within the `custom-head` or `custom-assets` block: + +```go-html-template +{{- define "custom-assets" -}} + {{- partial "inject/component-projects.html" . -}} +{{- end -}} +``` + To learn about theme components of hugo and how to use them, check out . ## Configuration diff --git a/README.zh-cn.md b/README.zh-cn.md index c3cd4e4..6075a6b 100644 --- a/README.zh-cn.md +++ b/README.zh-cn.md @@ -13,7 +13,7 @@ ## 要求 -- [FixIt](https://github.com/hugo-fixit) v0.3.5 或更高版本 +- [FixIt](https://github.com/hugo-fixit) v0.3.7 或更高版本 ## 安装 @@ -30,6 +30,14 @@ git submodule add https://github.com/hugo-fixit/component-projects.git themes/co theme = ["FixIt", "component-projects"] ``` +最后,在 `layouts/partials/custom.html` 中的 `custom-head` 或 `custom-assets` 块内注入主题组件的样式: + +```go-html-template +{{- define "custom-assets" -}} + {{- partial "inject/component-projects.html" . -}} +{{- end -}} +``` + 要了解 Hugo 的主题组件以及如何使用它们,请查看 。 ## 配置 diff --git a/assets/css/component-projects/repo-card.scss b/assets/css/component-projects/repo-card.scss index 3ae9f7a..40895fc 100644 --- a/assets/css/component-projects/repo-card.scss +++ b/assets/css/component-projects/repo-card.scss @@ -37,6 +37,10 @@ border-style: solid; border-width: var(--bw-gh-repo-card); + &.single:only-child { + margin: auto; + } + svg { display: inline-block; overflow: visible !important; diff --git a/layouts/partials/inject/component-projects.html b/layouts/partials/inject/component-projects.html new file mode 100644 index 0000000..926ee9d --- /dev/null +++ b/layouts/partials/inject/component-projects.html @@ -0,0 +1,8 @@ +{{- /* repo-card.min.css */ -}} +{{- if (.HasShortcode "gh-repo-card") | and (ne .Layout "projects") -}} + {{- $fingerprint := .Scratch.Get "fingerprint" -}} + {{- $options := dict "Source" "css/component-projects/repo-card.scss" "Fingerprint" $fingerprint -}} + {{- $toCSS := dict "targetPath" "css/repo-card.min.css" "enableSourceMap" true -}} + {{- $options = dict "Context" . "ToCSS" $toCSS | merge $options -}} + {{- partial "plugin/style.html" $options -}} +{{- end -}} diff --git a/layouts/partials/plugin/gh-repo-card.html b/layouts/partials/plugin/gh-repo-card.html index e39c493..ebfa47e 100644 --- a/layouts/partials/plugin/gh-repo-card.html +++ b/layouts/partials/plugin/gh-repo-card.html @@ -43,4 +43,5 @@ {{- end -}}

- \ No newline at end of file + +{{- /* EOF */ -}} diff --git a/layouts/shortcodes/gh-repo-card-container.html b/layouts/shortcodes/gh-repo-card-container.html index 869eec3..1d77d4d 100644 --- a/layouts/shortcodes/gh-repo-card-container.html +++ b/layouts/shortcodes/gh-repo-card-container.html @@ -1 +1 @@ -
{{- .Inner -}}
\ No newline at end of file +
{{- .Inner -}}
\ No newline at end of file diff --git a/layouts/shortcodes/gh-repo-card.html b/layouts/shortcodes/gh-repo-card.html index 890a6ad..a7a33d8 100644 --- a/layouts/shortcodes/gh-repo-card.html +++ b/layouts/shortcodes/gh-repo-card.html @@ -16,13 +16,4 @@ {{- erroridf "error-get-gh-repo" "gh-repo-card shortcode: failed to fetch repo info from GitHub API" -}} {{- end -}} -{{- if eq .Ordinal 0 -}} - {{- /* repo-card.min.css */ -}} - {{- $fingerprint := .Scratch.Get "fingerprint" -}} - {{- $options := dict "Source" "css/component-projects/repo-card.scss" "Fingerprint" $fingerprint -}} - {{- $toCSS := dict "targetPath" "css/repo-card.min.css" "enableSourceMap" true -}} - {{- $options = dict "Context" . "ToCSS" $toCSS | merge $options -}} - {{- partial "plugin/style.html" $options -}} -{{- end -}} - {{- dict "RepoInfo" $repoInfo "GithubLangColors" $githubLangColors | partial "plugin/gh-repo-card.html" -}}