Skip to content

Commit 09fde93

Browse files
committed
[Fix] 빌드 후 RSS 검토를 통해 Link/Domain/TrailingSlash 문제 해결
1 parent 9b65150 commit 09fde93

3 files changed

Lines changed: 38 additions & 29 deletions

File tree

astro.config.mjs

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const koBlogsPostDates = getKoPostDates("./blog");
6969
const koHobbyPostDates = getKoPostDates("./hobby");
7070
const koPostDates = { ...koBlogsPostDates, ...koHobbyPostDates };
7171

72-
const SITE_ORIGIN = "https://aaronryu.netlify.app";
72+
const SITE_ORIGIN = "https://aaronryu.github.io";
7373
// https://astro.build/config
7474
export default defineConfig({
7575
// (A) Astro-specific options
@@ -79,30 +79,22 @@ export default defineConfig({
7979

8080
// prettier-ignore
8181
redirects: {
82-
"/2019/02/17/how-do-i-make-email-address": "/ko/posts/engineering/how-do-i-make-email-address",
82+
// "/2019/02/17/how-do-i-make-email-address": "/ko/posts/engineering/how-do-i-make-email-address",
8383
"/2019/02/17/how-do-i-make-email-address/": "/ko/posts/engineering/how-do-i-make-email-address",
84-
"/2019/02/17/how-do-i-make-email-address/index.html": "/ko/posts/engineering/how-do-i-make-email-address",
85-
"/2019/03/24/only-one-page-for-functional-programming": "/ko/posts/engineering/only-one-page-for-functional-programming",
84+
// "/2019/03/24/only-one-page-for-functional-programming": "/ko/posts/engineering/only-one-page-for-functional-programming",
8685
"/2019/03/24/only-one-page-for-functional-programming/": "/ko/posts/engineering/only-one-page-for-functional-programming",
87-
"/2019/03/24/only-one-page-for-functional-programming/index.html": "/ko/posts/engineering/only-one-page-for-functional-programming",
88-
"/2019/05/27/coroutine-and-thread": "/ko/posts/engineering/coroutine-and-thread",
86+
// "/2019/05/27/coroutine-and-thread": "/ko/posts/engineering/coroutine-and-thread",
8987
"/2019/05/27/coroutine-and-thread/": "/ko/posts/engineering/coroutine-and-thread",
90-
"/2019/05/27/coroutine-and-thread/index.html": "/ko/posts/engineering/coroutine-and-thread",
91-
"/2021/02/07/things-that-i-should-have-known-when-i-was-a-junior-developer": "/ko/posts/engineering/things-that-i-should-have-known-when-i-was-a-junior-developer",
88+
// "/2021/02/07/things-that-i-should-have-known-when-i-was-a-junior-developer": "/ko/posts/engineering/things-that-i-should-have-known-when-i-was-a-junior-developer",
9289
"/2021/02/07/things-that-i-should-have-known-when-i-was-a-junior-developer/": "/ko/posts/engineering/things-that-i-should-have-known-when-i-was-a-junior-developer",
93-
"/2021/02/07/things-that-i-should-have-known-when-i-was-a-junior-developer/index.html": "/ko/posts/engineering/things-that-i-should-have-known-when-i-was-a-junior-developer",
94-
"/2021/02/14/a-tutorial-for-spring-mvc-and-security": "/ko/posts/engineering/a-tutorial-for-spring-mvc-and-security",
90+
// "/2021/02/14/a-tutorial-for-spring-mvc-and-security": "/ko/posts/engineering/a-tutorial-for-spring-mvc-and-security",
9591
"/2021/02/14/a-tutorial-for-spring-mvc-and-security/": "/ko/posts/engineering/a-tutorial-for-spring-mvc-and-security",
96-
"/2021/02/14/a-tutorial-for-spring-mvc-and-security/index.html": "/ko/posts/engineering/a-tutorial-for-spring-mvc-and-security",
97-
"/2021/03/14/thread-and-security-context-holder-mode": "/ko/posts/engineering/thread-and-security-context-holder-mode",
92+
// "/2021/03/14/thread-and-security-context-holder-mode": "/ko/posts/engineering/thread-and-security-context-holder-mode",
9893
"/2021/03/14/thread-and-security-context-holder-mode/": "/ko/posts/engineering/thread-and-security-context-holder-mode",
99-
"/2021/03/14/thread-and-security-context-holder-mode/index.html": "/ko/posts/engineering/thread-and-security-context-holder-mode",
100-
"/resume": "/ko/about",
94+
// "/resume": "/ko/about",
10195
"/resume/": "/ko/about",
102-
"/resume/index.html": "/ko/about",
103-
"/about": "/ko/about",
96+
// "/about": "/ko/about",
10497
"/about/": "/ko/about",
105-
"/about/index.html": "/ko/about",
10698
},
10799

108100
// (B) Vite-specific options
@@ -124,7 +116,7 @@ export default defineConfig({
124116
const slug = urlPath.split("/").pop();
125117

126118
// 루트 URL 사이트맵에서 제거
127-
const isRoot = urlPath === "https://aaronryu.netlify.app";
119+
const isRoot = urlPath === SITE_ORIGIN;
128120
if (isRoot) return null;
129121

130122
if (item.url.includes("/posts/") && koPostDates[slug]) {

src/pages/[lang]/resume/index.astro

Whitespace-only changes.

src/pages/[lang]/rss.xml.js

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { AARONS_BLOG_DESCRIPTION, AARONS_BLOG_TITLE } from "@/layouts/BaseLayout.astro";
22
import rss, { pagesGlobToRssItems } from "@astrojs/rss";
33
import { getCollection } from "astro:content";
4-
import { SUPPORTED_LANGUAGES } from "@/scripts/i18n";
4+
import { SUPPORTED_LANGUAGES, wipeoutPath } from "@/scripts/i18n";
55
import sanitizeHtml from "sanitize-html";
66
import MarkdownIt from "markdown-it";
77

@@ -14,28 +14,45 @@ export async function getStaticPaths() {
1414
export async function GET(context) {
1515
const { lang } = context.params;
1616

17-
const posts = await getCollection("blog", ({ id }) => id.startsWith(`${lang}/`));
18-
const hobbies = await getCollection("hobby", ({ id }) => id.startsWith(`${lang}/`));
17+
const posts = await getCollection("blog", ({ id }) => id.includes(`/${lang}/`));
18+
const hobbies = await getCollection("hobby", ({ id }) => id.includes(`/${lang}/`));
1919
return rss({
20+
// Option
21+
trailingSlash: false,
22+
// Data
2023
title: AARONS_BLOG_TITLE,
2124
description: AARONS_BLOG_DESCRIPTION[lang],
2225
site: context.site,
2326
// items: await pagesGlobToRssItems(import.meta.glob("@/pages/**/*.md")),
2427
items: [
2528
...posts.map((post) => ({
26-
link: `/${lang}/posts/${post.slug}`,
29+
link: `/${lang}/posts/${wipeoutPath(post.id)}`,
2730
content: sanitizeHtml(parser.render(post.body)), // 전체 콘텐츠 렌더링
28-
customData: `<category>${post.filePath?.split("/").slice(1, -1)[0]}/${post.data.category
29-
.map((each) => each.toLowerCase().replace(",", "").replace(" ", "-"))
30-
.join("/")}</category>`,
31+
customData: [
32+
...new Set([
33+
((str) => str.charAt(0).toUpperCase() + str.slice(1))(
34+
post.filePath?.split("/").slice(1, -1)[0],
35+
),
36+
...post.data.category,
37+
]),
38+
]
39+
.map((each) => `<category>${each}</category>`)
40+
.join(""),
3141
...post.data,
3242
})),
3343
...hobbies.map((hobby) => ({
34-
link: `/${lang}/hobby/${hobby.slug}`,
44+
link: `/${lang}/hobby/${wipeoutPath(hobby.id)}`,
3545
content: sanitizeHtml(parser.render(hobby.body)), // 전체 콘텐츠 렌더링
36-
customData: `<category>${hobby.data.category
37-
.map((each) => each.toLowerCase().replace(",", "").replace(" ", "-"))
38-
.join("/")}</category>`,
46+
customData: [
47+
...new Set([
48+
((str) => str.charAt(0).toUpperCase() + str.slice(1))(
49+
post.filePath?.split("/").slice(1, -1)[0],
50+
),
51+
...hobby.data.category,
52+
]),
53+
]
54+
.map((each) => `<category>${each}</category>`)
55+
.join(""),
3956
...hobby.data,
4057
})),
4158
],

0 commit comments

Comments
 (0)