From d271dbdd78487209f56939d5e59f07406c6ced97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=A3=A8=EB=B0=80LuMir?= Date: Sun, 27 Oct 2024 00:31:36 +0900 Subject: [PATCH] feat: create `sitemap.js` in every routes --- src/app/categories/sitemap.js | 13 +++++++++++++ src/app/posts/sitemap.js | 13 +++++++++++++ src/app/sitemap.js | 12 ++++++++++++ src/constants/index.js | 6 +++++- src/posts/docs/everything-about-markdown.md | 2 +- 5 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 src/app/categories/sitemap.js create mode 100644 src/app/posts/sitemap.js create mode 100644 src/app/sitemap.js diff --git a/src/app/categories/sitemap.js b/src/app/categories/sitemap.js new file mode 100644 index 0000000..b86842b --- /dev/null +++ b/src/app/categories/sitemap.js @@ -0,0 +1,13 @@ +import { WEBSITE_URL, PATH_DOCS } from '@/constants'; +import { readMarkdownTagTree } from '@/utils/fs'; + +export default async function sitemap() { + const tagTree = await readMarkdownTagTree(PATH_DOCS); + + return Object.keys(tagTree).map(tag => ({ + url: `${WEBSITE_URL}/categories/${tag}`, + lastModified: new Date(), + changeFrequency: 'weekly', + priority: 0.8, + })); +} diff --git a/src/app/posts/sitemap.js b/src/app/posts/sitemap.js new file mode 100644 index 0000000..20e3185 --- /dev/null +++ b/src/app/posts/sitemap.js @@ -0,0 +1,13 @@ +import { WEBSITE_URL, PATH_DOCS, EXT_MD_REGEXP } from '@/constants'; +import { readMarkdownFilesFromDir } from '@/utils/fs'; + +export default async function sitemap() { + const markdownDocuments = await readMarkdownFilesFromDir(PATH_DOCS); + + return markdownDocuments.map(({ basename, data: { updated } }) => ({ + url: `${WEBSITE_URL}/posts/${basename.replace(EXT_MD_REGEXP, '')}`, + lastModified: updated, + changeFrequency: 'monthly', + priority: 1.0, + })); +} diff --git a/src/app/sitemap.js b/src/app/sitemap.js new file mode 100644 index 0000000..5e1ce31 --- /dev/null +++ b/src/app/sitemap.js @@ -0,0 +1,12 @@ +import { WEBSITE_URL } from '@/constants'; + +export default function sitemap() { + return [ + { + url: WEBSITE_URL, + lastModified: new Date(), + changeFrequency: 'monthly', + priority: 0.5, + }, + ]; +} diff --git a/src/constants/index.js b/src/constants/index.js index 3fda57a..2ccfe3c 100644 --- a/src/constants/index.js +++ b/src/constants/index.js @@ -1,8 +1,12 @@ import { join } from 'path'; +// Website +export const WEBSITE_NAME = 'blog.lumir.page'; +export const WEBSITE_URL = `https://${WEBSITE_NAME}`; + // GitHub Repository, Ref: https://docs.github.com/en/rest/repos/repos export const GITHUB_REPO_OWNER = 'lumirlumir'; -export const GITHUB_REPO_NAME = 'web-blog.lumir.page'; +export const GITHUB_REPO_NAME = `web-${WEBSITE_NAME}`; export const GITHUB_REPO_FULL_NAME = `${GITHUB_REPO_OWNER}/${GITHUB_REPO_NAME}`; // Path diff --git a/src/posts/docs/everything-about-markdown.md b/src/posts/docs/everything-about-markdown.md index 17569f0..68250e3 100644 --- a/src/posts/docs/everything-about-markdown.md +++ b/src/posts/docs/everything-about-markdown.md @@ -416,7 +416,7 @@ HTML에서 이용하는 `` 기호를 사용한다. `
` 태그로 변환되는 '인용문Blockquotes'을 표현한다. -`>` 기호를 사용하며, 중첩된 인용문Nested blockquotes을 만들 수 있다. +`>` 기호를 사용하며, 중첩된 인용문Nested Blockquotes을 만들 수 있다. 인용문 내부에 다른 마크다운 요소를 포함할 수 있다. (제목, 리스트, 코드 블록 등등)