summaryrefslogtreecommitdiff
path: root/layouts
diff options
context:
space:
mode:
authorEltrac <hi@guhub.cn>2025-01-08 21:04:05 +0800
committerEltrac <hi@guhub.cn>2025-01-08 21:04:05 +0800
commitd74000f7429d6ce34b2a44a65b6551e2fbdb4bfb (patch)
tree521562cb329bf2e67f493fa1277bf811686ca5d5 /layouts
parentf65bb671b84fd9522ae21dc695911addd0db3bed (diff)
feat(theme): new header in index page
Diffstat (limited to 'layouts')
-rw-r--r--layouts/index.html50
1 files changed, 50 insertions, 0 deletions
diff --git a/layouts/index.html b/layouts/index.html
index eddfebb9..6db229d0 100644
--- a/layouts/index.html
+++ b/layouts/index.html
@@ -1,6 +1,56 @@
{{ partial "snippets/document-start.html" . }}
<article class="posts">
{{ partial "header.html" . }}
+
+
+ <header id="posts-header">
+ <div id="post-series">
+ <h1>专栏</h1>
+ <div id="post-series-list">
+ {{ range .Site.Params.series }}
+ <a class="post-series-item"
+ href="{{ .link }}"
+ title="{{ .description }}"
+ data-umami-event="Click series link from index"
+ >
+ <div class="post-series-cover">
+ <img src="{{ .cover }}" />
+ </div>
+ <div class="post-series-text">
+ <h3>{{ .name }}</h3>
+ </div>
+ </a>
+ {{ end }}
+ </div>
+ </div>
+ <div id="posts-recommendation">
+ <h1>欢迎</h1>
+ <script>
+ const posts = [
+ {{ range site.RegularPages }}
+ "{{ .RelPermalink }}",
+ {{ end }}
+ ];
+
+ function getRandomPost() {
+ const randomPostLink = document.getElementById("random-post-link")
+ const randomIndex = Math.floor(Math.random() * posts.length);
+ randomPostLink.href = posts[randomIndex];
+ }
+ getRandomPost()
+ </script>
+ <div id="posts-recommendation-links">
+ <a class="button" id="random-post-link"
+ onclick="getRandomPost()"
+ >🎲 随机文章</a>
+ <a class="button" href="https://www.travellings.cn/go.html"
+ target="_blank">🚇 开往</a>
+ <a class="button" href="https://www.guhub.cn/"
+ target="_blank">🏠 我的主页</a>
+ </div>
+ </div>
+ </header>
+
<div id="posts-list">
{{ $currentYear := now.Format "2006" }} <!-- 获取当前年份 -->