Skip to content

Commit

Permalink
feat: rss 인덱스 페이지 제외 및 생성 로직 수정 (#54)
Browse files Browse the repository at this point in the history
* feat: rss

* style: 홈페이지 콜아웃 스타일 변경

* docs: 인제님 컨텐츠 레이아웃 튀어나가는거 변경

* style: Answer

* style: Curation
  • Loading branch information
junghyeonsu authored Jan 12, 2025
1 parent e6ea93e commit 2a4b3f0
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 84 deletions.
2 changes: 1 addition & 1 deletion app/(home)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function HomePage() {

<p>- 최종 수정 : 2024년 9월 30일</p>

<div className="flex flex-col gap-2 p-4 rounded-xl bg-blue-50 text-blue-900">
<div className="flex flex-col gap-2 p-4 rounded-xl bg-blue-50 dark:bg-blue-950 text-blue-900 dark:text-blue-50">
<span className="font-bold text-lg">글또 추후 기수 공지</span>
<span>글또는 10기까지 운영될 예정입니다(25년 3월까지 10기 운영)</span>
<span>추가 모집을 받고 있지 않고 있습니다</span>
Expand Down
12 changes: 5 additions & 7 deletions content/blog/open-source/injae-kim-interview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,10 @@ _오픈소스에서 살펴보면 좋은 탭 (이슈/PR/토론)_
- 인제님께서는 오픈소스 멘토링을 운영 중이신데요, 오픈소스에 관심이 있는 분들에게 많은 도움이 될 것 같아요!
- 이상으로, 오픈소스 기여 시리즈 마지막 이야기를 마치겠습니다. 감사합니다! 🙏


<br/>

> 오픈소스 멘토링 블로그: https://medium.com/opensource-contributors<br/>
> 멘토링에서 함꼐만든 200+개 PR과 기부: [https://chip-bream-9d5.notion.site/459f46f1dbe048ffbb7ef04fd9dcc6a6](https://www.notion.so/459f46f1dbe048ffbb7ef04fd9dcc6a6?pvs=21)<br/>
> 오픈소스 멘토링 오픈챗: https://open.kakao.com/o/ghrD0mUf
<Callout>
- [오픈소스 멘토링 블로그](https://medium.com/opensource-contributors)
- [멘토링에서 함꼐만든 200+개 PR과 기부](https://www.notion.so/459f46f1dbe048ffbb7ef04fd9dcc6a6?pvs=21)
- [오픈소스 멘토링 오픈챗](https://open.kakao.com/o/ghrD0mUf)
</Callout>

<ProfileCard title="인제님의 github" profileImg="https://avatars.githubusercontent.com/u/34854527?v=4" url="https://github.com/injae-kim" />
8 changes: 1 addition & 7 deletions public/blog/rss.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,11 @@
<title>글또 블로그</title>
<link>https://geultto.github.io/</link>
<description>글또 블로그 RSS 피드</description>
<lastBuildDate>Thu, 09 Jan 2025 12:51:11 GMT</lastBuildDate>
<lastBuildDate>Sat, 11 Jan 2025 16:59:53 GMT</lastBuildDate>
<docs>https://validator.w3.org/feed/docs/rss2.html</docs>
<generator>https://github.com/jpmonette/feed</generator>
<language>ko</language>
<copyright>Copyright © 2025 글쓰는 또라이</copyright>
<item>
<title><![CDATA[글또 블로그]]></title>
<link>https://geultto.github.io/blog/</link>
<guid>https://geultto.github.io/blog/</guid>
<pubDate>Thu, 09 Jan 2025 12:51:11 GMT</pubDate>
</item>
<item>
<title><![CDATA[오픈소스 기여 시리즈 1, MDN 오거나이저 상철님을 만나다 🚀]]></title>
<link>https://geultto.github.io/blog/open-source/1ilsang-interview</link>
Expand Down
9 changes: 1 addition & 8 deletions public/curation/rss.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<title>글또 큐레이션</title>
<link>https://geultto.github.io/</link>
<description>글또 큐레이션 RSS 피드</description>
<lastBuildDate>Thu, 09 Jan 2025 12:51:11 GMT</lastBuildDate>
<lastBuildDate>Sat, 11 Jan 2025 16:59:53 GMT</lastBuildDate>
<docs>https://validator.w3.org/feed/docs/rss2.html</docs>
<generator>https://github.com/jpmonette/feed</generator>
<language>ko</language>
Expand Down Expand Up @@ -37,12 +37,5 @@
<pubDate>Mon, 30 Dec 2024 00:00:00 GMT</pubDate>
<description><![CDATA[10기 4회차에 글또에서 선정된 글을 소개합니다.]]></description>
</item>
<item>
<title><![CDATA[큐레이션]]></title>
<link>https://geultto.github.io/curation/</link>
<guid>https://geultto.github.io/curation/</guid>
<pubDate>Thu, 09 Jan 2025 12:51:11 GMT</pubDate>
<description><![CDATA[글또 큐레이션을 소개합니다.]]></description>
</item>
</channel>
</rss>
8 changes: 1 addition & 7 deletions public/docs/rss.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<title>글또 문서</title>
<link>https://geultto.github.io/</link>
<description>글또 문서 RSS 피드</description>
<lastBuildDate>Thu, 09 Jan 2025 12:51:11 GMT</lastBuildDate>
<lastBuildDate>Sat, 11 Jan 2025 16:59:53 GMT</lastBuildDate>
<docs>https://validator.w3.org/feed/docs/rss2.html</docs>
<generator>https://github.com/jpmonette/feed</generator>
<language>ko</language>
Expand All @@ -27,12 +27,6 @@
<guid>https://geultto.github.io/docs/guide</guid>
<pubDate>Thu, 04 Jul 2024 00:00:00 GMT</pubDate>
</item>
<item>
<title><![CDATA[글또 가이드]]></title>
<link>https://geultto.github.io/docs/</link>
<guid>https://geultto.github.io/docs/</guid>
<pubDate>Thu, 09 Jan 2025 12:51:11 GMT</pubDate>
</item>
<item>
<title><![CDATA[글 작성 가이드]]></title>
<link>https://geultto.github.io/docs/writing-guide</link>
Expand Down
76 changes: 41 additions & 35 deletions scripts/generate-rss.ts
Original file line number Diff line number Diff line change
@@ -1,46 +1,55 @@
import { blogSource, curationSource, docsSource } from '../src/lib/source';
import { generateFeed } from '../src/lib/rss';
import fs from 'node:fs';
import path from 'node:path';
import { blogSource, curationSource, docsSource } from "../src/lib/source";
import { generateFeed } from "../src/lib/rss";
import fs from "node:fs";
import path from "node:path";

async function generateRSSFeeds() {
// 각 섹션별 피드 생성
const feeds = {
blog: generateFeed({
title: '글또 블로그',
description: '글또 블로그 RSS 피드',
posts: blogSource.getPages().map(page => ({
title: page.data.title,
description: page.data.description || "",
date: new Date(page.data.createdAt || Date.now()),
url: `https://geultto.github.io/blog/${page.slugs.join('/')}`,
}))
title: "글또 블로그",
description: "글또 블로그 RSS 피드",
posts: blogSource
.getPages()
.filter((page) => page.slugs.length !== 0)
.map((page) => ({
title: page.data.title,
description: page.data.description || "",
date: new Date(page.data.createdAt || new Date("2025-01-01")),
url: `https://geultto.github.io/blog/${page.slugs.join("/")}`,
})),
}),
curation: generateFeed({
title: '글또 큐레이션',
description: '글또 큐레이션 RSS 피드',
posts: curationSource.getPages().map(page => ({
title: page.data.title,
description: page.data.description || "",
date: new Date(page.data.createdAt || Date.now()),
url: `https://geultto.github.io/curation/${page.slugs.join('/')}`,
}))
title: "글또 큐레이션",
description: "글또 큐레이션 RSS 피드",
posts: curationSource
.getPages()
.filter((page) => page.slugs.length !== 0)
.map((page) => ({
title: page.data.title,
description: page.data.description || "",
date: new Date(page.data.createdAt || new Date("2025-01-01")),
url: `https://geultto.github.io/curation/${page.slugs.join("/")}`,
})),
}),
docs: generateFeed({
title: '글또 문서',
description: '글또 문서 RSS 피드',
posts: docsSource.getPages().map(page => ({
title: page.data.title,
description: page.data.description || "",
date: new Date(page.data.createdAt || Date.now()),
url: `https://geultto.github.io/docs/${page.slugs.join('/')}`,
}))
})
title: "글또 문서",
description: "글또 문서 RSS 피드",
posts: docsSource
.getPages()
.filter((page) => page.slugs.length !== 0)
.map((page) => ({
title: page.data.title,
description: page.data.description || "",
date: new Date(page.data.createdAt || new Date("2025-01-01")),
url: `https://geultto.github.io/docs/${page.slugs.join("/")}`,
})),
}),
};

// public 디렉토리에 RSS 파일 생성
const publicDir = path.join(process.cwd(), 'public');
const publicDir = path.join(process.cwd(), "public");

// public 디렉토리가 없다면 생성
if (!fs.existsSync(publicDir)) {
fs.mkdirSync(publicDir);
Expand All @@ -53,10 +62,7 @@ async function generateRSSFeeds() {
fs.mkdirSync(dir);
}

fs.writeFileSync(
path.join(dir, "rss.xml"),
feed.rss2()
);
fs.writeFileSync(path.join(dir, "rss.xml"), feed.rss2());
}
}

Expand Down
7 changes: 4 additions & 3 deletions src/components/Answer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,21 @@ export function Answer({ children, profileImg, name = "", direction = "right" }:
return (
<div
className={cn(
"grid leading-7",
"flex flex-col",
direction === "right" && "grid-cols-[100px_1fr]",
direction === "left" && "grid-cols-[1fr_100px]",
direction === "center" && "grid-cols-[auto] justify-items-center text-center",
"md:grid-cols-auto md:[&_.profile]:mx-auto md:[&_.name]:mx-auto md:text-left",
"sm:grid sm:leading-7",
)}
>
{direction === "left" && <div className="break-words">{children}</div>}
{profileImg && (
<div className="flex flex-col items-center">
<div className="flex justify-center items-center w-[64px] h-[64px] overflow-hidden rounded-full border border-secondary-dark mr-4">
<div className="flex justify-center items-center w-[56px] h-[56px] overflow-hidden rounded-full border border-secondary-dark mt-6">
<img src={profileImg} alt={name} className="w-full h-full object-contain" draggable={false} />
</div>
{name && <p className="w-20 text-center text-primary-lightest text-sm">{name}</p>}
{name && <span className="text-center text-primary-lightest text-sm mt-2">{name}</span>}
</div>
)}
{(direction === "right" || direction === "center") && <div className="break-words">{children}</div>}
Expand Down
16 changes: 10 additions & 6 deletions src/components/Curation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,24 @@ const Content = (props: CurationContent) => {

return (
<a href={주소} target="_blank" rel="noreferrer" className="no-underline">
<div className="flex flex-col rounded-xl transition-all hover:shadow-sm border border-gray-100">
<div className="flex flex-col h-full rounded-xl transition-all hover:shadow-sm border border-gray-100 dark:border-gray-900">
{/* 썸네일 이미지 */}
{thumbnail ? (
<div className="aspect-[4/3] w-full h-full">
<img className="w-full h-full object-cover rounded-xl" src={thumbnail} alt={제목} draggable={false} />
<div className="aspect-[4/3] w-full h-full max-h-[243px]">
<img className="w-full h-full object-cover rounded-xl m-0" src={thumbnail} alt={제목} draggable={false} />
</div>
) : (
<div className="aspect-[4/3] w-full h-full bg-gray-100 rounded-xl" />
<div className="aspect-[4/3] w-full h-full bg-gray-100 dark:bg-gray-900 rounded-xl p-4 max-h-[243px]">
<div className="flex justify-center items-center w-full h-full text-gray-500 dark:text-gray-400 text-sm">
{제목}
</div>
</div>
)}

{/* 컨텐츠 */}
<div className="flex flex-col px-4 mt-4 mb-4">
<h3 className="text-xl font-bold mb-3 line-clamp-2">{제목}</h3>
<p className="text-gray-600 text-sm line-clamp-3">{설명}</p>
<h3 className="text-xl font-bold mb-2 mt-2">{제목}</h3>
<p className="text-gray-600 text-sm">{설명}</p>

{/* 작가 정보 */}
{author ? (
Expand Down
24 changes: 14 additions & 10 deletions src/lib/rss.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Feed } from 'feed';
import { Feed } from "feed";

import type { Author } from '../types/author';
import type { Author } from "../types/author";

interface FeedOptions {
title: string;
Expand All @@ -18,10 +18,10 @@ export function generateFeed(options: FeedOptions) {
const feed = new Feed({
title: options.title,
description: options.description,
id: 'https://geultto.github.io/',
link: 'https://geultto.github.io/',
language: 'ko',
copyright: `Copyright © ${new Date().getFullYear()} 글쓰는 또라이`
id: "https://geultto.github.io/",
link: "https://geultto.github.io/",
language: "ko",
copyright: `Copyright © ${new Date().getFullYear()} 글쓰는 또라이`,
});

for (const post of options.posts) {
Expand All @@ -30,10 +30,14 @@ export function generateFeed(options: FeedOptions) {
description: post.description,
date: post.date,
link: post.url,
author: post.author ? [{
name: post.author.name,
link: post.author.url
}] : undefined
author: post.author
? [
{
name: post.author.name,
link: post.author.url,
},
]
: undefined,
});
}

Expand Down

0 comments on commit 2a4b3f0

Please sign in to comment.