From 92e642b3d9e2df106e6ad3aa38e4be6966d44268 Mon Sep 17 00:00:00 2001 From: verdant Date: Sun, 29 Mar 2026 13:46:15 +0800 Subject: solve confiction --- layouts/layouts/404.html | 29 + layouts/layouts/_default/_markup/render-image.html | 4 + layouts/layouts/_default/baseof.html | 33 + layouts/layouts/_default/list.html | 70 ++ layouts/layouts/_default/rss.xml | 82 ++ layouts/layouts/_default/single.html | 319 ++++++++ layouts/layouts/_default/term.html | 36 + layouts/layouts/archives/single.html | 96 +++ layouts/layouts/index.html | 3 + layouts/layouts/partials/custom_body.html | 3 + layouts/layouts/partials/custom_head.html | 21 + layouts/layouts/partials/favicon.html | 2 + layouts/layouts/partials/footer.html | 8 + layouts/layouts/partials/header.html | 4 + layouts/layouts/partials/nav.html | 6 + layouts/layouts/partials/post_meta.html | 39 + layouts/layouts/partials/seo_tags.html | 15 + layouts/layouts/partials/style.html | 846 +++++++++++++++++++++ layouts/layouts/partials/toc.html | 91 +++ layouts/layouts/robots.txt | 2 + layouts/layouts/shortcodes/archives-list.html | 30 + layouts/layouts/shortcodes/book.html | 9 + layouts/layouts/shortcodes/music.html | 37 + layouts/layouts/shortcodes/recent-posts.html | 24 + layouts/layouts/shortcodes/word-count.html | 41 + 25 files changed, 1850 insertions(+) create mode 100644 layouts/layouts/404.html create mode 100644 layouts/layouts/_default/_markup/render-image.html create mode 100644 layouts/layouts/_default/baseof.html create mode 100644 layouts/layouts/_default/list.html create mode 100644 layouts/layouts/_default/rss.xml create mode 100644 layouts/layouts/_default/single.html create mode 100644 layouts/layouts/_default/term.html create mode 100644 layouts/layouts/archives/single.html create mode 100644 layouts/layouts/index.html create mode 100644 layouts/layouts/partials/custom_body.html create mode 100644 layouts/layouts/partials/custom_head.html create mode 100644 layouts/layouts/partials/favicon.html create mode 100644 layouts/layouts/partials/footer.html create mode 100644 layouts/layouts/partials/header.html create mode 100644 layouts/layouts/partials/nav.html create mode 100644 layouts/layouts/partials/post_meta.html create mode 100644 layouts/layouts/partials/seo_tags.html create mode 100644 layouts/layouts/partials/style.html create mode 100644 layouts/layouts/partials/toc.html create mode 100644 layouts/layouts/robots.txt create mode 100644 layouts/layouts/shortcodes/archives-list.html create mode 100644 layouts/layouts/shortcodes/book.html create mode 100644 layouts/layouts/shortcodes/music.html create mode 100644 layouts/layouts/shortcodes/recent-posts.html create mode 100644 layouts/layouts/shortcodes/word-count.html (limited to 'layouts') diff --git a/layouts/layouts/404.html b/layouts/layouts/404.html new file mode 100644 index 0000000..76d46d9 --- /dev/null +++ b/layouts/layouts/404.html @@ -0,0 +1,29 @@ +{{ define "title" }}404{{ end }} {{ define "main" }} + +
+

🏝️

+

OHHHHH~ +

+

Who lives in a pineapple under the sea?

