summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEltrac <hi@guhub.cn>2025-05-16 15:21:10 +0800
committerEltrac <hi@guhub.cn>2025-05-16 15:21:10 +0800
commit90e305c8addbb3f814e219633e9b3d75c2d921da (patch)
treecc5a087f948460f27c60c1101b43131451321dc3
parent4c04d9c5bfd031d3966856f55f0d7e3f6d8a25f7 (diff)
feat: add featured post section
Former-commit-id: ab6318704c4a5f22793fb738662bb2201fa89082
-rw-r--r--content/featured.md4
-rw-r--r--i18n/en.yml1
-rw-r--r--i18n/zh.yml1
-rw-r--r--layouts/_default/featured.html44
-rw-r--r--layouts/partials/components/postnav.html3
5 files changed, 53 insertions, 0 deletions
diff --git a/content/featured.md b/content/featured.md
new file mode 100644
index 00000000..37964861
--- /dev/null
+++ b/content/featured.md
@@ -0,0 +1,4 @@
+---
+title: 精选
+layout: featured
+---
diff --git a/i18n/en.yml b/i18n/en.yml
index 6427bc96..5e6a266e 100644
--- a/i18n/en.yml
+++ b/i18n/en.yml
@@ -14,6 +14,7 @@ postNav:
latest: 'Latest'
categories: 'Categories'
tags: 'Tags'
+ featured: 'Featured'
moreLinks:
posts: 'All Posts'
cards: 'All Cards'
diff --git a/i18n/zh.yml b/i18n/zh.yml
index c5099c93..8e3c7e72 100644
--- a/i18n/zh.yml
+++ b/i18n/zh.yml
@@ -14,6 +14,7 @@ postNav:
latest: '最新'
categories: '专栏'
tags: '标签'
+ featured: '精选'
cards: 最近在学
moreLinks:
posts: '所有文章'
diff --git a/layouts/_default/featured.html b/layouts/_default/featured.html
new file mode 100644
index 00000000..f1484bcb
--- /dev/null
+++ b/layouts/_default/featured.html
@@ -0,0 +1,44 @@
+{{ define "main" }}
+ <article class="index">
+ {{ partial "header.html" . }}
+ {{ partial "components/postnav.html" . }}
+
+ <!-- Latest Posts -->
+ <section id="featured-posts">
+ <div class="posts-list">
+ {{ range where site.RegularPages "Params.featured" true }}
+ <div class="posts-item"
+ style="view-transition-name: post-{{ .File.UniqueID }}">
+ <header>
+ <div class="posts-item-meta">
+ <time>
+ {{ .Date.Format "Jan 2" }}
+ </time>
+ <h2 class="posts-item-title">
+ <a
+ href="{{ .Permalink }}"
+ data-umami-event="Click post link from featured"
+ >
+ {{ if eq .Section "library" }}
+ 读《{{ .Title }}》
+ {{ else }}
+ {{ .Title }}
+ {{ end }}
+ </a>
+ </h2>
+ </div>
+ {{ with .Params.categories }}
+ <div class="posts-item-category">
+ <a href="/categories/{{ . }}" style="padding: 0.1rem 0.3rem;">
+ {{ . }}
+ </a>
+ </div>
+ {{ end }}
+ </header>
+ </div>
+ {{ end }}
+ </div>
+ </section>
+ </article>
+{{ partial "footer.html" . }}
+{{ end }}
diff --git a/layouts/partials/components/postnav.html b/layouts/partials/components/postnav.html
index 95f38a72..5a00797c 100644
--- a/layouts/partials/components/postnav.html
+++ b/layouts/partials/components/postnav.html
@@ -4,6 +4,9 @@
<a href="{{ .Site.LanguagePrefix }}/">{{ T "postNav.latest" }}</a>
</li>
{{ if eq .Site.Language.Lang "zh" }}
+ <li class="{{ if eq "/featured" $.Page.RelPermalink }}active{{ end }}">
+ <a href="{{ .Site.LanguagePrefix }}/featured">{{ T "postNav.featured" }}</a>
+ </li>
<li class="{{ if eq "/categories/" $.Page.RelPermalink }}active{{ end }}">
<a href="{{ .Site.LanguagePrefix }}/categories">{{ T "postNav.categories" }}</a>
</li>