summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEltrac <hi@guhub.cn>2025-07-14 19:26:28 +0800
committerEltrac <hi@guhub.cn>2025-07-14 19:26:28 +0800
commit29af8b6c2bd89c1966512b4305af345b8ee1ef82 (patch)
tree07a4801791db7d6a4670d53411f0689ec0090bfe
parent44c7def3f6958550ccf965971f1819c1d6c514f1 (diff)
refactor: clearer division of each partial and better folder structure
-rw-r--r--layouts/_partials/components/breadcrumbs.html (renamed from layouts/partials/components/breadcrumbs.html)0
-rw-r--r--layouts/_partials/components/category-pill.html (renamed from layouts/partials/components/category-pill.html)0
-rw-r--r--layouts/_partials/components/date.html (renamed from layouts/partials/components/date.html)0
-rw-r--r--layouts/_partials/components/global-search.html (renamed from layouts/partials/components/global-search.html)8
-rw-r--r--layouts/_partials/components/logo.html (renamed from layouts/partials/components/logo.html)0
-rw-r--r--layouts/_partials/components/post-page-header.html (renamed from layouts/partials/components/post-page-header.html)0
-rw-r--r--layouts/_partials/components/postnav.html (renamed from layouts/partials/components/postnav.html)0
-rw-r--r--layouts/_partials/components/svg-filters.html (renamed from layouts/partials/components/svg-filters.html)0
-rw-r--r--layouts/_partials/components/tags.html (renamed from layouts/partials/components/tags.html)0
-rw-r--r--layouts/_partials/footer.html (renamed from layouts/partials/footer.html)0
-rw-r--r--layouts/_partials/head.html (renamed from layouts/partials/head.html)0
-rw-r--r--layouts/_partials/head/css.html (renamed from layouts/partials/head/css.html)0
-rw-r--r--layouts/_partials/head/siteinfo.html (renamed from layouts/partials/head/siteinfo.html)0
-rw-r--r--layouts/_partials/head/umami.html (renamed from layouts/partials/head/umami.html)0
-rw-r--r--layouts/_partials/header.html (renamed from layouts/partials/header.html)2
-rw-r--r--layouts/_partials/home/latest-cards.html18
-rw-r--r--layouts/_partials/home/latest-posts.html54
-rw-r--r--layouts/_partials/icons/globe-icon.html (renamed from layouts/partials/snippets/globe-icon.html)0
-rw-r--r--layouts/_partials/items/card.html (renamed from layouts/partials/items/card.html)0
-rw-r--r--layouts/_partials/posts/action-menu.html (renamed from layouts/partials/components/post-tabs.html)2
-rw-r--r--layouts/_partials/posts/banner.html (renamed from layouts/partials/components/banner.html)0
-rw-r--r--layouts/_partials/posts/comment.html (renamed from layouts/partials/components/comment.html)0
-rw-r--r--layouts/_partials/posts/endnotes.html (renamed from layouts/partials/components/endnotes.html)0
-rw-r--r--layouts/_partials/posts/now-read-this.html (renamed from layouts/partials/components/now-read-this.html)0
-rw-r--r--layouts/_partials/posts/toc.html (renamed from layouts/partials/components/toc.html)0
-rw-r--r--layouts/_partials/scripts.html (renamed from layouts/partials/scripts.html)0
-rw-r--r--layouts/_partials/stats/external-link-rank.html (renamed from layouts/partials/components/external-link-rank.html)0
-rw-r--r--layouts/_partials/stats/publish-time-chart.html (renamed from layouts/partials/components/publish-time-chart.html)0
-rw-r--r--layouts/_partials/stats/stats-table.html (renamed from layouts/partials/components/stats-table.html)0
-rw-r--r--layouts/_partials/stats/word-count-chart.html (renamed from layouts/partials/components/word-count-chart.html)0
-rw-r--r--layouts/fictions/single.html4
-rw-r--r--layouts/home.html76
-rw-r--r--layouts/library/single.html4
-rw-r--r--layouts/partials/components/pagefind.html7
-rw-r--r--layouts/partials/snippets/rss-icon.html6
-rw-r--r--layouts/posts/single.html10
-rw-r--r--layouts/stats.html8
37 files changed, 96 insertions, 103 deletions
diff --git a/layouts/partials/components/breadcrumbs.html b/layouts/_partials/components/breadcrumbs.html
index 99a49708..99a49708 100644
--- a/layouts/partials/components/breadcrumbs.html
+++ b/layouts/_partials/components/breadcrumbs.html
diff --git a/layouts/partials/components/category-pill.html b/layouts/_partials/components/category-pill.html
index aeb25747..aeb25747 100644
--- a/layouts/partials/components/category-pill.html
+++ b/layouts/_partials/components/category-pill.html
diff --git a/layouts/partials/components/date.html b/layouts/_partials/components/date.html
index 1998202f..1998202f 100644
--- a/layouts/partials/components/date.html
+++ b/layouts/_partials/components/date.html
diff --git a/layouts/partials/components/global-search.html b/layouts/_partials/components/global-search.html
index d60f2f20..769d0d2d 100644
--- a/layouts/partials/components/global-search.html
+++ b/layouts/_partials/components/global-search.html
@@ -1,7 +1,13 @@
<div id="global-search-container">
<div id="global-search">
<div id="global-search-close">×</div>
- {{ partial "components/pagefind" . }}
+ <!-- Pagefind Search -->
+ <div id="pagefind"></div>
+ <script>
+ window.addEventListener('DOMContentLoaded', () => {
+ new PagefindUI({ element: "#pagefind", showSubResults: true });
+ });
+ </script>
</div>
<div id="global-search-overlay"></div>
diff --git a/layouts/partials/components/logo.html b/layouts/_partials/components/logo.html
index 36040768..36040768 100644
--- a/layouts/partials/components/logo.html
+++ b/layouts/_partials/components/logo.html
diff --git a/layouts/partials/components/post-page-header.html b/layouts/_partials/components/post-page-header.html
index 4363b74c..4363b74c 100644
--- a/layouts/partials/components/post-page-header.html
+++ b/layouts/_partials/components/post-page-header.html
diff --git a/layouts/partials/components/postnav.html b/layouts/_partials/components/postnav.html
index 0174060c..0174060c 100644
--- a/layouts/partials/components/postnav.html
+++ b/layouts/_partials/components/postnav.html
diff --git a/layouts/partials/components/svg-filters.html b/layouts/_partials/components/svg-filters.html
index 5e68d6ec..5e68d6ec 100644
--- a/layouts/partials/components/svg-filters.html
+++ b/layouts/_partials/components/svg-filters.html
diff --git a/layouts/partials/components/tags.html b/layouts/_partials/components/tags.html
index 6ff7f594..6ff7f594 100644
--- a/layouts/partials/components/tags.html
+++ b/layouts/_partials/components/tags.html
diff --git a/layouts/partials/footer.html b/layouts/_partials/footer.html
index a4fbd231..a4fbd231 100644
--- a/layouts/partials/footer.html
+++ b/layouts/_partials/footer.html
diff --git a/layouts/partials/head.html b/layouts/_partials/head.html
index 10cd1c0d..10cd1c0d 100644
--- a/layouts/partials/head.html
+++ b/layouts/_partials/head.html
diff --git a/layouts/partials/head/css.html b/layouts/_partials/head/css.html
index b55dbe8d..b55dbe8d 100644
--- a/layouts/partials/head/css.html
+++ b/layouts/_partials/head/css.html
diff --git a/layouts/partials/head/siteinfo.html b/layouts/_partials/head/siteinfo.html
index ff029ac1..ff029ac1 100644
--- a/layouts/partials/head/siteinfo.html
+++ b/layouts/_partials/head/siteinfo.html
diff --git a/layouts/partials/head/umami.html b/layouts/_partials/head/umami.html
index 881b34c6..881b34c6 100644
--- a/layouts/partials/head/umami.html
+++ b/layouts/_partials/head/umami.html
diff --git a/layouts/partials/header.html b/layouts/_partials/header.html
index 6b22259e..37d6a3fb 100644
--- a/layouts/partials/header.html
+++ b/layouts/_partials/header.html
@@ -21,7 +21,7 @@
{{- $entry := index $switch $lang -}}
<a href="{{ $entry.url }}" data-umami-event="🌍 Switch Language"
class="no-swup" title="{{ $entry.label }}">
- {{ partial "snippets/globe-icon" . }}
+ {{ partial "icons/globe-icon" . }}
</a>
</div>
</header>
diff --git a/layouts/_partials/home/latest-cards.html b/layouts/_partials/home/latest-cards.html
new file mode 100644
index 00000000..bad3a27e
--- /dev/null
+++ b/layouts/_partials/home/latest-cards.html
@@ -0,0 +1,18 @@
+{{ if eq .Site.Language.Lang "zh" }}
+<!-- Latest Cards -->
+<section id="latest-cards">
+ <div class="latest-cards-container">
+ {{- $cards := .Site.GetPage "section" "cards" }} <!-- 获取 "cards" 部分的内容 -->
+ {{- $paginator := .Paginate $cards.Pages 4 }} <!-- 对该部分内容进行分页 -->
+ {{- range $paginator.Pages }}
+ {{ partial "items/card" (dict "context" . "summary" true) }}
+ {{- end }}
+ </div>
+ <div style="margin: 1rem 0">
+ <a href="/cards" class="index-section-morelink"
+ data-umami-event="➕ Click more cards link">
+ {{ T "moreLinks.cards" }}
+ </a>
+ </div>
+</section>
+{{ end }}
diff --git a/layouts/_partials/home/latest-posts.html b/layouts/_partials/home/latest-posts.html
new file mode 100644
index 00000000..30b1f212
--- /dev/null
+++ b/layouts/_partials/home/latest-posts.html
@@ -0,0 +1,54 @@
+<!-- Latest Posts -->
+<section id="latest-posts">
+ <div class="posts-list">
+ {{ $firstPost := true }} <!-- 初始化标记 -->
+ {{ range first 8 (where site.RegularPages "Type" "in" site.Params.mainSections) }}
+ <div class="posts-item"
+ style="view-transition-name: post-{{ .File.UniqueID }}">
+ <header>
+ <div class="posts-item-meta">
+ <p class="font-mono">
+ <time>{{ .Date.Format "January 2" }},</time>
+ <span>in <a href="/{{ .Section }}/">{{ .Section }}</a></span>
+ </p>
+ <h2 class="posts-item-title"
+ {{ if $firstPost }} style="margin-bottom: 0"{{ end }}>
+ <a
+ href="{{ .Permalink }}"
+ data-umami-event="🏠 Click post link from index"
+ >
+ {{ if eq .Section "library" }}
+ 读《{{ .Title }}》
+ {{ else }}
+ {{ .Title }}
+ {{ end }}
+ </a>
+ {{ if eq .Section "fictions" }}
+ <span class="posts-item-title-pill">小说</span>
+ {{ end }}
+ </h2>
+ </div>
+ {{ with .Params.categories }}
+ <div class="posts-item-category">
+ <a href="/categories/{{ . }}" style="padding: 0.1rem 0.3rem;">
+ {{ . }}
+ </a>
+ </div>
+ {{ end }}
+ </header>
+ <!-- 如果是第一篇文章,则显示摘要 -->
+ {{ if $firstPost }}
+ <div class="markdown-body posts-item-summary"
+ style="view-transition-name: post-content-{{ .File.UniqueID }}">
+ {{ .Summary }}
+ </div>
+ {{ $firstPost = false }} <!-- 更新为非第一篇 -->
+ {{ end }}
+ </div>
+ {{ end }}
+ </div>
+ <a href="/posts" class="index-section-morelink"
+ data-umami-event="➕ Click more posts link">
+ {{ T "moreLinks.posts" }}
+ </a>
+</section>
diff --git a/layouts/partials/snippets/globe-icon.html b/layouts/_partials/icons/globe-icon.html
index 932831c9..932831c9 100644
--- a/layouts/partials/snippets/globe-icon.html
+++ b/layouts/_partials/icons/globe-icon.html
diff --git a/layouts/partials/items/card.html b/layouts/_partials/items/card.html
index b8a3c7c1..b8a3c7c1 100644
--- a/layouts/partials/items/card.html
+++ b/layouts/_partials/items/card.html
diff --git a/layouts/partials/components/post-tabs.html b/layouts/_partials/posts/action-menu.html
index 9a714491..df2a3c2a 100644
--- a/layouts/partials/components/post-tabs.html
+++ b/layouts/_partials/posts/action-menu.html
@@ -32,7 +32,7 @@
<!-- 评论区域 -->
<div class="comments-section" id="comments-section" style="display: none;">
- {{ partial "components/comment.html" . }}
+ {{ partial "posts/comment.html" . }}
</div>
</div>
diff --git a/layouts/partials/components/banner.html b/layouts/_partials/posts/banner.html
index 7ab4c826..7ab4c826 100644
--- a/layouts/partials/components/banner.html
+++ b/layouts/_partials/posts/banner.html
diff --git a/layouts/partials/components/comment.html b/layouts/_partials/posts/comment.html
index 804570bc..804570bc 100644
--- a/layouts/partials/components/comment.html
+++ b/layouts/_partials/posts/comment.html
diff --git a/layouts/partials/components/endnotes.html b/layouts/_partials/posts/endnotes.html
index e7245ad4..e7245ad4 100644
--- a/layouts/partials/components/endnotes.html
+++ b/layouts/_partials/posts/endnotes.html
diff --git a/layouts/partials/components/now-read-this.html b/layouts/_partials/posts/now-read-this.html
index 6f2950c2..6f2950c2 100644
--- a/layouts/partials/components/now-read-this.html
+++ b/layouts/_partials/posts/now-read-this.html
diff --git a/layouts/partials/components/toc.html b/layouts/_partials/posts/toc.html
index 794328c9..794328c9 100644
--- a/layouts/partials/components/toc.html
+++ b/layouts/_partials/posts/toc.html
diff --git a/layouts/partials/scripts.html b/layouts/_partials/scripts.html
index 12beca10..12beca10 100644
--- a/layouts/partials/scripts.html
+++ b/layouts/_partials/scripts.html
diff --git a/layouts/partials/components/external-link-rank.html b/layouts/_partials/stats/external-link-rank.html
index 8ffe04d6..8ffe04d6 100644
--- a/layouts/partials/components/external-link-rank.html
+++ b/layouts/_partials/stats/external-link-rank.html
diff --git a/layouts/partials/components/publish-time-chart.html b/layouts/_partials/stats/publish-time-chart.html
index dac9e542..dac9e542 100644
--- a/layouts/partials/components/publish-time-chart.html
+++ b/layouts/_partials/stats/publish-time-chart.html
diff --git a/layouts/partials/components/stats-table.html b/layouts/_partials/stats/stats-table.html
index 24e2b45d..24e2b45d 100644
--- a/layouts/partials/components/stats-table.html
+++ b/layouts/_partials/stats/stats-table.html
diff --git a/layouts/partials/components/word-count-chart.html b/layouts/_partials/stats/word-count-chart.html
index 10513922..10513922 100644
--- a/layouts/partials/components/word-count-chart.html
+++ b/layouts/_partials/stats/word-count-chart.html
diff --git a/layouts/fictions/single.html b/layouts/fictions/single.html
index 83db7d60..d0817e9c 100644
--- a/layouts/fictions/single.html
+++ b/layouts/fictions/single.html
@@ -9,7 +9,7 @@
style="view-transition-name: post-{{ .File.UniqueID }}"
class="post-header fiction-header"
>
- {{ partial "components/banner.html" . }}
+ {{ partial "posts/banner" . }}
<h1 class="post-title" data-pagefind-meta="title">{{ .Title }}</h1>
<div class="post-meta">{{ partial "components/date" . }}</div>
</header>
@@ -21,6 +21,6 @@
</div>
<!-- Comment -->
- {{ partial "components/comment.html" . }}
+ {{ partial "posts/comment.html" . }}
</article>
{{ end }}
diff --git a/layouts/home.html b/layouts/home.html
index cc1042fd..18742fdf 100644
--- a/layouts/home.html
+++ b/layouts/home.html
@@ -2,80 +2,8 @@
<article class="index">
{{ partial "header.html" . }}
{{ partial "components/postnav.html" . }}
-
- <!-- Latest Posts -->
- <section id="latest-posts">
- <div class="posts-list">
- {{ $firstPost := true }} <!-- 初始化标记 -->
- {{ range first 8 (where site.RegularPages "Type" "in" site.Params.mainSections) }}
- <div class="posts-item"
- style="view-transition-name: post-{{ .File.UniqueID }}">
- <header>
- <div class="posts-item-meta">
- <p class="font-mono">
- <time>{{ .Date.Format "January 2" }},</time>
- <span>in <a href="/{{ .Section }}/">{{ .Section }}</a></span>
- </p>
- <h2 class="posts-item-title"
- {{ if $firstPost }} style="margin-bottom: 0"{{ end }}>
- <a
- href="{{ .Permalink }}"
- data-umami-event="🏠 Click post link from index"
- >
- {{ if eq .Section "library" }}
- 读《{{ .Title }}》
- {{ else }}
- {{ .Title }}
- {{ end }}
- </a>
- {{ if eq .Section "fictions" }}
- <span class="posts-item-title-pill">小说</span>
- {{ end }}
- </h2>
- </div>
- {{ with .Params.categories }}
- <div class="posts-item-category">
- <a href="/categories/{{ . }}" style="padding: 0.1rem 0.3rem;">
- {{ . }}
- </a>
- </div>
- {{ end }}
- </header>
- <!-- 如果是第一篇文章,则显示摘要 -->
- {{ if $firstPost }}
- <div class="markdown-body posts-item-summary"
- style="view-transition-name: post-content-{{ .File.UniqueID }}">
- {{ .Summary }}
- </div>
- {{ $firstPost = false }} <!-- 更新为非第一篇 -->
- {{ end }}
- </div>
- {{ end }}
- </div>
- <a href="/posts" class="index-section-morelink"
- data-umami-event="➕ Click more posts link">
- {{ T "moreLinks.posts" }}
- </a>
- </section>
-
- {{ if eq .Site.Language.Lang "zh" }}
- <!-- Latest Cards -->
- <section id="latest-cards">
- <div class="latest-cards-container">
- {{- $cards := .Site.GetPage "section" "cards" }} <!-- 获取 "cards" 部分的内容 -->
- {{- $paginator := .Paginate $cards.Pages 4 }} <!-- 对该部分内容进行分页 -->
- {{- range $paginator.Pages }}
- {{ partial "items/card" (dict "context" . "summary" true) }}
- {{- end }}
- </div>
- <div style="margin: 1rem 0">
- <a href="/cards" class="index-section-morelink"
- data-umami-event="➕ Click more cards link">
- {{ T "moreLinks.cards" }}
- </a>
- </div>
- </section>
- {{ end }}
+ {{ partial "home/latest-posts.html" . }}
+ {{ partial "home/latest-cards.html" . }}
</article>
{{ partial "footer.html" . }}
{{ end }}
diff --git a/layouts/library/single.html b/layouts/library/single.html
index 1f051da7..d5d2ea59 100644
--- a/layouts/library/single.html
+++ b/layouts/library/single.html
@@ -30,11 +30,11 @@
{{ .Content }}
</div>
<!-- Endnotes -->
- {{ partial "components/endnotes" . }}
+ {{ partial "posts/endnotes" . }}
<div class="book-footer">
<p>于 {{ partial "components/date" . }} 读完</p>
</div>
</div>
- {{ partial "components/comment.html" . }}
+ {{ partial "posts/comment.html" . }}
</article>
{{ end }}
diff --git a/layouts/partials/components/pagefind.html b/layouts/partials/components/pagefind.html
deleted file mode 100644
index fb031ace..00000000
--- a/layouts/partials/components/pagefind.html
+++ /dev/null
@@ -1,7 +0,0 @@
-<!-- Pagefind Search -->
-<div id="pagefind"></div>
-<script>
-window.addEventListener('DOMContentLoaded', () => {
- new PagefindUI({ element: "#pagefind", showSubResults: true });
-});
-</script>
diff --git a/layouts/partials/snippets/rss-icon.html b/layouts/partials/snippets/rss-icon.html
deleted file mode 100644
index 8e426cca..00000000
--- a/layouts/partials/snippets/rss-icon.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" viewBox="0 0 16 16" id="rss"
- style="width: 1rem; height: 1rem; fill: var(--text-color)">
- <circle cx="3" cy="13" r="2"></circle>
- <path d="M1 5.667v2.667A6.674 6.674 0 0 1 7.667 15h2.666c0-5.146-4.187-9.333-9.333-9.333z"></path>
- <path d="M1 1v2.667C7.25 3.667 12.334 8.75 12.334 15H15C15 7.28 8.72 1 1 1z"></path>
-</svg>
diff --git a/layouts/posts/single.html b/layouts/posts/single.html
index 94f9be6f..bdb0f617 100644
--- a/layouts/posts/single.html
+++ b/layouts/posts/single.html
@@ -6,7 +6,7 @@
style="view-transition-name: post-{{ .File.UniqueID }}"
class="post-header"
>
- {{ partial "components/banner.html" . }}
+ {{ partial "posts/banner" . }}
<!-- Title and Subtitle -->
<h1 class="post-title">
<span data-pagefind-meta="title">{{ .Title }}</span>
@@ -27,16 +27,16 @@
<div class="post-content markdown-body"
style="view-transition-name: post-content-{{ .File.UniqueID }}">
<!-- TOC -->
- {{ partial "components/toc" . }}
+ {{ partial "posts/toc" . }}
<!-- Content -->
<div id="post-content">
{{ .Content }}
</div>
<!-- Endnotes -->
- {{ partial "components/endnotes" . }}
+ {{ partial "posts/endnotes" . }}
</div>
- {{ partial "components/post-tabs.html" . }}
- {{ partial "components/now-read-this.html" . }}
+ {{ partial "posts/action-menu.html" . }}
+ {{ partial "posts/now-read-this.html" . }}
</article>
{{ end }}
diff --git a/layouts/stats.html b/layouts/stats.html
index 683b559d..1aa7cf3e 100644
--- a/layouts/stats.html
+++ b/layouts/stats.html
@@ -5,18 +5,18 @@
<section>
<h2>站点统计</h2>
- {{ partial "components/stats-table" . }}
+ {{ partial "stats/stats-table" . }}
</section>
<section>
<h2>每月文章字数</h2>
- {{ partial "components/word-count-chart" . }}
+ {{ partial "stats/word-count-chart" . }}
</section>
<section>
<h2>文章发布时间段分布</h2>
<div class="outbox">
- {{ partial "components/publish-time-chart" . }}
+ {{ partial "stats/publish-time-chart" . }}
</div>
</section>
<hr>
@@ -34,7 +34,7 @@
<section>
<h2>外部链接排行</h2>
<p>我在页面中嵌入的外部链接主要来自以下域名,引用次数少于 3 的已被排除。</p>
- {{ partial "components/external-link-rank" . }}
+ {{ partial "stats/external-link-rank" . }}
</section>
</article>
{{ partial "footer.html" . }}