Skip to content

Commit 2ad57c0

Browse files
committed
feat: rss.xml 구현
1 parent 89ebca6 commit 2ad57c0

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

src/components/Footer.astro

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,10 @@ const today = new Date();
2828
rel="noreferrer noopener">LinkedIn</SnsIcon
2929
>
3030
</li>
31+
<li>
32+
<SnsIcon href="/rss.xml" target="_blank" rel="noreferrer noopener"
33+
>RSS</SnsIcon
34+
>
35+
</li>
3136
</ul>
3237
</footer>

src/pages/rss.xml.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import rss from '@astrojs/rss';
2+
import type { APIContext } from 'astro';
3+
import { getCollection } from 'astro:content';
4+
5+
export async function GET(context: APIContext) {
6+
const posts = (await getCollection('blog')).sort(
7+
(a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf()
8+
);
9+
return rss({
10+
title: 'devwqc blog',
11+
description: '저의 경험을 이야기하는 블로그입니다.',
12+
site: context.site || 'https://devwqc.github.io/',
13+
items: posts.map((post) => ({
14+
...post.data,
15+
link: `/blog/${post.slug}/`,
16+
})),
17+
});
18+
}

0 commit comments

Comments
 (0)