Skip to content

Commit dc0f8b0

Browse files
committed
移除文章頁面的最新文章 sidebar,只保留 TOC 目錄
1 parent c8dc604 commit dc0f8b0

File tree

1 file changed

+184
-9
lines changed

1 file changed

+184
-9
lines changed

_layouts/post.html

Lines changed: 184 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,191 @@
11
---
22
layout: default
3+
hide_hero: true
4+
show_sidebar: false
35
---
46

5-
<div class="content">
7+
<article class="post" itemscope itemtype="http://schema.org/BlogPosting">
8+
<!-- Post Header -->
9+
<header class="mb-8">
10+
<!-- Category Badge -->
11+
{% if page.category %}
12+
<a href="{{ '/categories/' | relative_url }}#{{ page.category | slugify }}" class="inline-block px-3 py-1 text-xs font-mono bg-cp-green-500/10 text-cp-green-500 border border-cp-green-600 rounded mb-4 hover:bg-cp-green-500/20 transition-colors">
13+
{{ page.category }}
14+
</a>
15+
{% endif %}
616

7-
<p>Published: {{ page.date | date: "%b %-d, %Y" }} by {{ page.author }}</p>
17+
<!-- Title -->
18+
<h1 class="text-3xl md:text-4xl font-bold font-mono text-cp-green-500 mb-4 text-glow-sm" itemprop="headline">
19+
{{ page.title }}
20+
</h1>
821

9-
{{ content }}
10-
</div>
22+
<!-- Meta Info -->
23+
<div class="flex flex-wrap items-center gap-4 text-sm text-cp-dark-600 font-mono">
24+
<!-- Date -->
25+
<time datetime="{{ page.date | date_to_xmlschema }}" itemprop="datePublished" class="flex items-center gap-1">
26+
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
27+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"/>
28+
</svg>
29+
{{ page.date | date: "%Y-%m-%d" }}
30+
</time>
1131

