summaryrefslogtreecommitdiff
path: root/layouts/posts
diff options
context:
space:
mode:
authorEltrac <hi@guhub.cn>2025-04-18 14:40:33 +0800
committerEltrac <hi@guhub.cn>2025-04-18 14:40:33 +0800
commit4f0ebaeed13c1c44c7d7c5778b187b69f5849552 (patch)
treed8faa11058a2d73128bd20a08294562202963a3e /layouts/posts
parent74ac7cc4e0104cd4953a0df305815f1260596cca (diff)
refactor: separate post single template and page template
Diffstat (limited to 'layouts/posts')
-rw-r--r--layouts/posts/single.html73
1 files changed, 73 insertions, 0 deletions
diff --git a/layouts/posts/single.html b/layouts/posts/single.html
new file mode 100644
index 00000000..525db84d
--- /dev/null
+++ b/layouts/posts/single.html
@@ -0,0 +1,73 @@
+{{ define "main" }}
+ {{ partial "components/post-page-header.html" . }}
+ <article
+ class="post {{ .Site.Language.LanguageName }}"
+ id="article"
+ >
+ <!-- Post Header -->
+ <header
+ style="view-transition-name: post-{{ .File.UniqueID }}"
+ class="post-header"
+ >
+ {{ partial "components/banner.html" . }}
+ <!-- Title and Subtitle -->
+ <h1 class="post-title">
+ {{ .Title }}
+ {{ with .Params.subtitle }}
+ <small class="post-subtitle">{{ . }}</small>
+ {{ end }}
+ </h1>
+ <!-- Post Meta -->
+ <div class="post-meta">
+ {{ if .Date }}
+ <time class="post-date" datetime="{{ .Date.Format "2006-01-02 15:04:05 MST" }}">
+ {{ .Date.Format "2006-1-2" }}
+ </time>
+ {{ end }}
+ <span>·</span>
+ {{ if .Params.categories }}
+ <a class="post-category" href="/categories/{{ .Params.categories | urlize }}">{{ .Params.categories }}</a>
+ {{ end }}
+ {{ range .Params.tags }}
+ <a class="post-tag" href="{{ site.LanguagePrefix }}/tags/{{ lower . | urlize }}/">#{{ . }}</a>
+ {{ end }}
+ </div>
+ </header>
+
+ <!-- Post Content -->
+ <div id="post-content" class="post-content markdown-body"
+ style="view-transition-name: post-content-{{ .File.UniqueID }}">
+ {{ if .Params.toc }}
+ <div id="toc-container"><div id="toc"></div></div>
+ {{ end }}
+ {{ .Site.Params.postHeaderContent | safeHTML }}
+ {{ .Content }}
+ {{ if eq .Site.Language.Lang "zh" }}
+ <p style="font-size: 0.9rem">如果你觉得文章对你有帮助,可以考虑<a href="/sponsor">赞助作者</a></p>
+ {{ end }}
+ </div>
+
+ {{ partial "components/comment.html" . }}
+
+ {{ with site.RegularPages.Related . | first 5 }}
+ <p>{{ T "relatedContent" }}</p>
+ <ul>
+ {{ range . }}
+ <li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
+ {{ end }}
+ </ul>
+ {{ end }}
+
+ <script src="/js/tocbot.min.js"></script>
+ <script>
+ tocbot.init({
+ tocSelector: '#toc',
+ contentSelector: '#post-content',
+ headingSelector: 'h2, h3:not(blockquote > h3)',
+ hasInnerContainers: true,
+ scrollSmoothOffset: -30
+ });
+ </script>
+
+ </article>
+{{ end }}