diff --git a/apps/test/assets/images/fixit-test.png b/apps/test/assets/images/fixit-test.png new file mode 100644 index 00000000..a11cef0a Binary files /dev/null and b/apps/test/assets/images/fixit-test.png differ diff --git a/apps/test/hugo.toml b/apps/test/hugo.toml index b80884a7..513eb716 100644 --- a/apps/test/hugo.toml +++ b/apps/test/hugo.toml @@ -37,6 +37,22 @@ _merge = "shallow" [params] version = "0.3.X" +[params.home.profile] +enable = true +avatarURL = "/images/fixit-test.png" + +[params.social] + +[params.social.github] +id = "hugo-fixit" +weight = 2 + +[params.social.twitter] +id = "lruihao" +weight = 1 +# for twitter cards +# site = "hugo-fixit" + [params.page] collectionList = true collectionNavigation = true diff --git a/assets/scss/pages/specials/_base.scss b/assets/scss/pages/specials/_base.scss new file mode 100644 index 00000000..3a8f18d2 --- /dev/null +++ b/assets/scss/pages/specials/_base.scss @@ -0,0 +1,6 @@ +.special { + .single-title, + .single-subtitle { + text-align: right; + } +} diff --git a/assets/scss/pages/specials/_friends.scss b/assets/scss/pages/specials/_friends.scss index 12ac7c76..3a9f65eb 100644 --- a/assets/scss/pages/specials/_friends.scss +++ b/assets/scss/pages/specials/_friends.scss @@ -1,7 +1,7 @@ // Style of layout friends @use "core/mixins" as *; -&.friends { +.special.friends { .friend-links { margin-top: 1rem; display: flex; diff --git a/assets/scss/pages/specials/_index.scss b/assets/scss/pages/specials/_index.scss index 72e62c17..ecaa59d8 100644 --- a/assets/scss/pages/specials/_index.scss +++ b/assets/scss/pages/specials/_index.scss @@ -1,11 +1,3 @@ -@use "sass:meta"; - -.special { - .single-title, - .single-subtitle { - text-align: right; - } - - @include meta.load-css('friends'); - @include meta.load-css('search'); -} +@use "base.scss"; +@use "friends.scss"; +@use "search.scss"; diff --git a/assets/scss/pages/specials/_search.scss b/assets/scss/pages/specials/_search.scss index 52c145dc..779ff10b 100644 --- a/assets/scss/pages/specials/_search.scss +++ b/assets/scss/pages/specials/_search.scss @@ -1,7 +1,7 @@ // Style of layout search @use "core/mixins" as *; -&.search { +.special.search { // Google CSE .gcse-searchbox:empty, .gcse-searchresults:empty { diff --git a/hugo.toml b/hugo.toml index 651022a2..b092b008 100644 --- a/hugo.toml +++ b/hugo.toml @@ -820,8 +820,8 @@ RSS = true # [params.social.twitter] # id = "lruihao" # weight = 3 -# prefix = "https://twitter.com/" -# Title = "Twitter" +# prefix = "https://x.com/" +# title = "X" # [params.social.twitter.icon] # class = "fa-brands fa-x-twitter" diff --git a/layouts/_partials/init/index.html b/layouts/_partials/init/index.html index 11298e99..628361a0 100644 --- a/layouts/_partials/init/index.html +++ b/layouts/_partials/init/index.html @@ -1,4 +1,4 @@ -{{- hugo.Store.Set "version" "v0.4.6-20260510194406-26b0556b" -}} +{{- hugo.Store.Set "version" "v0.4.6-20260511091232-04fb47c6" -}} {{- .Store.Set "this" dict -}} {{- partial "init/detection-env.html" . -}} diff --git a/layouts/_partials/layouts/head.html b/layouts/_partials/layouts/head/index.html similarity index 97% rename from layouts/_partials/layouts/head.html rename to layouts/_partials/layouts/head/index.html index 37365742..43520827 100644 --- a/layouts/_partials/layouts/head.html +++ b/layouts/_partials/layouts/head/index.html @@ -34,10 +34,7 @@ {{- template "_internal/schema.html" . -}} {{- template "_internal/opengraph.html" . -}} -{{- template "_internal/twitter_cards.html" . -}} -{{- with .Site.Params.social.Twitter -}} - -{{- end -}} +{{- partial "layouts/head/twitter-cards.html" . -}} @@ -59,8 +56,8 @@ {{- $id := "" -}} {{- $prefix := "https://mastodon.social/" -}} {{- if reflect.IsMap . -}} - {{- $id = .Id | default .id -}} - {{- $prefix = .Prefix | default .prefix | default $prefix -}} + {{- $id = .id -}} + {{- $prefix = .prefix | default $prefix -}} {{- end -}} {{- if $id | and $prefix -}} {{- $link := printf "%s/%s" $prefix $id -}} @@ -317,3 +314,6 @@ {{- $options = dict "sourceMap" "external" | merge $options -}} {{- end -}} {{- dict "Source" (resources.Get "js/head/color-scheme.js") "Build" $options "Fingerprint" $fingerprint | partial "plugin/script.html" -}} + +{{- /* Custom head */ -}} +{{- block "custom-head" . }}{{ end -}} diff --git a/layouts/_partials/layouts/head/twitter-cards.html b/layouts/_partials/layouts/head/twitter-cards.html new file mode 100644 index 00000000..bf28d879 --- /dev/null +++ b/layouts/_partials/layouts/head/twitter-cards.html @@ -0,0 +1,40 @@ +{{- /* + Extends Hugo's embedded twitter_cards partial: + https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_partials/twitter_cards.html + + Key differences: + - Generates twitter:site / twitter:creator from site params (.Site.Params.social.twitter) + - The param can be a string or a map; when it's a map, reads Id/id +*/ -}} +{{- $images := partial "_funcs/get-page-images" . }} +{{- with index $images 0 }} + + +{{- else }} + +{{- end }} + +{{- with or .Title site.Title site.Params.title | plainify }} + +{{- end }} + +{{- with or .Description .Summary site.Params.description | plainify | htmlUnescape }} + +{{- end }} + +{{- with site.Params.social.twitter -}} + {{- $site := "" -}} + {{- $creator := "" -}} + {{- if reflect.IsMap . -}} + {{- $creator = .creator | default .id -}} + {{- $site = .site | default $creator -}} + {{- else -}} + {{- $creator = . -}} + {{- end -}} + {{- with $site -}} + + {{- end -}} + {{- with $creator -}} + + {{- end -}} +{{- end -}} diff --git a/layouts/_partials/plugin/share.html b/layouts/_partials/plugin/share.html index b7f20fd5..ddca9cdd 100644 --- a/layouts/_partials/plugin/share.html +++ b/layouts/_partials/plugin/share.html @@ -9,9 +9,17 @@ {{- if $share.enable -}} {{- $title := cond (.Param "capitalizeTitles") (title .Title) .Title -}} + {{- $twitterVia := "" -}} + {{- with .Site.Params.social.twitter -}} + {{- if reflect.IsMap . -}} + {{- $twitterVia = .creator | default .id -}} + {{- else -}} + {{- $twitterVia = . -}} + {{- end -}} + {{- end -}} {{- /* 001: Twitter */ -}} {{- if $share.Twitter -}} - + {{- dict "Class" "fa-brands fa-x-twitter" | partial "plugin/icon.html" -}} {{ end -}} @@ -81,7 +89,7 @@ {{- /* 011: Buffer */ -}} {{- if $share.Buffer -}} - + {{- dict "Class" "fa-brands fa-buffer" | partial "plugin/icon.html" -}} {{ end -}} diff --git a/layouts/baseof.html b/layouts/baseof.html index 7f6a2bdf..28b5760b 100644 --- a/layouts/baseof.html +++ b/layouts/baseof.html @@ -10,11 +10,8 @@