diff options
| author | eltrac <hi@eltr.ac> | 2026-02-15 10:43:44 +0800 |
|---|---|---|
| committer | eltrac <hi@eltr.ac> | 2026-02-15 10:43:44 +0800 |
| commit | d924553ced6983a1983409c9e9ebd8e0bb4b1cc5 (patch) | |
| tree | 36e45e1b2fe3c41f4d7aeda618fe94731f64ee44 | |
| parent | e9d93b7514c94228d129046669a6e1a1b6b5e0b7 (diff) | |
feat: reimagined tags page
also, i brought `all-tags` back. it's better to divide huge pages into
reusable partials anyway.
pagefind was also moved into an individual partial.
| -rw-r--r-- | config/_default/params.zh.toml | 4 | ||||
| -rw-r--r-- | content/tags/_index.md | 7 | ||||
| -rw-r--r-- | layouts/_partials/taxonomy/all-tags.html | 46 | ||||
| -rw-r--r-- | layouts/_partials/taxonomy/pagefind.html | 7 | ||||
| -rw-r--r-- | layouts/tags/taxonomy.html | 55 | ||||
| -rw-r--r-- | layouts/taxonomy.html | 22 |
6 files changed, 78 insertions, 63 deletions
diff --git a/config/_default/params.zh.toml b/config/_default/params.zh.toml index 0045fd28..6dadbb7f 100644 --- a/config/_default/params.zh.toml +++ b/config/_default/params.zh.toml @@ -1,6 +1,10 @@ description = "欢迎来访,这里只有真情流露和赤裸的思考。" [[nav]] +name = "切行" +link = "/tags/" + +[[nav]] name = "搜寻" link = "/categories/" diff --git a/content/tags/_index.md b/content/tags/_index.md index 40362fd3..c18eaa5f 100644 --- a/content/tags/_index.md +++ b/content/tags/_index.md @@ -1,3 +1,8 @@ --- -title: 标签 +title: 切入与切出 --- + +在电子游戏中,程序员使用名为「Clipping」的编程模式,来保证玩家保持在游戏世界中的物理屏障上,而所谓的「穿模」和「穿墙」,就被称作「No-clip」。在 [Backrooms](https://backrooms-wiki-cn.wikidot.com/) 社区,这个概念被译作「切行」。 + +我把内容网站的标签当成「切面」,在一个切面上你能透过时间线、文章系列等连贯的空间结构,窥探具有相同主题的文本。所以,如果你想的话,就在下面这些链接中切入到你感兴趣的切面上吧。 + diff --git a/layouts/_partials/taxonomy/all-tags.html b/layouts/_partials/taxonomy/all-tags.html new file mode 100644 index 00000000..efd63fb4 --- /dev/null +++ b/layouts/_partials/taxonomy/all-tags.html @@ -0,0 +1,46 @@ +<!-- Display Tags --> +<section> + {{ $categorizedTags := dict }} + {{ $uncategorizedTags := slice }} + + <!-- Group tags by category --> + {{ range $tagName, $tagPages := .Site.Taxonomies.tags }} + {{ $tagPage := site.GetPage (printf "/tags/%s" $tagName) }} + {{ $tagData := dict "Name" $tagName "Count" (len $tagPages) "Page" $tagPage }} + {{ if $tagPage.Params.category }} + {{ $category := $tagPage.Params.category }} + {{ $categoryTags := index $categorizedTags $category | default slice }} + {{ $categoryTags = $categoryTags | append $tagData }} + {{ $categorizedTags = merge $categorizedTags (dict $category $categoryTags) }} + {{ else }} + {{ $uncategorizedTags = $uncategorizedTags | append $tagData }} + {{ end }} + {{ end }} + + <!-- Sort tags by count --> + {{ $uncategorizedTags = sort $uncategorizedTags "Count" "desc" }} + {{ range $category, $categoryTags := $categorizedTags }} + {{ $categorizedTags = merge $categorizedTags (dict $category (sort $categoryTags "Count" "desc")) }} + {{ end }} + + <!-- Display uncategorized tags first --> + {{ if $uncategorizedTags }} + <div class="flex flex-wrap gap-2"> + {{ range $uncategorizedTags }} + {{ partial "taxonomy/tag-pill" . }} + {{ end }} + </div> + {{ end }} + + <!-- Display categorized tags --> + {{ range $category, $categoryTags := $categorizedTags }} + <div> + <h3>{{ $category }}</h3> + <div class="flex flex-wrap gap-2"> + {{ range $categoryTags }} + {{ partial "taxonomy/tag-pill" . }} + {{ end }} + </div> + </div> + {{ end }} +</section> diff --git a/layouts/_partials/taxonomy/pagefind.html b/layouts/_partials/taxonomy/pagefind.html new file mode 100644 index 00000000..2c41457d --- /dev/null +++ b/layouts/_partials/taxonomy/pagefind.html @@ -0,0 +1,7 @@ +<div id="pagefind" class="py-3"></div> +<script src="/pagefind/pagefind-ui.js"></script> +<script> + window.addEventListener('DOMContentLoaded', () => { + new PagefindUI({ element: "#pagefind", showSubResults: true }); + }); +</script> diff --git a/layouts/tags/taxonomy.html b/layouts/tags/taxonomy.html index 633e9c09..a0c38a40 100644 --- a/layouts/tags/taxonomy.html +++ b/layouts/tags/taxonomy.html @@ -1,51 +1,14 @@ {{ define "main" }} <article> {{ partial "header" . }} - <!-- Display Tags --> - <section> - {{ $categorizedTags := dict }} - {{ $uncategorizedTags := slice }} - - <!-- Group tags by category --> - {{ range $tagName, $tagPages := .Site.Taxonomies.tags }} - {{ $tagPage := site.GetPage (printf "/tags/%s" $tagName) }} - {{ $tagData := dict "Name" $tagName "Count" (len $tagPages) "Page" $tagPage }} - {{ if $tagPage.Params.category }} - {{ $category := $tagPage.Params.category }} - {{ $categoryTags := index $categorizedTags $category | default slice }} - {{ $categoryTags = $categoryTags | append $tagData }} - {{ $categorizedTags = merge $categorizedTags (dict $category $categoryTags) }} - {{ else }} - {{ $uncategorizedTags = $uncategorizedTags | append $tagData }} - {{ end }} - {{ end }} - - <!-- Sort tags by count --> - {{ $uncategorizedTags = sort $uncategorizedTags "Count" "desc" }} - {{ range $category, $categoryTags := $categorizedTags }} - {{ $categorizedTags = merge $categorizedTags (dict $category (sort $categoryTags "Count" "desc")) }} - {{ end }} - - <!-- Display uncategorized tags first --> - {{ if $uncategorizedTags }} - <div class="flex flex-wrap gap-2"> - {{ range $uncategorizedTags }} - {{ partial "taxonomy/tag-pill" . }} - {{ end }} - </div> - {{ end }} - - <!-- Display categorized tags --> - {{ range $category, $categoryTags := $categorizedTags }} - <div> - <h3>{{ $category }}</h3> - <div class="flex flex-wrap gap-2"> - {{ range $categoryTags }} - {{ partial "taxonomy/tag-pill" . }} - {{ end }} - </div> - </div> - {{ end }} - </section> + <div class="post-content markdown-body text-size-md md:text-size-lg leading-loose"> + {{ partial "utils/render" .Content }} + </div> + <h2>切面</h2> + {{ partial "taxonomy/all-tags" . }} + <hr /> + <h2>开始速切!</h2> + <p class="text-secondary text-sm">快速切换到你想去的地方。</p> + {{ partial "taxonomy/pagefind" . }} {{ partial "footer.html" . }} {{ end }} diff --git a/layouts/taxonomy.html b/layouts/taxonomy.html index c44dc18a..4a93e1cb 100644 --- a/layouts/taxonomy.html +++ b/layouts/taxonomy.html @@ -1,18 +1,8 @@ {{ define "main" }} -<article> - {{ partial "header" . }} - - <div id="pagefind" class="py-3"></div> - - <h2>文章系列</h2> - {{ partial "taxonomy/all-categories.html" . }} -</article> - -<script src="/pagefind/pagefind-ui.js"></script> -<script> - window.addEventListener('DOMContentLoaded', () => { - new PagefindUI({ element: "#pagefind", showSubResults: true }); - }); -</script> -{{ partial "footer.html" . }} + <article> + {{ partial "header" . }} + <h2>文章系列</h2> + {{ partial "taxonomy/all-categories.html" . }} + </article> + {{ partial "footer.html" . }} {{ end }} |
