From 1da07b0b4a337342cc48627d9af78e7fd20a45cf Mon Sep 17 00:00:00 2001 From: Yuqian Yang Date: Sat, 14 Jun 2025 22:49:26 +0800 Subject: www: move layout files for new version of hugo and fix nested shortcodes. --- www/layouts/_default/baseof.html | 49 ------------------- www/layouts/_default/list.html | 17 ------- www/layouts/_default/single.html | 23 --------- www/layouts/_partials/css-res.html | 9 ++++ www/layouts/_partials/css.html | 1 + www/layouts/_partials/date.html | 1 + www/layouts/_partials/highlight.html | 6 +++ www/layouts/_partials/js.html | 11 +++++ www/layouts/_partials/nav.html | 6 +++ www/layouts/_partials/preview/article.html | 10 ++++ www/layouts/_partials/preview/post.html | 7 +++ www/layouts/_partials/preview/posts.html | 7 +++ www/layouts/_shortcodes/link-group.html | 25 ++++++++++ www/layouts/baseof.html | 49 +++++++++++++++++++ www/layouts/home.html | 78 ++++++++++++++++++++++++++++++ www/layouts/index.html | 78 ------------------------------ www/layouts/list.html | 13 +++++ www/layouts/partials/css-res.html | 9 ---- www/layouts/partials/css.html | 1 - www/layouts/partials/date.html | 1 - www/layouts/partials/highlight.html | 6 --- www/layouts/partials/js.html | 11 ----- www/layouts/partials/nav.html | 6 --- www/layouts/partials/preview/article.html | 10 ---- www/layouts/partials/preview/post.html | 7 --- www/layouts/partials/preview/posts.html | 7 --- www/layouts/shortcodes/link-group.html | 25 ---------- www/layouts/shortcodes/mono.html | 3 -- www/layouts/shortcodes/todo.html | 5 -- www/layouts/single.html | 23 +++++++++ 30 files changed, 246 insertions(+), 258 deletions(-) delete mode 100644 www/layouts/_default/baseof.html delete mode 100644 www/layouts/_default/list.html delete mode 100644 www/layouts/_default/single.html create mode 100644 www/layouts/_partials/css-res.html create mode 100644 www/layouts/_partials/css.html create mode 100644 www/layouts/_partials/date.html create mode 100644 www/layouts/_partials/highlight.html create mode 100644 www/layouts/_partials/js.html create mode 100644 www/layouts/_partials/nav.html create mode 100644 www/layouts/_partials/preview/article.html create mode 100644 www/layouts/_partials/preview/post.html create mode 100644 www/layouts/_partials/preview/posts.html create mode 100644 www/layouts/_shortcodes/link-group.html create mode 100644 www/layouts/baseof.html create mode 100644 www/layouts/home.html delete mode 100644 www/layouts/index.html create mode 100644 www/layouts/list.html delete mode 100644 www/layouts/partials/css-res.html delete mode 100644 www/layouts/partials/css.html delete mode 100644 www/layouts/partials/date.html delete mode 100644 www/layouts/partials/highlight.html delete mode 100644 www/layouts/partials/js.html delete mode 100644 www/layouts/partials/nav.html delete mode 100644 www/layouts/partials/preview/article.html delete mode 100644 www/layouts/partials/preview/post.html delete mode 100644 www/layouts/partials/preview/posts.html delete mode 100644 www/layouts/shortcodes/link-group.html delete mode 100644 www/layouts/shortcodes/mono.html delete mode 100644 www/layouts/shortcodes/todo.html create mode 100644 www/layouts/single.html (limited to 'www/layouts') diff --git a/www/layouts/_default/baseof.html b/www/layouts/_default/baseof.html deleted file mode 100644 index 6d00be5..0000000 --- a/www/layouts/_default/baseof.html +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - {{ block "title" . }} - {{ .Site.Title }} - {{ end }} - {{ partial "js.html" "res/js/color-scheme.ts" }} - {{ partial "css-res.html" (partial "highlight.html" dict) }} - {{ partial "css.html" "res/css/base.css" }} - {{ block "head" . }} - {{ end }} - {{ range .Params.css }} - {{ partial "css.html" (printf "res/css/%s.css" .) }} - {{ end }} - - - {{ block "pre-article" .}} - {{ end }} -
- {{ block "content" . }} - {{ end }} -
- -
- - {{ block "scripts" . }} - {{ end }} - - diff --git a/www/layouts/_default/list.html b/www/layouts/_default/list.html deleted file mode 100644 index 5bb0b5e..0000000 --- a/www/layouts/_default/list.html +++ /dev/null @@ -1,17 +0,0 @@ -{{ define "head"}} - {{ partial "css.html" "res/css/article.css" }} -{{ end }} - -{{ define "content" }} - {{ partial "nav.html" . }} -