+
+{{ end }} diff --git a/layouts/layouts/_default/_markup/render-image.html b/layouts/layouts/_default/_markup/render-image.html new file mode 100644 index 0000000..bf19bf9 --- /dev/null +++ b/layouts/layouts/_default/_markup/render-image.html @@ -0,0 +1,4 @@ +
+ {{ .Text }} +
{{ .Text }}
+
\ No newline at end of file diff --git a/layouts/layouts/_default/baseof.html b/layouts/layouts/_default/baseof.html new file mode 100644 index 0000000..72b2954 --- /dev/null +++ b/layouts/layouts/_default/baseof.html @@ -0,0 +1,33 @@ + + + + + + + {{- partial "favicon.html" . -}} + {{ .Title }} + + {{- partial "seo_tags.html" . -}} + + + {{ with .OutputFormats.Get "rss" -}} {{ printf ` + + ` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }} {{ end -}} {{- + partial "style.html" . -}} + + + {{- partial "custom_head.html" . -}} + + + +
{{- block "main" . }}{{- end }}
+ + + + {{- partial "custom_body.html" . -}} + + diff --git a/layouts/layouts/_default/list.html b/layouts/layouts/_default/list.html new file mode 100644 index 0000000..8c1db86 --- /dev/null +++ b/layouts/layouts/_default/list.html @@ -0,0 +1,70 @@ +{{ define "main" }} + + {{ if .Site.Params.postSearch }} + + + {{ end }} + + +{{ end }} diff --git a/layouts/layouts/_default/rss.xml b/layouts/layouts/_default/rss.xml new file mode 100644 index 0000000..e480a4b --- /dev/null +++ b/layouts/layouts/_default/rss.xml @@ -0,0 +1,82 @@ +{{- /* Deprecate site.Author.email in favor of site.Params.author.email */}} +{{- $authorEmail := "" }} +{{- with site.Params.author }} + {{- if reflect.IsMap . }} + {{- with .email }} + {{- $authorEmail = . }} + {{- end }} + {{- end }} +{{- else }} + {{- with site.Author.email }} + {{- $authorEmail = . }} + {{- warnf "The author key in site configuration is deprecated. Use params.author.email instead." }} + {{- end }} +{{- end }} + +{{- /* Deprecate site.Author.name in favor of site.Params.author.name */}} +{{- $authorName := "" }} +{{- with site.Params.author }} + {{- if reflect.IsMap . }} + {{- with .name }} + {{- $authorName = . }} + {{- end }} + {{- else }} + {{- $authorName = . }} + {{- end }} +{{- else }} + {{- with site.Author.name }} + {{- $authorName = . }} + {{- warnf "The author key in site configuration is deprecated. Use params.author.name instead." }} + {{- end }} +{{- end }} + +{{- $pctx := . }} +{{- if .IsHome }}{{ $pctx = .Site }}{{ end }} +{{- $pages := slice }} +{{- if or $.IsHome $.IsSection }} +{{- $pages = where $pctx.RegularPages "Type" "in" (slice "posts" "post") }} +{{- else }} +{{- $pages = where $pctx.Pages "Type" "in" (slice "posts" "post") }} +{{- end }} + +{{- printf "" | safeHTML }} + + + {{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{ . }} on {{ end }}{{ .Site.Title }}{{ end }} + {{ .Permalink }} + Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{ . }} {{ end }}{{ end }}on {{ .Site.Title }} + Hugo + {{ site.LanguageCode }} + {{ with $authorEmail }} + {{ . }}{{ with $authorName }} ({{ . }}){{ end }} + {{ end }} + {{ with $authorEmail }} + {{ . }}{{ with $authorName }} ({{ . }}){{ end }} + {{ end }} + {{ with .Site.Params.copyright }} + {{ . }} + {{ end }} + {{ if not .Date.IsZero }} + {{ (index $pages.ByLastmod.Reverse 0).Lastmod.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} + {{ end }} + {{ if and .Site.Params.RSS.followFeedId .Site.Params.RSS.followUserId }} + + {{ .Site.Params.RSS.followFeedId }} + {{ .Site.Params.RSS.followUserId }} + + {{ end }} + {{- with .OutputFormats.Get "RSS" }} + {{ printf "" .Permalink .MediaType | safeHTML }} + {{- end }} + {{- range $pages }} + + {{ .Title }} + {{ .Permalink }} + {{ .PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} + {{- with $authorEmail }}{{ . }}{{ with $authorName }} ({{ . }}){{ end }}{{ end }} + {{ .Permalink }} + {{ .Content | transform.XMLEscape | safeHTML }} + + {{- end }} + + diff --git a/layouts/layouts/_default/single.html b/layouts/layouts/_default/single.html new file mode 100644 index 0000000..6b3f0a4 --- /dev/null +++ b/layouts/layouts/_default/single.html @@ -0,0 +1,319 @@ +{{ define "main" }} +
{{- partial "header.html" . -}}
+ +
+

+ {{ .Title }} +

+ +
{{ .Content }}
+
+ + +
+ +{{ partial "post_meta.html" . }} + +{{ $upvoteEnabled := default .Site.Params.upvote .Params.upvote }} {{ if $upvoteEnabled }} +
+ + + +
+ + + +{{ end }} + + +{{ $tocEnabled := default .Site.Params.toc .Params.toc }} {{ if $tocEnabled }} +
{{ partial "toc.html" . }}
+{{ end }} + +{{ if .Params.comments | default true }} +
+
+ +

评论 与 Webmentions

+
+
+ +
+
+ + +

+ 若想回复本文,请在你的博客或社媒发布含有本文链接的帖子,然后在下方表单提交链接。 +

+
+
+
+ + +
+ + + +
+
+
+

+ 也可以发送邮件评论。 +

+ 关于 Webmention 的更多信息 + 以及 + 为什么要这么做? +
+ + + + {{ end }} +
+
+
+ + {{ if not .Params.comments }} + {{ with .Params.reason }} +
+

评论区已关闭。

+ {{ . | markdownify }} +
+ {{ end }} + {{ end }} +
+{{ end }} diff --git a/layouts/layouts/_default/term.html b/layouts/layouts/_default/term.html new file mode 100644 index 0000000..0d55fc1 --- /dev/null +++ b/layouts/layouts/_default/term.html @@ -0,0 +1,36 @@ +{{ define "main" }} +
+

{{ .Title }}

+ +
+ {{ range .Pages }} + +
  • + + {{ .Title }} +
  • + + {{ else }} +

    该分类下还没有文章。

    + {{ end }} +
    +
    +{{ end }} diff --git a/layouts/layouts/archives/single.html b/layouts/layouts/archives/single.html new file mode 100644 index 0000000..698fc46 --- /dev/null +++ b/layouts/layouts/archives/single.html @@ -0,0 +1,96 @@ +{{ define "main" }} +
    {{- partial "header.html" . -}}
    + + {{ if .Site.Params.postSearch }} + + + {{ end }} {{ $allPosts := where .Site.RegularPages "Type" "eq" "posts" }} + {{ $excludePosts := where $allPosts "Params.categories" "intersect" (slice "1") }} + + {{ $postPages := $allPosts | complement $excludePosts }} {{ if + .Site.Params.showPostCount }} +

    共有 {{ len $postPages }} 篇文章

    + {{ end }} + + +
    +
    +{{ end }} diff --git a/layouts/layouts/index.html b/layouts/layouts/index.html new file mode 100644 index 0000000..2c47df5 --- /dev/null +++ b/layouts/layouts/index.html @@ -0,0 +1,3 @@ +{{ define "main" }} +
    {{- partial "header.html" . -}}
    +{{ .Content }} {{ end }} diff --git a/layouts/layouts/partials/custom_body.html b/layouts/layouts/partials/custom_body.html new file mode 100644 index 0000000..126375a --- /dev/null +++ b/layouts/layouts/partials/custom_body.html @@ -0,0 +1,3 @@ + diff --git a/layouts/layouts/partials/custom_head.html b/layouts/layouts/partials/custom_head.html new file mode 100644 index 0000000..051d3d9 --- /dev/null +++ b/layouts/layouts/partials/custom_head.html @@ -0,0 +1,21 @@ + + + + + + + + diff --git a/layouts/layouts/partials/favicon.html b/layouts/layouts/partials/favicon.html new file mode 100644 index 0000000..ccf1a5d --- /dev/null +++ b/layouts/layouts/partials/favicon.html @@ -0,0 +1,2 @@ +{{ with .Site.Params.favicon }} +{{ end }} diff --git a/layouts/layouts/partials/footer.html b/layouts/layouts/partials/footer.html new file mode 100644 index 0000000..5cd0d54 --- /dev/null +++ b/layouts/layouts/partials/footer.html @@ -0,0 +1,8 @@ + diff --git a/layouts/layouts/partials/header.html b/layouts/layouts/partials/header.html new file mode 100644 index 0000000..1efdd22 --- /dev/null +++ b/layouts/layouts/partials/header.html @@ -0,0 +1,4 @@ + +

    {{ .Site.Title }}

    +
    + diff --git a/layouts/layouts/partials/nav.html b/layouts/layouts/partials/nav.html new file mode 100644 index 0000000..96bf26b --- /dev/null +++ b/layouts/layouts/partials/nav.html @@ -0,0 +1,6 @@ +{{ range .Site.Menus.main }} +{{ .Name }} +{{ end }} +{{ with .Site.GetPage "/blog" }} +Blog +{{ end }} diff --git a/layouts/layouts/partials/post_meta.html b/layouts/layouts/partials/post_meta.html new file mode 100644 index 0000000..741efd2 --- /dev/null +++ b/layouts/layouts/partials/post_meta.html @@ -0,0 +1,39 @@ +{{ if ne (.Params.showMeta | default true) false }} +
    + + + + + + + + +
    +{{ end }} diff --git a/layouts/layouts/partials/seo_tags.html b/layouts/layouts/partials/seo_tags.html new file mode 100644 index 0000000..06e90cd --- /dev/null +++ b/layouts/layouts/partials/seo_tags.html @@ -0,0 +1,15 @@ + + + + + + + + +{{ template "_internal/opengraph.html" . }} + + +{{ template "_internal/twitter_cards.html" . }} + + +{{ template "_internal/schema.html" . }} diff --git a/layouts/layouts/partials/style.html b/layouts/layouts/partials/style.html new file mode 100644 index 0000000..470a611 --- /dev/null +++ b/layouts/layouts/partials/style.html @@ -0,0 +1,846 @@ + diff --git a/layouts/layouts/partials/toc.html b/layouts/layouts/partials/toc.html new file mode 100644 index 0000000..66936a4 --- /dev/null +++ b/layouts/layouts/partials/toc.html @@ -0,0 +1,91 @@ +{{/* 根据页面内容生成目录 */}} +{{ if and .TableOfContents (ne .TableOfContents "") }} + + + +{{ end }} \ No newline at end of file diff --git a/layouts/layouts/robots.txt b/layouts/layouts/robots.txt new file mode 100644 index 0000000..0326f5c --- /dev/null +++ b/layouts/layouts/robots.txt @@ -0,0 +1,2 @@ +User-Agent: * +Sitemap: {{ "sitemap.xml" | absURL }} diff --git a/layouts/layouts/shortcodes/archives-list.html b/layouts/layouts/shortcodes/archives-list.html new file mode 100644 index 0000000..b9767f7 --- /dev/null +++ b/layouts/layouts/shortcodes/archives-list.html @@ -0,0 +1,30 @@ +{{ $allPages := where .Site.RegularPages "Type" "in" (slice "posts" "blog") }} +{{ $visiblePages := where $allPages "Params.hidden" "!=" true }} +{{ $pagesToShow := $visiblePages.ByDate.Reverse }} + +
    +

    归档

    + +

    共有 {{ len $pagesToShow }} 篇文章

    + + +
    diff --git a/layouts/layouts/shortcodes/book.html b/layouts/layouts/shortcodes/book.html new file mode 100644 index 0000000..45f806a --- /dev/null +++ b/layouts/layouts/shortcodes/book.html @@ -0,0 +1,9 @@ +
    + {{ if .Get "url" }} + + 图书封面 + + {{ else }} + 图书封面 + {{ end }} +
    diff --git a/layouts/layouts/shortcodes/music.html b/layouts/layouts/shortcodes/music.html new file mode 100644 index 0000000..583b0b0 --- /dev/null +++ b/layouts/layouts/shortcodes/music.html @@ -0,0 +1,37 @@ + + +
    + +
    + Cover +
    +

    {{ .Get "title" }}

    +

    {{ .Get "artist" }}

    +
    +
    + + + +
    diff --git a/layouts/layouts/shortcodes/recent-posts.html b/layouts/layouts/shortcodes/recent-posts.html new file mode 100644 index 0000000..b2a6637 --- /dev/null +++ b/layouts/layouts/shortcodes/recent-posts.html @@ -0,0 +1,24 @@ +{{ $pages := where site.RegularPages "Type" "in" site.Params.mainSections }} {{ +$recent := first 5 $pages.ByDate.Reverse }} + + + +
    + {{ if $recent }} {{ range $index, $page := $recent }} +
    +

    + {{ .Title }} +

    +
    {{ .Summary }}
    + + {{ partial "post_meta.html" . }} + + {{ if not (eq (add $index 1) (len $recent)) }} {{ end }} {{ end }} {{ else }} +
    暂无文章
    + {{ end }} +
    diff --git a/layouts/layouts/shortcodes/word-count.html b/layouts/layouts/shortcodes/word-count.html new file mode 100644 index 0000000..38dbe0e --- /dev/null +++ b/layouts/layouts/shortcodes/word-count.html @@ -0,0 +1,41 @@ +{{ $scratch := newScratch }} {{ if eq (.Get 0) "posts" }} {{ range where +site.RegularPages "Type" "in" (slice "posts" "jottings" "readings" "tech") }} {{ +if not (in .Params.categories "!往昔!") }} {{ $scratch.Add "wordcount" .WordCount +}} {{ end }} {{ end }} {{ else if eq (.Get 0) "all" }} {{ range where +site.RegularPages "Type" "in" (slice "posts" "about" "newsgroup" "links" +"jottings" "readings" "tech") }} {{ if not (in .Params.categories "!往昔") }} {{ +$scratch.Add "wordcount" .WordCount }} {{ end }} {{ end }} {{ end }} {{ $count +:= $scratch.Get "wordcount" }} {{ if gt $count 0 }} {{ $count }} 字, {{/* +名著数据库(字数单位:汉字) */}} {{ $classics := slice (dict "name" "红楼梦" +"author" "曹雪芹" "country" "(中)" "words" 731017) (dict "name" "源氏物语" +"author" "紫式部" "country" "(日)" "words" 876000) (dict "name" "假面的告白" +"author" "三岛由纪夫" "country" "(日)" "words" 86000) (dict "name" "金阁寺" +"author" "三岛由纪夫" "country" "(日)" "words" 125000) (dict "name" +"了不起的盖茨比" "author" "菲茨杰拉德" "country" "(美)" "words" 49800) (dict +"name" "傲慢与偏见" "author" "简·奥斯汀" "country" "(英)" "words" 183000) +(dict "name" "呐喊" "author" "鲁迅" "country" "(中)" "words" 152000) (dict +"name" "罗生门" "author" "芥川龙之介" "country" "(日)" "words" 35800) (dict +"name" "老人与海" "author" "海明威" "country" "(美)" "words" 26800) (dict +"name" "简爱" "author" "夏洛蒂·勃朗特" "country" "(英)" "words" 322000) (dict +"name" "三国演义" "author" "罗贯中" "country" "(中)" "words" 640000) (dict +"name" "雪国" "author" "川端康成" "country" "(日)" "words" 78000) (dict "name" +"杀死一只知更鸟" "author" "哈珀·李" "country" "(美)" "words" 187000) (dict +"name" "1984" "author" "乔治·奥威尔" "country" "(英)" "words" 123000) (dict +"name" "围城" "author" "钱钟书" "country" "(中)" "words" 257000) (dict "name" +"我是猫" "author" "夏目漱石" "country" "(日)" "words" 402000) (dict "name" +"飘" "author" "玛格丽特·米切尔" "country" "(美)" "words" 802000) (dict "name" +"呼啸山庄" "author" "艾米莉·勃朗特" "country" "(英)" "words" 282000) }} {{/* +寻找最接近的名著 */}} {{ $closest := dict "diff" 999999999 "book" (index +$classics 0) }} {{ range $book := $classics }} {{ $ratio := div (float $count) +$book.words }} {{ if and (ge $ratio 0.8) (le $ratio 1.2) }} {{ $diff := sub +$ratio 1.0 }} {{ if lt $diff 0 }}{{ $diff = mul $diff -1 }}{{ end }} {{ if lt +$diff $closest.diff }} {{ $closest = dict "diff" $diff "book" $book }} {{ end }} +{{ end }} {{ end }} {{/* 输出对比结果 */}} {{ with $closest.book }} 约等于 《{{ +.name }}》 的{{ div (float $count) .words | printf "%.1f" }}倍 {{ else }} {{/* +未找到匹配时显示长度最接近的名著 */}} {{ $closestBook := index $classics 0 }} {{ +$minDiff := sub $count $closestBook.words }} {{ if lt $minDiff 0 }}{{ $minDiff = +mul $minDiff -1 }}{{ end }} {{ range $classics }} {{ $currDiff := sub $count +.words }} {{ if lt $currDiff 0 }}{{ $currDiff = mul $currDiff -1 }}{{ end }} {{ +if lt $currDiff $minDiff }} {{ $closestBook = . }} {{ $minDiff = $currDiff }} {{ +end }} {{ end }} ≈ {{ $closestBook.name }}{{ div (float $count) +$closestBook.words | printf "%.1f" }}倍 {{ end }} {{ else }} 0字 {{ end }} -- cgit v1.2.3