12-
<div class="tags">
13-
{% for tag in page.tags %}
14-
<span class="tag is-primary">{{ tag }}</span>
15-
{% endfor %}
16-
</div>
32+
<!-- Author -->
33+
<span class="flex items-center gap-1" itemprop="author" itemscope itemtype="http://schema.org/Person">
34+
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
35+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"/>
36+
</svg>
37+
<span itemprop="name">{{ page.author | default: site.author.name }}</span>
38+
</span>
39+
40+
<!-- Reading Time -->
41+
{% if site.reading_time.enabled %}
42+
{% assign words = content | number_of_words %}
43+
{% assign reading_time = words | divided_by: site.reading_time.words_per_minute %}
44+
{% if reading_time < 1 %}{% assign reading_time = 1 %}{% endif %}
45+
<span class="flex items-center gap-1">
46+
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
47+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"/>
48+
</svg>
49+
{{ reading_time }} 分鐘閱讀
50+
</span>
51+
{% endif %}
52+
</div>
53+
</header>
54+
55+
<!-- Featured Image -->
56+
{% if page.image and page.show_image != false %}
57+
<figure class="mb-8 rounded-lg overflow-hidden border border-cp-dark-400">
58+
<img
59+
src="{{ page.image | relative_url }}"
60+
alt="{{ page.title }}"
61+
class="w-full h-auto"
62+
loading="lazy"
63+
itemprop="image"
64+
>
65+
</figure>
66+
{% endif %}
67+
68+
<!-- Post Content with TOC -->
69+
<div class="flex flex-col lg:flex-row gap-8">
70+
<!-- Main Content -->
71+
<div class="flex-grow min-w-0">
72+
<div class="content prose prose-invert max-w-none" itemprop="articleBody">
73+
{{ content }}
74+
</div>
75+
76+
<!-- Tags -->
77+
{% if page.tags and page.tags.size > 0 %}
78+
<div class="mt-8 pt-8 border-t border-cp-dark-400">
79+
<h3 class="text-sm font-mono text-cp-dark-600 mb-3">
80+
<span class="text-cp-green-600">#</span> 標籤
81+
</h3>
82+
<div class="flex flex-wrap gap-2">
83+
{% for tag in page.tags %}
84+
<a href="{{ '/tags/' | relative_url }}#{{ tag | slugify }}" class="tag text-xs px-3 py-1 bg-cp-dark-200 text-cp-green-500 border border-cp-dark-400 rounded font-mono hover:border-cp-green-500 hover:bg-cp-green-500/10 transition-all">
85+
{{ tag }}
86+
</a>
87+
{% endfor %}
88+
</div>
89+
</div>
90+
{% endif %}
91+
92+
<!-- Share Buttons -->
93+
{% if page.show_share != false %}
94+
<div class="mt-8 pt-8 border-t border-cp-dark-400">
95+
<h3 class="text-sm font-mono text-cp-dark-600 mb-3">
96+
<span class="text-cp-green-600">//</span> 分享
97+
</h3>
98+
{% include share-buttons.html %}
99+
</div>
100+
{% endif %}
101+
102+
<!-- Author Bio -->
103+
<div class="mt-8 pt-8 border-t border-cp-dark-400">
104+
<div class="flex items-center gap-4 p-4 bg-cp-dark-100 border border-cp-dark-400 rounded-lg">
105+
<div class="w-12 h-12 rounded-full bg-cp-green-500/20 flex items-center justify-center text-cp-green-500 font-mono font-bold">
106+
CP
107+
</div>
108+
<div>
109+
<h4 class="font-mono font-medium text-cp-dark-800">{{ page.author | default: site.author.name }}</h4>
110+
<p class="text-sm text-cp-dark-600">{{ site.description | truncate: 80 }}</p>
111+
</div>
112+
</div>
113+
</div>
114+
115+
<!-- Related Posts -->
116+
{% if page.tags.size > 0 %}
117+
{% assign related_posts = site.posts | where_exp: "post", "post.url != page.url" %}
118+
{% assign related_by_tags = "" | split: "" %}
119+
{% for post in related_posts %}
120+
{% for tag in page.tags %}
121+
{% if post.tags contains tag %}
122+
{% assign related_by_tags = related_by_tags | push: post %}
123+
{% break %}
124+
{% endif %}
125+
{% endfor %}
126+
{% endfor %}
127+
{% assign related_posts = related_by_tags | uniq | slice: 0, 3 %}
128+
129+
{% if related_posts.size > 0 %}
130+
<div class="mt-8 pt-8 border-t border-cp-dark-400">
131+
<h3 class="text-lg font-mono font-bold text-cp-green-500 mb-4">
132+
<span class="text-cp-dark-600">//</span> 相關文章
133+
</h3>
134+
<div class="grid gap-4">
135+
{% for post in related_posts %}
136+
<a href="{{ post.url | relative_url }}" class="block p-4 bg-cp-dark-100 border border-cp-dark-400 rounded-lg hover:border-cp-green-600 hover:bg-cp-dark-200 transition-all group">
137+
<h4 class="font-medium text-cp-dark-800 group-hover:text-cp-green-500 transition-colors">
138+
{{ post.title }}
139+
</h4>
140+
<time class="text-xs text-cp-dark-600 font-mono mt-1 block">
141+
{{ post.date | date: "%Y-%m-%d" }}
142+
</time>
143+
</a>
144+
{% endfor %}
145+
</div>
146+
</div>
147+
{% endif %}
148+
{% endif %}
149+
150+
<!-- Comments -->
151+
{% if page.show_comments != false and site.comments.provider %}
152+
<div class="mt-8 pt-8 border-t border-cp-dark-400">
153+
<h3 class="text-lg font-mono font-bold text-cp-green-500 mb-4">
154+
<span class="text-cp-dark-600">//</span> 留言
155+
</h3>
156+
{% include comments.html %}
157+
</div>
158+
{% endif %}
159+
</div>
160+
161+
<!-- TOC Sidebar -->
162+
{% if page.show_toc != false %}
163+
<aside class="hidden xl:block w-64 flex-shrink-0">
164+
<div class="sticky top-24">
165+
{% include toc.html %}
166+
</div>
167+
</aside>
168+
{% endif %}
169+
</div>
170+
171+
<!-- Post Navigation -->
172+
<nav class="mt-12 pt-8 border-t border-cp-dark-400">
173+
<div class="flex flex-col sm:flex-row justify-between gap-4">
174+
{% if page.previous.url %}
175+
<a href="{{ page.previous.url | relative_url }}" class="flex-1 p-4 bg-cp-dark-100 border border-cp-dark-400 rounded-lg hover:border-cp-green-600 transition-all group">
176+
<span class="text-xs text-cp-dark-600 font-mono block mb-1">← 上一篇</span>
177+
<span class="text-cp-dark-800 group-hover:text-cp-green-500 transition-colors line-clamp-1">{{ page.previous.title }}</span>
178+
</a>
179+
{% else %}
180+
<div class="flex-1"></div>
181+
{% endif %}
182+
183+
{% if page.next.url %}
184+
<a href="{{ page.next.url | relative_url }}" class="flex-1 p-4 bg-cp-dark-100 border border-cp-dark-400 rounded-lg hover:border-cp-green-600 transition-all group text-right">
185+
<span class="text-xs text-cp-dark-600 font-mono block mb-1">下一篇 →</span>
186+
<span class="text-cp-dark-800 group-hover:text-cp-green-500 transition-colors line-clamp-1">{{ page.next.title }}</span>
187+
</a>
188+
{% endif %}
189+
</div>
190+
</nav>
191+
</article>

0 commit comments

Comments
 (0)