{{ .Title }}

- {{ $pages := .RegularPages }} - {{ if .Param "recursive" }} - {{ $pages = .RegularPagesRecursive }} - {{ end }} - {{ partial "preview/posts.html" (dict - "h" "h3" - "pages" $pages - ) - }} -{{ end }} diff --git a/www/layouts/_default/single.html b/www/layouts/_default/single.html deleted file mode 100644 index cd0e9c5..0000000 --- a/www/layouts/_default/single.html +++ /dev/null @@ -1,23 +0,0 @@ -{{ define "head"}} - {{ partial "css.html" "res/css/single.css" }} -{{ end }} - -{{ define "title" }} - {{ .Title }} -{{ end }} - -{{ define "content" }} - {{ partial "nav.html" . }} -

{{ .Title }}

-
-

- {{ partial "date.html" .Date }} | - {{ .WordCount }} words - {{ if ne .Lastmod .Date }} - Last updated: {{ partial "date.html" .Lastmod }} - {{ end}} -

- {{ .Content }} -
- {{ partial "nav.html" . }} -{{ end }} diff --git a/www/layouts/_partials/css-res.html b/www/layouts/_partials/css-res.html new file mode 100644 index 0000000..6fabf67 --- /dev/null +++ b/www/layouts/_partials/css-res.html @@ -0,0 +1,9 @@ +{{ with . | minify }} + {{ if hugo.IsProduction }} + {{ with . | fingerprint }} + + {{ end }} + {{ else }} + + {{ end }} +{{ end }} diff --git a/www/layouts/_partials/css.html b/www/layouts/_partials/css.html new file mode 100644 index 0000000..12d3353 --- /dev/null +++ b/www/layouts/_partials/css.html @@ -0,0 +1 @@ +{{ partial "css-res.html" (resources.Get .) }} \ No newline at end of file diff --git a/www/layouts/_partials/date.html b/www/layouts/_partials/date.html new file mode 100644 index 0000000..9769e4e --- /dev/null +++ b/www/layouts/_partials/date.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/www/layouts/_partials/highlight.html b/www/layouts/_partials/highlight.html new file mode 100644 index 0000000..28c510e --- /dev/null +++ b/www/layouts/_partials/highlight.html @@ -0,0 +1,6 @@ +{{ $light := resources.Get "res/css/catppuccin-latte.css" }} +{{ $dark := resources.Get "res/css/catppuccin-mocha.css" }} +{{ $dark_wrapper_before := resources.FromString "highlight-dark-wapper-before.css" `html[data-theme="dark"] {`}}} +{{ $dark_wrapper_after := resources.FromString "highlight-dark-wapper-after.css" "}"}} +{{ $highlight := slice $light $dark_wrapper_before $dark $dark_wrapper_after | resources.Concat "res/css/highlight.css" }} +{{ return $highlight }} diff --git a/www/layouts/_partials/js.html b/www/layouts/_partials/js.html new file mode 100644 index 0000000..16dafa4 --- /dev/null +++ b/www/layouts/_partials/js.html @@ -0,0 +1,11 @@ +{{ with resources.Get . }} + {{ if hugo.IsProduction }} + {{ with . | js.Build (dict "minify" true "sourceMap" "external") | fingerprint }} + + {{ end }} + {{ else }} + {{ with . | js.Build }} + + {{ end }} + {{ end }} +{{ end }} diff --git a/www/layouts/_partials/nav.html b/www/layouts/_partials/nav.html new file mode 100644 index 0000000..42c9ad1 --- /dev/null +++ b/www/layouts/_partials/nav.html @@ -0,0 +1,6 @@ + diff --git a/www/layouts/_partials/preview/article.html b/www/layouts/_partials/preview/article.html new file mode 100644 index 0000000..6245434 --- /dev/null +++ b/www/layouts/_partials/preview/article.html @@ -0,0 +1,10 @@ +
+ {{ .date | time.Format ":date_medium" }} + {{ (printf `<%[1]s class="title">%s` .h .link .title) | safeHTML }} +

