aboutsummaryrefslogtreecommitdiffstats
path: root/layouts
diff options
context:
space:
mode:
authorverdant <im@verdant.ee>2026-05-31 16:33:36 +0800
committerverdant <im@verdant.ee>2026-05-31 16:33:36 +0800
commit172adfb014596423d7cc3043f2a288ac01884cba (patch)
treef788b0b10f330daf8c3a6d1a8ed656a1d1253390 /layouts
parentf9869a2cf060976c69aeade3d3f231bf1fbdddd3 (diff)
downloadblog-172adfb014596423d7cc3043f2a288ac01884cba.tar.gz
blog-172adfb014596423d7cc3043f2a288ac01884cba.zip
Add minify configuration, modify favicon url
Diffstat (limited to 'layouts')
-rw-r--r--layouts/_default/#baseof.html#29
l---------layouts/_default/.#baseof.html1
-rw-r--r--layouts/_default/baseof.html2
-rw-r--r--layouts/_default/list.html44
-rw-r--r--layouts/_default/single.html369
-rw-r--r--layouts/archives/single.html46
-rw-r--r--layouts/partials/footer.html37
-rw-r--r--layouts/partials/nav.html2
-rw-r--r--layouts/partials/seo_tags.html6
-rw-r--r--layouts/shortcodes/recent-posts.html128
10 files changed, 86 insertions, 578 deletions
diff --git a/layouts/_default/#baseof.html# b/layouts/_default/#baseof.html#
new file mode 100644
index 0000000..a6224e8
--- /dev/null
+++ b/layouts/_default/#baseof.html#
@@ -0,0 +1,29 @@
+<!doctype html>
+<html lang="{{ with .Site.LanguageCode }}{{ . }}{{ else }}en-US{{ end }}">
+ <head>
+ <!-- <link rel="stylesheet" href="/css/style.css" /> -->
+ <link rel="stylesheet" href="/css/style.css" />
+ <meta http-equiv="X-Clacks-Overhead" content="GNU Terry Pratchett" />
+ <meta charset="utf-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ {{- partial "favicon.html" . -}}
+ <title>{{ .Title }}</title>
+
+ {{- partial "seo_tags.html" . -}}
+ <meta name="referrer" content="no-referrer-when-downgrade" />
+ <link rel="alternate" type="application/rss+xml" href="/atom.xml" title="{{ .Site.Title }}">
+
+ {{ with .OutputFormats.Get "rss" -}} {{ printf `
+ <link rel="%s" type="%s" href="%s" title="%s" />
+ ` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }} {{ end -}}
+
+ {{- partial "custom_head.html" . -}}
+ </head>
+
+ <body>
+ <main>{{- block "main" . }}{{- end }}</main>
+ <footer>{{- partial "footer.html" . -}}</footer>
+
+ {{- partial "custom_body.html" . -}}
+ </body>
+</html>
diff --git a/layouts/_default/.#baseof.html b/layouts/_default/.#baseof.html
new file mode 120000
index 0000000..c37d2f8
--- /dev/null
+++ b/layouts/_default/.#baseof.html
@@ -0,0 +1 @@
+verdant@glowisle.178751:1780072799 \ No newline at end of file
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html
index dd29a6b..54fa756 100644
--- a/layouts/_default/baseof.html
+++ b/layouts/_default/baseof.html
@@ -11,7 +11,9 @@
{{- partial "seo_tags.html" . -}}
<meta name="referrer" content="no-referrer-when-downgrade" />
+ <link rel="alternate" type="application/rss+xml" href="/atom.xml" title="{{ .Site.Title }}">
+
{{ with .OutputFormats.Get "rss" -}} {{ printf `
<link rel="%s" type="%s" href="%s" title="%s" />
` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }} {{ end -}}
diff --git a/layouts/_default/list.html b/layouts/_default/list.html
index 8c1db86..3992a01 100644
--- a/layouts/_default/list.html
+++ b/layouts/_default/list.html
@@ -1,50 +1,6 @@
{{ define "main" }}
<content>
- {{ if .Site.Params.postSearch }}
- <input
- id="search-input"
- type="text"
- placeholder="Search..."
- style="margin-top: 16px"
- />
- <script>
- // 等待 DOM 完全加载后执行
- document.addEventListener('DOMContentLoaded', function () {
- // 缓存 DOM 元素
- const searchInput = document.getElementById('search-input');
- const posts = document.querySelectorAll('.blog-posts li');
- const years = document.querySelectorAll('.blog-posts h3');
- // 更新搜索结果
- function updateSearchResults(searchTerm) {
- let visiblePosts = 0;
- const displayedYears = new Set();
- posts.forEach(function (post) {
- const title = post.querySelector('a').textContent.toLowerCase();
- const year = post.querySelector('time').getAttribute('datetime').split('-')[0];
- if (title.includes(searchTerm)) {
- post.style.display = '';
- visiblePosts++;
- displayedYears.add(year);
- } else {
- post.style.display = 'none';
- }
- });
-
- {{ if .Site.Params.groupByYear }}
- years.forEach(function (y) {
- const year = y.textContent;
- y.style.display = displayedYears.has(year) ? '' : 'none';
- });
- {{ end }}
- }
-
- searchInput.addEventListener('input', function () {
- updateSearchResults(this.value.toLowerCase().trim());
- });
- });
- </script>
- {{ end }}
<ul class="blog-posts">
{{ $currentYear := 0 }} {{ range .Pages }} {{ if and (not .Params.hidden)
(not (in .Params.categories "往昔")) }}
diff --git a/layouts/_default/single.html b/layouts/_default/single.html
index 9ec00f3..3006c56 100644
--- a/layouts/_default/single.html
+++ b/layouts/_default/single.html
@@ -1,355 +1,40 @@
{{ define "main" }}
-<header>
-<a href="{{ "" | relURL }}" class="title">
- <p class="site-title">{{ .Site.Title }}</p>
-</a>
-<nav>{{- partial "nav.html" . -}}</nav>
+<header class="post-header">
+ <span class="site-title"><a href="{{ "" | relURL }}">{{ .Site.Title }}</a></span>
+ <nav>{{- partial "nav.html" . -}}</nav>
</header>
-
-<style>
-/* 底部声明区 */
-.h-entry ~ .info,
-.h-entry ~ div:last-of-type {
- margin-top: 2rem;
- padding-top: 1rem;
- font-size: 0.85rem;
- line-height: 1.6;
- color: var(--summary-text-color);
- font-family: var(--font-secondary);
-}
-
-.h-entry ~ .info p,
-.h-entry ~ div:last-of-type p {
- margin: 0.4rem 0;
-}
-
-</style>
+<hr>
<article class="h-entry">
-<h1 class="post-title">
- <a href="{{ .RelPermalink }}" class="item-link">{{ .Title }}</a>
-</h1>
-
-<div class="post-meta">
- <div class="post-meta-item post-date">
- <time class="dt-published" datetime="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}">
- {{ .Date.Format "January 02, 2006" }}
- </time>
+ <header class="entry-meta">
+ <h1 class="p-name post-title">{{ .Title }}</h1>
+ <div class="meta-line">
+ <time class="dt-published" datetime="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}">
+ {{ .Date.Format "2006-01-02" }}
+ </time>
+
+ {{ with .Params.categories }}
+ <span class="meta-categories">
+ [{{ range $index, $cat := . }}{{ if $index }} · {{ end }}<a href="/categories/{{ $cat | urlize }}/" class="p-category">{{ $cat }}</a>{{ end }}]
+ </span>
+ {{ end }}
+ </div>
+ </header>
+
+ <div class="e-content entry-body">
+ {{ .Content }}
</div>
-
- <div class="post-meta-item post-category">
-
- {{ range .Params.categories }}
- {{ $url := printf "/categories/%s/" (. | urlize) }}
-•
- <a href="{{ $url }}" class="category-link">{{ . }}</a>
- {{ end }}
- </div>
-</div>
-
-
- <div class="e-content">{{ .Content }}</div>
</article>
-<a class="u-url" href="{{ .Permalink }}" style="display: none">Permalink</a>
<hr>
-{{ partial "post_meta.html" . }}
-
-{{ $upvoteEnabled := default .Site.Params.upvote .Params.upvote }}
-{{ if $upvoteEnabled }}
-<div class="upvote-container">
-<small class="upvote">
- <button class="upvote-btn" id="upvote-btn">
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round" class="css-i6dzq1">
- <polyline points="17 11 12 6 7 11"></polyline>
- <polyline points="17 18 12 13 7 18"></polyline>
- </svg>
- <span class="upvote-count" id="upvote-count">0</span>
- </button>
-</small>
-</div>
-
-<script>
- let hasUpvoted = false;
- let upvoteBtn;
- let upvoteCount;
-
- // 页面加载时获取点赞数量
- document.addEventListener('DOMContentLoaded', function() {
- const slug = '{{ .Slug }}';
- upvoteBtn = document.getElementById('upvote-btn');
- upvoteCount = document.getElementById('upvote-count');
- getCount(slug);
-
- // 处理点赞按钮的点击事件
- upvoteBtn.addEventListener('click', handleUpvote);
- });
-
- // 点赞方法
- async function handleUpvote() {
- if (hasUpvoted) {
- console.log('You have already upvoted this post!');
- return;
- }
- const slug = '{{ .Slug }}';
-
- // 禁用按钮以防止重复点击
- upvoteBtn.disabled = true;
- // 给按钮添加 upvoted 类以赋以点击过的样式
- upvoteBtn.classList.add('upvoted');
- // 更新 upvote-count 的值 +1
- upvoteCount.innerText = parseInt(upvoteCount.innerText) + 1;
-
- try {
- const response = await fetch('{{ .Site.Params.upvoteURL }}upvote', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify({ postId: slug, diff: 1 }),
- });
-
- if (response.ok) {
- console.log('Upvote successful!');
- hasUpvoted = true;
- await getCount(slug, 3);
- } else {
- console.log('Upvote failed!');
- }
- } catch (error) {
- console.error('Error: ', error);
- } finally {
- upvoteBtn.disabled = false;
- }
- }
-
- // 获取 Upvote 数量的方法,支持设置重试次数,默认不重试
- async function getCount(slug, retryCount = 0) {
- try {
- const response = await fetch('{{ .Site.Params.upvoteURL }}count?post=' + slug, {
- method: 'GET',
- headers: {
- 'Content-Type': 'application/json',
- },
- });
-
- const data = await response.json();
-
- if (data.code === 0) {
- const count = data.data.count;
- upvoteCount.innerText = count;
- hasUpvoted = data.data.hasUpvoted;
- if (hasUpvoted) {
- upvoteBtn.classList.add('upvoted');
- } else {
- upvoteBtn.classList.remove('upvoted');
- }
- } else {
- console.error('Failed to get upvote count: ', data.msg);
- }
- } catch (error) {
- console.error('Error: ', error);
- if (retryCount > 0) {
- setTimeout(() => {
- getCount(slug, retryCount - 1);
- }, 1000);
- }
- }
- }
-</script>
-{{ end }}
-
-
-
-<!-- Place the TOC at the end to ensure the article content loads first. -->
-<!-- {{ $tocEnabled := default .Site.Params.toc .Params.toc }} {{ if $tocEnabled }} -->
-<!-- <div class="toc">{{ partial "toc.html" . }}</div> -->
-<!-- {{ end }} -->
-
-<!-- {{ if .Params.comments | default true }} -->
-<!-- <div class="comments-and-webmentions"> -->
-<!-- <details> -->
-<!-- <summary> -->
-<!-- <p style="display: inline">评论 与 Webmentions</p> -->
-<!-- </summary> -->
-<!-- <div id="giscus-container"></div> -->
-
-<!-- <div class="wm"> -->
-<!-- <div id="webmentions"></div> -->
-<!-- <script -->
-<!-- src="/js/webmention.min.js" -->
-<!-- data-id="webmentions" -->
-<!-- data-page-url="https://www.glowisle.me{{ .RelPermalink }}" -->
-<!-- data-max-webmentions="50" -->
-<!-- data-wordcount="30" -->
-<!-- data-sort-by="published" -->
-<!-- data-sort-dir="up" -->
-<!-- async -->
-<!-- ></script> -->
-
-<!-- <p> -->
-<!-- 若想回复本文,请在你的博客或社媒发布含有本文链接的帖子,然后在下方表单提交链接。 -->
-<!-- </p> -->
-<!-- <div class="wm-guide-content"> -->
-<!-- <div class="webmention-form"> -->
-<!-- <form -->
-<!-- id="webmention-submit-form" -->
-<!-- action="https://webmention.io/www.glowisle.me/webmention" -->
-<!-- method="post" -->
-<!-- > -->
-<!-- <\!-- 自动填充的目标文章链接 -\-> -->
-<!-- <input -->
-<!-- type="hidden" -->
-<!-- name="target" -->
-<!-- value="https://www.glowisle.me{{ .RelPermalink }}" -->
-<!-- /> -->
-<!-- <div> -->
-<!-- <label for="webmention-source">你的文章链接:</label> -->
-<!-- <input -->
-<!-- type="url" -->
-<!-- id="webmention-source" -->
-<!-- name="source" -->
-<!-- required -->
-<!-- pattern="https?://.+" -->
-<!-- /> -->
-<!-- <button type="submit" id="webmention-submit-btn">提交</button> -->
-<!-- </div> -->
-<!-- <div id="webmention-form-feedback"></div> -->
-<!-- </form> -->
-<!-- <p> -->
-<!-- 也可以<a href="mailto:i@glowisle.me?subject=回复《{{ .Title }}》">发送邮件</a>评论。 -->
-<!-- </p> -->
-<!-- <a href="https://indieweb.org/webmention" -->
-<!-- >关于 Webmention 的更多信息</a -->
-<!-- > -->
-<!-- 以及 -->
-<!-- <a href="https://www.glowisle.me/posts/tear-hypocrisy-apart/" -->
-<!-- >为什么要这么做?</a -->
-<!-- > -->
-<!-- </div> -->
-
-<!-- <script> -->
-<!-- function getInitialTheme() { -->
-<!-- // 1. 优先检查 localStorage 中的用户偏好 -->
-<!-- if ( -->
-<!-- typeof localStorage !== "undefined" && -->
-<!-- localStorage.getItem("theme") -->
-<!-- ) { -->
-<!-- return localStorage.getItem("theme"); -->
-<!-- } -->
-<!-- // 2. 检查系统偏好 -->
-<!-- if (window.matchMedia("(prefers-color-scheme: dark)").matches) { -->
-<!-- return "dark"; -->
-<!-- } -->
-<!-- // 3. 默认值 -->
-<!-- return "light"; -->
-<!-- } -->
-
-<!-- const currentTheme = getInitialTheme(); -->
-<!-- const giscusTheme = currentTheme === "dark" ? "dark" : "light"; -->
-
-<!-- const giscusScript = document.createElement("script"); -->
-<!-- giscusScript.src = "https://giscus.app/client.js"; -->
-<!-- giscusScript.setAttribute( -->
-<!-- "data-repo", -->
-<!-- "yingyu5658/yingyu5658.github.io", -->
-<!-- ); -->
-<!-- giscusScript.setAttribute("data-repo-id", "R_kgDOOBetsA"); -->
-<!-- giscusScript.setAttribute("data-category", "Announcements"); -->
-<!-- giscusScript.setAttribute("data-category-id", "DIC_kwDOOBetsM4CoF_Z"); -->
-<!-- giscusScript.setAttribute("data-mapping", "title"); -->
-<!-- giscusScript.setAttribute("data-strict", "0"); -->
-<!-- giscusScript.setAttribute("data-reactions-enabled", "0"); -->
-<!-- giscusScript.setAttribute("data-emit-metadata", "0"); -->
-<!-- giscusScript.setAttribute("data-input-position", "bottom"); -->
-<!-- giscusScript.setAttribute("data-theme", giscusTheme); -->
-<!-- giscusScript.setAttribute("data-lang", "zh-CN"); -->
-<!-- giscusScript.crossOrigin = "anonymous"; -->
-<!-- giscusScript.async = true; -->
-
-<!-- document.getElementById("giscus-container").appendChild(giscusScript); -->
-
-<!-- document.addEventListener("DOMContentLoaded", function () { -->
-<!-- const form = document.getElementById("webmention-submit-form"); -->
-<!-- const submitBtn = document.getElementById("webmention-submit-btn"); -->
-<!-- const feedbackEl = document.getElementById( -->
-<!-- "webmention-form-feedback", -->
-<!-- ); -->
-
-<!-- if (!form) return; -->
-
-<!-- form.addEventListener("submit", async function (e) { -->
-<!-- e.preventDefault(); -->
-
-<!-- // 禁用提交按钮防止重复提交 -->
-<!-- const originalBtnText = submitBtn.textContent; -->
-<!-- submitBtn.disabled = true; -->
-<!-- submitBtn.textContent = "发送中..."; -->
-
-<!-- // 清除之前的反馈信息 -->
-<!-- feedbackEl.textContent = ""; -->
-
-<!-- try { -->
-<!-- // 使用 FormData 收集表单数据 -->
-<!-- const formData = new FormData(form); -->
-
-<!-- // 发送 POST 请求 -->
-<!-- const response = await fetch(form.action, { -->
-<!-- method: "POST", -->
-<!-- headers: { -->
-<!-- Accept: "application/json", -->
-<!-- }, -->
-<!-- body: new URLSearchParams(formData), -->
-<!-- }); -->
-
-<!-- const result = await response.json(); -->
-
-<!-- if (response.ok) { -->
-<!-- // 成功响应 -->
-<!-- feedbackEl.textContent = -->
-<!-- "✅ 提交成功!Webmention 正在处理中。"; -->
-<!-- form.reset(); -->
-<!-- } else { -->
-<!-- // 错误响应 -->
-<!-- let errorMsg = "提交失败:"; -->
-<!-- if (result.error || result.summary) { -->
-<!-- errorMsg += result.error || result.summary; -->
-<!-- } -->
-<!-- feedbackEl.textContent = errorMsg; -->
-<!-- } -->
-<!-- } catch (error) { -->
-<!-- // 网络错误 -->
-<!-- feedbackEl.textContent = -->
-<!-- "❌ 提交过程中出现网络错误,请稍后重试。"; -->
-<!-- } finally { -->
-<!-- // 恢复提交按钮状态 -->
-<!-- submitBtn.disabled = false; -->
-<!-- submitBtn.textContent = originalBtnText; -->
-<!-- } -->
-<!-- }); -->
-<!-- }); -->
-<!-- </script> -->
-
-<!-- {{ end }} -->
-<!-- </div> -->
-<!-- </div> -->
-<!-- </details> -->
+<footer class="post-footer">
+ <div class="post-declaration">
+ <p>条目共享:遵循 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" rel="license noopener">CC BY-NC-SA 4.0</a> 协议。</p>
+ <p>交流通道:向 <a href="mailto:im@verdant.ee?subject=回复《{{ .Title }}》">im@verdant.ee</a> 发送一封 <a href="https://useplaintext.email/">纯文本邮件</a>。</p>
+ </div>
+</footer>
- {{ if not .Params.comments }}
- {{ with .Params.reason }}
- <div class="reason">
- <p>评论区已关闭。</p>
- <strong>{{ . | markdownify }}</strong>
- </div>
- {{ end }}
- {{ end }}
- <div class="info">
- <p>文章内容遵循 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/">CC BY-NC-SA 4.0</a> 标准共享。</p>
- <p>有想对我说的?向<a href="mailto:im@verdant.ee?subject=回复《{{ .Title }}》"> im@verdant.ee </a>发送一封<a href="https://useplaintext.email/
-">纯文本邮件</a>吧。</p>
- </div>
-</div>
{{ end }}
diff --git a/layouts/archives/single.html b/layouts/archives/single.html
index 60ec3e4..dc089ff 100644
--- a/layouts/archives/single.html
+++ b/layouts/archives/single.html
@@ -15,52 +15,6 @@
</small>
{{ end }}
- {{ if .Site.Params.postSearch }}
- <input id="search-input" type="text" placeholder="Search..." style="margin-top: 16px" />
- <script>
- // 等待 DOM 完全加载后执行
- document.addEventListener('DOMContentLoaded', function () {
- // 缓存 DOM 元素
- const searchInput = document.getElementById('search-input');
- const posts = document.querySelectorAll('.blog-posts li');
- const years = document.querySelectorAll('.blog-posts h3');
-
- // 更新搜索结果
- function updateSearchResults(searchTerm) {
- let visiblePosts = 0;
- const displayedYears = new Set();
- posts.forEach(function (post) {
- const title = post.querySelector('a').textContent.toLowerCase();
- const year = post.querySelector('time').getAttribute('datetime').split('-')[0];
- if (title.includes(searchTerm)) {
- post.style.display = '';
- visiblePosts++;
- displayedYears.add(year);
- } else {
- post.style.display = 'none';
- }
- });
-
- {{ if .Site.Params.groupByYear }}
- years.forEach(function (y) {
- const year = y.textContent;
- y.style.display = displayedYears.has(year) ? '' : 'none';
- });
- {{ end }}
-
- {{ if .Site.Params.showPostCount }}
- const countText = `There ${visiblePosts <= 1 ? `is ${visiblePosts} piece.` : `are ${visiblePosts} pieces.`}`;
- document.getElementById('post-count').innerHTML = countText;
- {{ end }}
- }
-
- searchInput.addEventListener('input', function () {
- updateSearchResults(this.value.toLowerCase().trim());
- });
- });
- </script>
- {{ end }}
-
{{ $allPosts := where .Site.RegularPages "Type" "eq" "posts" }}
{{ $excludePosts := where $allPosts "Params.categories" "intersect" (slice "1") }}
{{ $postPages := ($allPosts | complement $excludePosts) }}
diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html
index c5fe20b..a40be26 100644
--- a/layouts/partials/footer.html
+++ b/layouts/partials/footer.html
@@ -1,40 +1,3 @@
<div class="copyright">
{{ .Site.Params.footer.content | markdownify }}
- <div class="footer-item">
- | <button id="toggle-theme-btn">Dark/Light</button>
-
- </div>
-
</div>
-<script>
- console.log("Loaded")
- const modes = {
- Dark: "dark",
- Light: "light",
- }
-
- function getCurrentMode() {
- let mode = localStorage.getItem("theme");
- return mode === null ? null : mode;
- }
-
- const toggleColorSchemeBtn = document.getElementById("toggle-theme-btn");
- const body = document.body;
- const currentMode = getCurrentMode()
-
- if (currentMode === modes.Dark) {
- body.classList.toggle("dark-mode")
- }
-
-
- toggleColorSchemeBtn.addEventListener("click", () => {
- body.classList.toggle("dark-mode");
-
- if (body.classList.contains("dark-mode")) {
- localStorage.setItem("theme", modes.Dark);
- } else {
- localStorage.setItem("theme", modes.Light);
- }
- })
-
-</script>
diff --git a/layouts/partials/nav.html b/layouts/partials/nav.html
index 6eb8a7b..ad2f6d1 100644
--- a/layouts/partials/nav.html
+++ b/layouts/partials/nav.html
@@ -1,5 +1,5 @@
{{ range .Site.Menus.main }}
-<a href="{{ .URL }}">{{ .Name}}</a>
+[<a href="{{ .URL }}">{{ .Name }}</a>]
{{ end }}
{{ with .Site.GetPage "/blog" }}
<a href="{{ "blog/" | relURL }}">Blog</a>
diff --git a/layouts/partials/seo_tags.html b/layouts/partials/seo_tags.html
index 06e90cd..4f594fd 100644
--- a/layouts/partials/seo_tags.html
+++ b/layouts/partials/seo_tags.html
@@ -3,6 +3,12 @@
<meta name="description" content="{{ with .Description }}{{ . }}{{ else }}{{ if .IsPage }}{{ .Summary }}{{ else }}{{ with .Site.Params.Description }}{{ . }}{{ end }}{{ end }}{{ end }}" />
<meta name="keywords" content="{{ if .IsPage }}{{ range $index, $tag := .Params.tags }}{{ $tag }},{{ end }}{{ else }}{{ range $plural, $terms := .Site.Taxonomies }}{{ range $term, $val := $terms }}{{ printf "%s," $term }}{{ end }}{{ end }}{{ end }}" />
+<meta property="og:site_name" content="{{ .Site.Title }}">
+ <meta property="og:title" content="{{ if .IsHome }}{{ .Site.Title }}{{ else }}{{ .Title }}{{ end }}">
+ <meta property="og:url" content="{{ .Permalink }}">
+ <meta property="og:description" content="{{ if .Description }}{{ .Description }}{{ else }}{{ .Site.Params.Description }}{{ end }}">
+ <meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}">
+
<link rel="canonical" href="{{ .Permalink }}">
<!-- Open Graph / Facebook -->
diff --git a/layouts/shortcodes/recent-posts.html b/layouts/shortcodes/recent-posts.html
index e720d33..45e1958 100644
--- a/layouts/shortcodes/recent-posts.html
+++ b/layouts/shortcodes/recent-posts.html
@@ -1,113 +1,25 @@
-<!-- 1: 展示标题摘要;2:标题列表 -->
{{ $mode := 2 }}
-
{{ $pages := where site.RegularPages "Type" "in" site.Params.mainSections }}
-{{ $recent := first 20 $pages.ByDate.Reverse }}
-
-{{ if eq $mode 1 }}
-
-<style>
- .recent-list {
- list-style: none;
- margin: 0;
- padding: 0;
- }
-
- .recent-list li {
- margin-bottom: 8px;
- }
-
- .recent-date {
- font-family: monospace;
- margin-right: 10px;
- white-space: nowrap;
- }
-
- .recent-title {
- word-wrap: break-word;
- }
-
- .recent-empty {
- text-align: center;
- font-style: italic;
- }
-
- @media (max-width: 720px) {
- .recent-list li {
- display: flex;
- flex-wrap: wrap;
- }
-
- .recent-date {
- width: auto;
- margin-right: 0.5em;
- }
- }
-
- .recent-posts {
- margin-top: .8rem;
- }
-
- .recent-posts h2 {
- margin-top: 1rem;
- margin-bottom: 1rem;
-
- }
-</style>
+{{ $recent := first 10 $pages.ByDate.Reverse }}
<div class="recent-posts">
- {{ if $recent }}
- <ul class="recent-list">
- {{ range $recent }}
- <div class="recent-item">
- <li>
- <span class="recent-date">{{ .Date.Format "2006-01-02" }}</span>
- <a href="{{ .RelPermalink }}" class="recent-title">{{ .Title }}</a>
- </li>
-
- <summary>
- {{ .Summary }}
- </summary>
-
- </div>
- {{ end }}
- </ul>
- {{ else }}
- <div class="recent-empty">暂无文章</div>
- {{ end }}
+ {{ if $recent }}
+ <ul class="posts-list {{ if eq $mode 1 }}with-summary{{ else }}title-only{{ end }}">
+ {{ range $recent }}
+ <li>
+ <time datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Format "2006-01-02" }}</time>
+
+ <span class="post-link-wrapper">
+ <a href="{{ .RelPermalink }}" class="post-title">{{ .Title }}</a>
+ </span>
+
+ {{ if eq $mode 1 }}
+ <p class="post-summary">{{ .Summary | plainify | truncate 150 }}</p>
+ {{ end }}
+ </li>
+ {{ end }}
+ </ul>
+ {{ else }}
+ <p class="posts-empty">暂无随笔 / No posts found.</p>
+ {{ end }}
</div>
-{{ end }}
-
-
-
-{{ if eq $mode 2 }}
-<style>
- .recent-date {
- display: inline-block;
- margin-right: 0.4rem;
- }
-
- .recent-item-2 {
- margin-bottom: .5rem;
- }
-
- .recent-title {
- border-bottom: none !important;
- }
-
-</style>
-
-
-<div class="recent-posts">
- {{ range $recent }}
- <div class="recent-item-2">
- <span class="recent-date">{{ .Date.Format "2006-01-02" }}</span>
- <a href="{{ .RelPermalink }}" class="recent-title">{{ .Title }}</a>
- <br>
- </div>
- {{ end }}
-</div>
-
-
-
-{{ end }}