Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RSS 추가 #348

Merged
merged 1 commit into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"@astrojs/check": "^0.5.4",
"@astrojs/mdx": "^2.1.1",
"@astrojs/preact": "^3.1.0",
"@astrojs/rss": "^4.0.5",
"@astrojs/sitemap": "^3.1.1",
"@astrojs/ts-plugin": "^1.5.2",
"@astrojs/vercel": "^7.3.1",
Expand Down
21 changes: 21 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 15 additions & 1 deletion src/components/blog/PostList/PostListLayout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,21 @@ const { listTitle, entries } = Astro.props;
// const pathname = Astro.url.pathname.replace(/\/$/, "");
---

<LayoutBase lang="ko" title="PortOne 기술 블로그" slug="blog" navAsMenu>
<LayoutBase
lang="ko"
title="PortOne 기술 블로그"
description="핀테크 기업 포트원이 기술을 통해 결제를 혁신해나가는 과정을 이야기합니다"
slug="blog"
navAsMenu
>
<Fragment slot="head">
<link
rel="alternate"
type="application/rss+xml"
title="PortOne 기술 블로그"
href={`${Astro.site}blog/rss.xml`}
/>
</Fragment>
<div class="mx-auto my-4 max-w-1148px min-h-full flex flex-col gap-10 px-5">
<div class="z-10 flex flex-wrap items-end justify-between gap-x-6 gap-y-4">
<h1 class="break-keep text-8 text-slate-8 font-semibold lg:text-10">
Expand Down
1 change: 1 addition & 0 deletions src/layouts/LayoutBase.astro
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const {
<meta property="og:image" content={`${Astro.site}${ogImageSlug}`} />
<meta name="twitter:card" content="summary_large_image" />
</slot>
<slot name="head" />
<Trackers />
</head>
<body>
Expand Down
8 changes: 8 additions & 0 deletions src/pages/blog/posts/[...slug].astro
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ const author = authors[authorId];
ogType="article"
ogImageSlug={`blog/posts/${entry.slug}.png`}
>
<Fragment slot="head">
<link
rel="alternate"
type="application/rss+xml"
title="PortOne 기술 블로그"
href={`${Astro.site}blog/rss.xml`}
/>
</Fragment>
<div class="mx-auto max-w-[1150px]">
<!--
<div
Expand Down
23 changes: 23 additions & 0 deletions src/pages/blog/rss.xml.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import rss from "@astrojs/rss";
import type { APIContext } from "astro";
import { getCollection } from "astro:content";

export async function GET(context: APIContext) {
const blog = await getCollection("blog");
return rss({
title: "PortOne 기술 블로그",
description:
"핀테크 기업 포트원이 기술을 통해 결제를 혁신해나가는 과정을 이야기합니다",
site: context.site!,
items: blog
.filter((post) => !post.data.draft)
.sort((a, b) => b.data.date.getTime() - a.data.date.getTime())
.slice(0, 100)
.map((post) => ({
title: post.data.title,
pubDate: post.data.date,
description: post.data.description,
link: `/blog/posts/${post.slug}`,
})),
});
}