Skip to content

Commit f3fce93

Browse files
committed
Merge branch 'development'
2 parents 641326d + 89f66aa commit f3fce93

File tree

2 files changed

+41
-19
lines changed

2 files changed

+41
-19
lines changed

src/pages/404.astro

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
import PageLayout from '@/components/layouts/PageLayout.astro';
3+
import Button from '@/components/button';
4+
---
5+
6+
<PageLayout title="404">
7+
<div class="flex h-[70vh] flex-col items-center justify-center">
8+
<h1 class="mb-4 text-4xl font-bold">404</h1>
9+
<p class="mb-8 text-slate10">你访问的页面不存在</p>
10+
<Button id="back">返回首页</Button>
11+
</div>
12+
</PageLayout>
13+
14+
<script>
15+
const backBtn = document.getElementById('back');
16+
backBtn?.addEventListener('click', () => {
17+
window.location.href = '/';
18+
});
19+
</script>

src/pages/index.astro

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,27 @@ const postCollection = await getCollection('post', ({ data }) => {
99
return import.meta.env.DEV || data.draft !== true;
1010
});
1111
12-
const tagCounts = postCollection.reduce<Record<string, number>>((res, post) => {
13-
const postTags = post.data.tags;
14-
if(!postTags || !postTags.length) return res;
15-
postTags.forEach(tag => {
16-
if(tag.trim() === '') return;
12+
const tagCounts = postCollection.reduce<Record<string, number>>(
13+
(res, post) => {
14+
const postTags = post.data.tags;
15+
if (!postTags || !postTags.length) return res;
16+
postTags.forEach((tag) => {
17+
if (tag.trim() === '') return;
1718
18-
if(res[tag]) {
19-
res[tag]++;
20-
} else {
21-
res[tag] = 1;
22-
}
23-
})
24-
return res;
25-
}, {
26-
All: postCollection.length
27-
})
19+
if (res[tag]) {
20+
res[tag]++;
21+
} else {
22+
res[tag] = 1;
23+
}
24+
});
25+
return res;
26+
},
27+
{
28+
All: postCollection.length,
29+
},
30+
);
2831
29-
const tags = Object.keys(tagCounts).map(tag => ({
32+
const tags = Object.keys(tagCounts).map((tag) => ({
3033
name: tag,
3134
count: tagCounts[tag],
3235
}));
@@ -80,8 +83,8 @@ const posts = [...postCollection]
8083
{
8184
tags.map(({ name, count }) => (
8285
<li class="block cursor-pointer rounded-full bg-slate3 px-4 py-2 text-slate10 transition-all hover:bg-slate4 hover:text-slate11">
83-
{name}
84-
<sup class="text-slate8 text-[10px]">{count}</sup>
86+
{name}
87+
<sup class="text-[10px] text-slate8">{count}</sup>
8588
</li>
8689
))
8790
}
@@ -91,6 +94,6 @@ const posts = [...postCollection]
9194
</PageLayout>
9295
<style>
9396
.blog-list-item {
94-
@apply flex cursor-pointer flex-col justify-between rounded-lg py-2 transition-all active:scale-[0.995] active:bg-slate4 sm:flex-row sm:items-center sm:px-2 sm:hover:bg-slate3;
97+
@apply flex cursor-pointer flex-col justify-between rounded-lg py-2.5 transition-all active:scale-[0.995] active:bg-slate4 sm:flex-row sm:items-center sm:px-2 sm:hover:bg-slate3;
9598
}
9699
</style>

0 commit comments

Comments
 (0)