summaryrefslogtreecommitdiff
path: root/layouts
diff options
context:
space:
mode:
authorEltrac <hi@guhub.cn>2025-11-27 23:35:37 +0800
committerEltrac <hi@guhub.cn>2025-11-27 23:35:37 +0800
commit5cb1c7eb72fad939bcc76be11e4b6149f37618e1 (patch)
tree338e937126b595840885a529b67c6b62b4ddbdbc /layouts
parentd56407e244a6b74f6f913507d63e03377cc86308 (diff)
feat: adapt to new content system - remove more posts link in homepage - more
latest content (posts, essays, library, fictions...) in homepage - use the same template for posts and essays - new post section list style - show section-specific categories in section page Former-commit-id: 9a478cf5ee77a32b83dbe8f03d7ed8e83247937f
Diffstat (limited to 'layouts')
-rw-r--r--layouts/_partials/home/latest-posts.html6
-rw-r--r--layouts/_partials/section-categories.html20
-rw-r--r--layouts/_partials/template/post-page.html47
-rw-r--r--layouts/essays/page.html3
-rw-r--r--layouts/essays/section.html4
-rw-r--r--layouts/posts/page.html48
-rw-r--r--layouts/section.html40
7 files changed, 104 insertions, 64 deletions
diff --git a/layouts/_partials/home/latest-posts.html b/layouts/_partials/home/latest-posts.html
index 2a0beccd..ac015111 100644
--- a/layouts/_partials/home/latest-posts.html
+++ b/layouts/_partials/home/latest-posts.html
@@ -1,7 +1,7 @@
<!-- Latest Posts -->
<section class="pagefind-exclude flex flex-col my-4">
{{ $firstPost := true }}
- {{ range first 5 (where site.RegularPages "Type" "in" site.Params.mainSections) }}
+ {{ range first 12 (where site.RegularPages "Type" "in" site.Params.mainSections) }}
{{ partial "items/post" (dict
"ctx" .
"showSummary" $firstPost
@@ -9,7 +9,3 @@
{{ $firstPost = false }}
{{ end }}
</section>
-
-<a href="/posts" class="small-button">
- {{ T "moreLinks.posts" }} →
-</a>
diff --git a/layouts/_partials/section-categories.html b/layouts/_partials/section-categories.html
new file mode 100644
index 00000000..5e92bcc3
--- /dev/null
+++ b/layouts/_partials/section-categories.html
@@ -0,0 +1,20 @@
+{{ $categories := slice }}
+{{ range . }}
+ {{ with .Params.categories }}
+ {{ if not (in $categories .) }}
+ {{ $categories = $categories | append . }}
+ {{ end }}
+ {{ end }}
+{{ end }}
+
+<div class="flex gap-2 flex-wrap">
+ {{ range $categories }}
+ <a href="/categories/{{ . }}/"
+ class="text-size-lg px-3 py-2
+ transition-colors duration-300 rounded-xl hover:no-underline
+ bg-slate-2/50 dark:bg-neutral-800/50
+ hover:bg-[var(--text-color)] hover:text-[var(--block-background-color)]">
+ {{ . }}
+ </a>
+ {{ end }}
+</div>
diff --git a/layouts/_partials/template/post-page.html b/layouts/_partials/template/post-page.html
new file mode 100644
index 00000000..39d8c875
--- /dev/null
+++ b/layouts/_partials/template/post-page.html
@@ -0,0 +1,47 @@
+<article>
+ <!-- Post Header -->
+ <header
+ style="view-transition-name: post-{{ .File.UniqueID }}"
+ class="mb-8 relative"
+ >
+ {{ if .Params.banner }}
+ {{ partial "components/logo" (dict
+ "class" "block round-sticker w-14 h-14 lg:w-28 lg:h-28 right-2 lg:-right-20 top-2 lg:top-4 absolute rotate-[3.0deg]"
+ "imageClass" "block w-full"
+ ) }}
+ {{ else }}
+ {{ partial "components/logo" (dict
+ "class" "block w-[10rem]"
+ "imageClass" "block w-full"
+ ) }}
+ {{ end }}
+
+ {{ partial "posts/banner" . }}
+ <!-- Title and Subtitle -->
+ <h1 class="text-size-3xl font-900 xerox">
+ <span data-pagefind-meta="title">{{ .Title }}</span>
+ {{ with .Params.subtitle }}
+ <small class="block text-secondary font-italic text-size-xl">{{ . }}</small>
+ {{ end }}
+ </h1>
+ <!-- Post Meta -->
+ <div class="flex flex-wrap items-center gap-2">
+ <span class="text-secondary">{{ partial "components/date" . }}</span>
+ {{ if or .Params.categories .Params.tags }}<span>·</span>{{ end }}
+ {{ partial "components/category-pill" . }}
+ {{ partial "components/tags" . }}
+ </div>
+ </header>
+
+ <!-- Post Content -->
+ <div class="min-h-[60%] leading-loose mb-8 markdown-body text-size-lg md:text-size-xl"
+ style="view-transition-name: post-content-{{ .File.UniqueID }}">
+ {{ partial "posts/toc" . }}
+ <div id="post-content">{{ .Content }}</div>
+ {{ partial "posts/endnotes" . }}
+ </div>
+
+ {{ partial "posts/action-menu.html" . }}
+ {{ partial "posts/now-read-this.html" . }}
+ {{ partial "components/back-to-top.html" . }}
+</article>
diff --git a/layouts/essays/page.html b/layouts/essays/page.html
new file mode 100644
index 00000000..e093e810
--- /dev/null
+++ b/layouts/essays/page.html
@@ -0,0 +1,3 @@
+{{ define "main" }}
+ {{ partial "template/post-page" . }}
+{{ end }}
diff --git a/layouts/essays/section.html b/layouts/essays/section.html
index d7075c5f..36331fbf 100644
--- a/layouts/essays/section.html
+++ b/layouts/essays/section.html
@@ -3,9 +3,11 @@
{{ partial "header.html" . }}
<div class="posts-list pagefind-exclude">
<div class="markdown-body">{{ .Content }}</div>
+ {{ $pages := .Pages }}
+ {{ partial "section-categories" $pages }}
<!-- Post Archive List -->
{{ $remainingMonthsToOpen := 3 }}
- {{ range (where site.RegularPages "Type" "eq" "essays").GroupByDate "2006" -}}
+ {{ range $pages.GroupByDate "2006" -}}
<section class="w-full">
{{ partial "components/section-title" (dict
"Left" .Key
diff --git a/layouts/posts/page.html b/layouts/posts/page.html
index 0320820d..e093e810 100644
--- a/layouts/posts/page.html
+++ b/layouts/posts/page.html
@@ -1,49 +1,3 @@
{{ define "main" }}
- <article>
- <!-- Post Header -->
- <header
- style="view-transition-name: post-{{ .File.UniqueID }}"
- class="mb-8 relative"
- >
- {{ if .Params.banner }}
- {{ partial "components/logo" (dict
- "class" "block round-sticker w-14 h-14 lg:w-28 lg:h-28 right-2 lg:-right-20 top-2 lg:top-4 absolute rotate-[3.0deg]"
- "imageClass" "block w-full"
- ) }}
- {{ else }}
- {{ partial "components/logo" (dict
- "class" "block w-[10rem]"
- "imageClass" "block w-full"
- ) }}
- {{ end }}
-
- {{ partial "posts/banner" . }}
- <!-- Title and Subtitle -->
- <h1 class="text-size-3xl font-900 xerox">
- <span data-pagefind-meta="title">{{ .Title }}</span>
- {{ with .Params.subtitle }}
- <small class="block text-secondary font-italic text-size-xl">{{ . }}</small>
- {{ end }}
- </h1>
- <!-- Post Meta -->
- <div class="flex flex-wrap items-center gap-2">
- <span class="text-secondary">{{ partial "components/date" . }}</span>
- {{ if or .Params.categories .Params.tags }}<span>·</span>{{ end }}
- {{ partial "components/category-pill" . }}
- {{ partial "components/tags" . }}
- </div>
- </header>
-
- <!-- Post Content -->
- <div class="min-h-[60%] leading-loose mb-8 markdown-body text-size-lg md:text-size-xl"
- style="view-transition-name: post-content-{{ .File.UniqueID }}">
- {{ partial "posts/toc" . }}
- <div id="post-content">{{ .Content }}</div>
- {{ partial "posts/endnotes" . }}
- </div>
-
- {{ partial "posts/action-menu.html" . }}
- {{ partial "posts/now-read-this.html" . }}
- {{ partial "components/back-to-top.html" . }}
- </article>
+ {{ partial "template/post-page" . }}
{{ end }}
diff --git a/layouts/section.html b/layouts/section.html
index d3fe3ac4..3ddc6bb7 100644
--- a/layouts/section.html
+++ b/layouts/section.html
@@ -1,11 +1,19 @@
{{ define "main" }}
+
+ {{ $pages := .Pages }}
+ {{ $categories := slice }}
+
<article>
{{ partial "header.html" . }}
<div class="posts-list pagefind-exclude">
<div class="markdown-body">{{ .Content }}</div>
+
+ {{ partial "section-categories" $pages }}
+ <p class="text-secondary text-sm">*稻草人周刊也属于散文集,但为了方便查阅,周刊没有列在下面,请到<a href="/categories/稻草人周刊/">分类页面</a>查看周刊。</p>
+
<!-- Post Archive List -->
{{ $remainingMonthsToOpen := 3 }}
- {{ range (where site.RegularPages "Type" "eq" "posts").GroupByDate "2006" -}}
+ {{ range $pages.GroupByDate "2006" -}}
<section class="w-full">
{{ partial "components/section-title" (dict
"Left" .Key
@@ -13,20 +21,30 @@
)}}
{{ range .Pages.GroupByDate "January" }}
- <details class="posts-month-archive"{{ if gt $remainingMonthsToOpen 0 }} open{{ end }}>
- <summary class="flex items-center border-b border-b-dashed border-[var(--border-color)] py-2 px-1">
- <h2 class="text-size-lg inline-block w-full m-0
- flex justify-between items-center">
- {{ .Key }}
- <small class="font-mono text-secondary text-3">{{ T "archivePage.postCountMonthly" (len .Pages) }}</small>
- </h2>
- </summary>
+ <div class="posts-month-archive"{{ if gt $remainingMonthsToOpen 0 }} open{{ end }}>
+ <h2 class="text-size-lg inline-block w-full m-0
+ flex justify-between items-center">
+ {{ .Key }}
+ </h2>
<ul class="ps-0 flex flex-col gap-2 list-none leading-relaxed">
{{ range .Pages }}
- {{ partial "items/post-small" . }}
+ {{ $isWeekly := (eq .Params.categories "稻草人周刊") }}
+ {{ if not (eq .Params.categories "稻草人周刊") }}
+ <li class="flex gap-4 text-size-lg">
+ <span class="text-size-xs h-5 font-mono text-secondary flex-shrink-0
+ inline-block border-1 border-solid border-t-5 px-1
+ border-neutral-200 dark:border-neutral-700">
+ {{ .Date.Format "02" }}
+ </span>
+ <a href="{{ .RelPermalink }}">
+ {{ .Title }}{{ with .Params.subtitle }}:<span class="text-secondary">{{. }}</span>
+ {{ end }}
+ </a>
+ </li>
+ {{ end }}
{{ end }}
</ul>
- </details>
+ </div>
{{ $remainingMonthsToOpen = sub $remainingMonthsToOpen 1 }}
{{ end }}
</section>