+ {{ range split .content "\n" | first 5 }} + {{ . | htmlUnescape }}
+ {{ end }} +

+

... Read more

+
diff --git a/www/layouts/_partials/preview/post.html b/www/layouts/_partials/preview/post.html new file mode 100644 index 0000000..f0c6fb5 --- /dev/null +++ b/www/layouts/_partials/preview/post.html @@ -0,0 +1,7 @@ +{{ partial "preview/article.html" (dict + "h" .h + "title" .page.Title + "link" .page.RelPermalink + "content" .page.Plain + "date" .page.Date) +}} diff --git a/www/layouts/_partials/preview/posts.html b/www/layouts/_partials/preview/posts.html new file mode 100644 index 0000000..f2cb640 --- /dev/null +++ b/www/layouts/_partials/preview/posts.html @@ -0,0 +1,7 @@ +{{ $h := .h }} +{{ range .pages }} + {{ partial "preview/post.html" (dict + "h" $h + "page" .) + }} +{{ end }} \ No newline at end of file diff --git a/www/layouts/_shortcodes/link-group.html b/www/layouts/_shortcodes/link-group.html new file mode 100644 index 0000000..b16c2bc --- /dev/null +++ b/www/layouts/_shortcodes/link-group.html @@ -0,0 +1,25 @@ + diff --git a/www/layouts/baseof.html b/www/layouts/baseof.html new file mode 100644 index 0000000..6d00be5 --- /dev/null +++ b/www/layouts/baseof.html @@ -0,0 +1,49 @@ + + + + + + + + + {{ block "title" . }} + {{ .Site.Title }} + {{ end }} + {{ partial "js.html" "res/js/color-scheme.ts" }} + {{ partial "css-res.html" (partial "highlight.html" dict) }} + {{ partial "css.html" "res/css/base.css" }} + {{ block "head" . }} + {{ end }} + {{ range .Params.css }} + {{ partial "css.html" (printf "res/css/%s.css" .) }} + {{ end }} + + + {{ block "pre-article" .}} + {{ end }} +
+ {{ block "content" . }} + {{ end }} +
+ +
+ + {{ block "scripts" . }} + {{ end }} + + diff --git a/www/layouts/home.html b/www/layouts/home.html new file mode 100644 index 0000000..3cfc455 --- /dev/null +++ b/www/layouts/home.html @@ -0,0 +1,78 @@ +{{ define "head"}} + {{ partial "css.html" "res/css/home.css" }} + {{ partial "css.html" "res/css/article.css" }} +{{ end }} + +{{ define "friend" }} + {{ $gh_url := printf "https://github.com/%s" .github}} +
+ + Friend {{.name}}'s avatar
{{.name}}
+ + {{- with resources.Get "res/img/gh.png" -}} + + {{- end -}} +
+ {{ if .tag }} + {{ .tag }} + {{ end }} +
+{{ end }} + +{{ define "content"}} + My avatar +

Hello! This is crupest !

+
+
+

Welcome to my home page! Nice to meet you here! 🥰

+

Feel free to contact me via my email address crupest@crupest.life, + or just create an issue in any of my GitHub + repos. I love talking with people a lot.

+ +
+
+ {{ with .GetPage "/posts" }} +
+

Recent Posts (all)

+ {{ partial "preview/posts.html" (dict + "h" "h3" + "pages" (.RegularPages.ByDate.Reverse.Limit 3)) + }} +
+ {{ end }} +
+
+

My Friends (more links are being collected ...)

