Skip to content

Commit

Permalink
feat: create sitemap.js in every routes
Browse files Browse the repository at this point in the history
  • Loading branch information
lumirlumir committed Oct 26, 2024
1 parent c45f6d9 commit d271dbd
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 2 deletions.
13 changes: 13 additions & 0 deletions src/app/categories/sitemap.js
Original file line number Diff line number Diff line change
@@ -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,
}));
}
13 changes: 13 additions & 0 deletions src/app/posts/sitemap.js
Original file line number Diff line number Diff line change
@@ -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,
}));
}
12 changes: 12 additions & 0 deletions src/app/sitemap.js
Original file line number Diff line number Diff line change
@@ -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,
},
];
}
6 changes: 5 additions & 1 deletion src/constants/index.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/posts/docs/everything-about-markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ HTML에서 이용하는 `<!-- -->` 기호를 사용한다.

`<blockquote>` 태그로 변환되는 '인용문<sup>Blockquotes</sup>'을 표현한다.

`>` 기호를 사용하며, 중첩된 인용문<sup>Nested blockquotes</sup>을 만들 수 있다.
`>` 기호를 사용하며, 중첩된 인용문<sup>Nested Blockquotes</sup>을 만들 수 있다.

인용문 내부에 다른 마크다운 요소를 포함할 수 있다. (제목, 리스트, 코드 블록 등등)

Expand Down

0 comments on commit d271dbd

Please sign in to comment.