summaryrefslogtreecommitdiff
path: root/layouts
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 /layouts
parent4c04d9c5bfd031d3966856f55f0d7e3f6d8a25f7 (diff)
feat: add featured post section
Former-commit-id: ab6318704c4a5f22793fb738662bb2201fa89082
Diffstat (limited to 'layouts')
-rw-r--r--layouts/_default/featured.html44
-rw-r--r--layouts/partials/components/postnav.html3
2 files changed, 47 insertions, 0 deletions
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>