+
+ {{ block "friend" dict + "name" "wsm" + "avatar" "https://avatars.githubusercontent.com/u/74699943?v=4" + "github" "wushuming666" + }} + {{ end }} + {{ block "friend" dict + "name" "hsz" + "url" "https://www.hszsoft.com" + "avatar" "https://avatars.githubusercontent.com/u/63097618?v=4" + "github" "hszSoft" + "tag" "随性の程序员" + }} + {{ end }} +
+
+{{ end }} diff --git a/www/layouts/index.html b/www/layouts/index.html deleted file mode 100644 index af3e11d..0000000 --- a/www/layouts/index.html +++ /dev/null @@ -1,78 +0,0 @@ -{{ define "head"}} - {{ partial "css.html" "res/css/home.css" }} - {{ partial "css.html" "res/css/article.css" }} -{{ end }} - -{{ define "friend" }} - {{ $gh_url := printf "https://github.com/%s" .github}} -
- - Friend {{.name}}'s avatar
{{.name}}
- - {{- with resources.Get "res/img/gh.png" -}} - - {{- end -}} -
- {{ if .tag }} - {{ .tag }} - {{ end }} -
-{{ end }} - -{{ define "content"}} - My avatar -

Hello! This is crupest !

-
-
-

Welcome to my home page! Nice to meet you here! 🥰

-

Feel free to contact me via my email address crupest@crupest.life, - or just create an issue in any of my GitHub - repos. I love talking with people a lot.

- -
-
- {{ with .GetPage "/posts" }} -
-

Recent Posts (all)

- {{ partial "preview/posts.html" (dict - "h" "h3" - "pages" (.RegularPages.ByDate.Reverse.Limit 3)) - }} -
- {{ end }} -
-
-

My Friends (more links are being collected ...)

-
- {{ block "friend" dict - "name" "wsm" - "avatar" "https://avatars.githubusercontent.com/u/74699943?v=4" - "github" "wushuming666" - }} - {{ end }} - {{ block "friend" dict - "name" "hsz" - "url" "https://www.hszsoft.com" - "avatar" "https://avatars.githubusercontent.com/u/63097618?v=4" - "github" "hszSoft" - "tag" "随性の程序员" - }} - {{ end }} -
-
-{{ end }} diff --git a/www/layouts/list.html b/www/layouts/list.html new file mode 100644 index 0000000..be33d10 --- /dev/null +++ b/www/layouts/list.html @@ -0,0 +1,13 @@ +{{ define "head"}} + {{ partial "css.html" "res/css/article.css" }} +{{ end }} + +{{ define "content" }} + {{ partial "nav.html" . }} +

{{ .Title }}

+ {{ partial "preview/posts.html" (dict + "h" "h3" + "pages" .RegularPages + ) + }} +{{ end }} diff --git a/www/layouts/partials/css-res.html b/www/layouts/partials/css-res.html deleted file mode 100644 index 6fabf67..0000000 --- a/www/layouts/partials/css-res.html +++ /dev/null @@ -1,9 +0,0 @@ -{{ with . | minify }} - {{ if hugo.IsProduction }} - {{ with . | fingerprint }} - - {{ end }} - {{ else }} - - {{ end }} -{{ end }} diff --git a/www/layouts/partials/css.html b/www/layouts/partials/css.html deleted file mode 100644 index 12d3353..0000000 --- a/www/layouts/partials/css.html +++ /dev/null @@ -1 +0,0 @@ -{{ partial "css-res.html" (resources.Get .) }} \ No newline at end of file diff --git a/www/layouts/partials/date.html b/www/layouts/partials/date.html deleted file mode 100644 index 9769e4e..0000000 --- a/www/layouts/partials/date.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/www/layouts/partials/highlight.html b/www/layouts/partials/highlight.html deleted file mode 100644 index 28c510e..0000000 --- a/www/layouts/partials/highlight.html +++ /dev/null @@ -1,6 +0,0 @@ -{{ $light := resources.Get "res/css/catppuccin-latte.css" }} -{{ $dark := resources.Get "res/css/catppuccin-mocha.css" }} -{{ $dark_wrapper_before := resources.FromString "highlight-dark-wapper-before.css" `html[data-theme="dark"] {`}}} -{{ $dark_wrapper_after := resources.FromString "highlight-dark-wapper-after.css" "}"}} -{{ $highlight := slice $light $dark_wrapper_before $dark $dark_wrapper_after | resources.Concat "res/css/highlight.css" }} -{{ return $highlight }} diff --git a/www/layouts/partials/js.html b/www/layouts/partials/js.html deleted file mode 100644 index 16dafa4..0000000 --- a/www/layouts/partials/js.html +++ /dev/null @@ -1,11 +0,0 @@ -{{ with resources.Get . }} - {{ if hugo.IsProduction }} - {{ with . | js.Build (dict "minify" true "sourceMap" "external") | fingerprint }} - - {{ end }} - {{ else }} - {{ with . | js.Build }} - - {{ end }} - {{ end }} -{{ end }} diff --git a/www/layouts/partials/nav.html b/www/layouts/partials/nav.html deleted file mode 100644 index 42c9ad1..0000000 --- a/www/layouts/partials/nav.html +++ /dev/null @@ -1,6 +0,0 @@ - diff --git a/www/layouts/partials/preview/article.html b/www/layouts/partials/preview/article.html deleted file mode 100644 index 6245434..0000000 --- a/www/layouts/partials/preview/article.html +++ /dev/null @@ -1,10 +0,0 @@ -
- {{ .date | time.Format ":date_medium" }} - {{ (printf `<%[1]s class="title">%s` .h .link .title) | safeHTML }} -

