Skip to content

Commit 46af781

Browse files
authored
Merge pull request #28 from devwqc/feat/rss
[feat] RSS feed
2 parents 2028479 + 2ad57c0 commit 46af781

4 files changed

Lines changed: 61 additions & 0 deletions

File tree

package-lock.json

Lines changed: 37 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
},
2828
"dependencies": {
2929
"@astrojs/check": "^0.9.3",
30+
"@astrojs/rss": "4.0.7",
3031
"@astrojs/tailwind": "5.1.1",
3132
"astro": "^4.15.9",
3233
"tailwindcss": "3.4.13",

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)