- {{ range split .content "\n" | first 5 }} - {{ . | htmlUnescape }}
- {{ end }} -

-

... Read more

-
diff --git a/www/layouts/partials/preview/post.html b/www/layouts/partials/preview/post.html deleted file mode 100644 index f0c6fb5..0000000 --- a/www/layouts/partials/preview/post.html +++ /dev/null @@ -1,7 +0,0 @@ -{{ partial "preview/article.html" (dict - "h" .h - "title" .page.Title - "link" .page.RelPermalink - "content" .page.Plain - "date" .page.Date) -}} diff --git a/www/layouts/partials/preview/posts.html b/www/layouts/partials/preview/posts.html deleted file mode 100644 index f2cb640..0000000 --- a/www/layouts/partials/preview/posts.html +++ /dev/null @@ -1,7 +0,0 @@ -{{ $h := .h }} -{{ range .pages }} - {{ partial "preview/post.html" (dict - "h" $h - "page" .) - }} -{{ end }} \ No newline at end of file diff --git a/www/layouts/shortcodes/link-group.html b/www/layouts/shortcodes/link-group.html deleted file mode 100644 index b16c2bc..0000000 --- a/www/layouts/shortcodes/link-group.html +++ /dev/null @@ -1,25 +0,0 @@ - diff --git a/www/layouts/shortcodes/mono.html b/www/layouts/shortcodes/mono.html deleted file mode 100644 index ab183a5..0000000 --- a/www/layouts/shortcodes/mono.html +++ /dev/null @@ -1,3 +0,0 @@ -
- {{ .Inner | .Page.RenderString }} -
diff --git a/www/layouts/shortcodes/todo.html b/www/layouts/shortcodes/todo.html deleted file mode 100644 index b4fc680..0000000 --- a/www/layouts/shortcodes/todo.html +++ /dev/null @@ -1,5 +0,0 @@ -
-

{{ .Get "name" }}

- {{ .Inner }} -
- diff --git a/www/layouts/single.html b/www/layouts/single.html new file mode 100644 index 0000000..cd0e9c5 --- /dev/null +++ b/www/layouts/single.html @@ -0,0 +1,23 @@ +{{ define "head"}} + {{ partial "css.html" "res/css/single.css" }} +{{ end }} + +{{ define "title" }} + {{ .Title }} +{{ end }} + +{{ define "content" }} + {{ partial "nav.html" . }} +

{{ .Title }}

+
+

+ {{ partial "date.html" .Date }} | + {{ .WordCount }} words + {{ if ne .Lastmod .Date }} + Last updated: {{ partial "date.html" .Lastmod }} + {{ end}} +

+ {{ .Content }} +
+ {{ partial "nav.html" . }} +{{ end }} -- cgit v1.2.3