๐ฆ plugin-content-blog
๋ธ๋ก๊ทธ ๋ง๋ค๊ธฐ ๊ธฐ๋ฅ์ ์ ๊ณตํ๋ ๋ํ์ฌ์ฐ๋ฃจ์ค์ ๊ธฐ๋ณธ ๋ธ๋ก๊ทธ ํ๋ฌ๊ทธ์ธ์ ๋๋ค.
ํผ๋ ๊ธฐ๋ฅ์ ๋น๋ ์ฐ์ถ๋ฌผ์์๋ง ์๋ํ๋ฉฐ ์ ํ ๋ฒ์ ์์๋ง ํ์ฑํ๋ฉ๋๋ค.
์ค์นโ
- npm
- Yarn
- pnpm
npm install --save @docusaurus/plugin-content-blog
yarn add @docusaurus/plugin-content-blog
pnpm add @docusaurus/plugin-content-blog
@docusaurus/preset-classic
์ ์ค์นํ ๊ฒฝ์ฐ์๋ ํ๋ฌ๊ทธ์ธ์ ๋ฐ๋ก ์ค์นํ ํ์๋ ์์ต๋๋ค.
ํ๋ฆฌ์ ์ต์ ์์ ํ๋ฌ๊ทธ์ธ์ ์ค์ ํ ์ ์์ต๋๋ค.
์ค์ โ
์ค์ ํ ์ ์๋ ํ๋
์ต์ ๋ช | ํ์ | ๊ธฐ๋ณธ๊ฐ | ์ค๋ช |
---|---|---|---|
path | string | 'blog' | ์ฌ์ดํธ ๋๋ ํ ๋ฆฌ์ ์๋์ ์ธ ํ์ผ ์์คํ ์ ๋ธ๋ก๊ทธ ์ฝํ ์ธ ๋๋ ํ ๋ฆฌ ๊ฒฝ๋ก์ ๋๋ค. |
editUrl | string | EditUrlFn | undefined | ์ฌ์ดํธ๋ฅผ ํธ์งํ๊ธฐ ์ํ Base URL์
๋๋ค. ์ต์ข
URL์ editUrl + relativePostPath ํํ๋ก ์ฒ๋ฆฌ๋ฉ๋๋ค. ์ต์
์ฌ์ฉ ์ ๊ฐ ํ์ผ์ ๋ํ ์ธ๋ฐํ ์ ์ด๋ฅผ ํ ์ ์์ต๋๋ค. ํด๋น ํ๋๋ฅผ ์ค์ ํ์ง ์์ผ๋ฉด ํธ์ง ๋งํฌ๊ฐ ๋นํ์ฑํ๋ฉ๋๋ค. |
editLocalizedFiles | boolean | false | ํธ์ง URL์ ํ์งํ๋์ง ์์ ์๋ณธ ํ์ผ ๋์ ํ์งํ๋ ํ์ผ์ ๋์์ผ๋ก ํฉ๋๋ค. editUrl ์ด ํจ์์ธ ๊ฒฝ์ฐ์๋ ๋ฌด์ํฉ๋๋ค. |
blogTitle | string | 'Blog' | ๋ ๋์ SEO๋ฅผ ์ํ ๋ธ๋ก๊ทธ ํ์ด์ง ์ ๋ชฉ |
blogDescription | string | 'Blog' | ๋ ๋์ SEO๋ฅผ ์ํ ๋ธ๋ก๊ทธ ํ์ด์ง ๋ฉํ ์ค๋ช |
blogSidebarCount | number | 'ALL' | 5 | ๋ธ๋ก๊ทธ ์ฌ์ด๋๋ฐ์ ํ์ํ ๋ธ๋ก๊ทธ ๊ฒ์๋ฌผ ์์
๋๋ค. ๋ชจ๋ ๋ธ๋ก๊ทธ ๊ฒ์๋ฌผ์ ํ์ํ๋ ค๋ฉด 'ALL' , ๊ฐ์ถ๋ ค๋ฉด 0 |
blogSidebarTitle | string | 'Recent posts' | ๋ธ๋ก๊ทธ ์ฌ์ด๋๋ฐ ์ ๋ชฉ |
routeBasePath | string | 'blog' | ์ฌ์ดํธ ๋ธ๋ก๊ทธ ์น์
์ ๋ํ URL ๋ผ์ฐํธ ํธ๋ ์ผ๋ง ์ฌ๋์๋ฅผ ํฌํจํ์ง ๋ง์ธ์. ๋ธ๋ก๊ทธ๋ฅผ ๋ฃจํธ ๊ฒฝ๋ก๋ก ์ค์ ํ ๋๋ง / ๋ฅผ ์ฌ์ฉํฉ๋๋ค. |
tagsBasePath | string | 'tags' | ๋ธ๋ก๊ทธ ํ๊ทธ ์น์
์ ๋ํ URL ๋ผ์ฐํธ routeBasePath ์ ์ถ๊ฐ๋ฉ๋๋ค. ํธ๋ ์ผ๋ง ์ฌ๋์๋ฅผ ํฌํจํ์ง ๋ง์ธ์. |
archiveBasePath | string | null | 'archive' | ๋ธ๋ก๊ทธ ์์นด์ด๋ธ ์น์
์ ๋ํ URL ๋ผ์ฐํธ routeBasePath ์ ์ถ๊ฐ๋ฉ๋๋ค. ํธ๋ ์ผ๋ง ์ฌ๋์๋ฅผ ํฌํจํ์ง ๋ง์ธ์. ์์นด์ด๋ธ ์์ฑ์ ํ์ง ์์ผ๋ ค๋ฉด null ๋ก ์ค์ ํฉ๋๋ค. |
include | string[] | ['**/*.{md,mdx}'] | ์ฝํ ์ธ ๊ฒฝ๋ก๋ฅผ ๊ธฐ์ค์ผ๋ก ๋น๋ํ ๋งํฌ๋ค์ด ํ์ผ๊ณผ ์ผ์นํ๋ glob ํจํด ๋ฐฐ์ด์ ๋๋ค. |
exclude | string[] | ์ค์ ์์๋ฅผ ์ฐธ์กฐํ์ธ์ | ์ ์ธํ ๋งํฌ๋ค์ด ํ์ผ๊ณผ ์ผ์นํ๋ glob ํจํด ๋ฐฐ์ด์
๋๋ค. include ์ต์
์ ์ข ๋ ์ธ๋ถํํ๋ ์ญํ ์ ํฉ๋๋ค. |
postsPerPage | number | 'ALL' | 10 | ๋ชฉ๋ก ํ์ด์ง์์ ํ์ด์ง ๋น ํ์ํ ๊ฒ์๋ฌผ ์์
๋๋ค. ํ๋์ ๋ชฉ๋ก ํ์ด์ง์ ๋ชจ๋ ๊ฒ์๋ฌผ์ ํ์ํ๋ ค๋ฉด 'ALL' ์ ์ค์ ํฉ๋๋ค. |
blogListComponent | string | '@theme/BlogListPage' | ๋ธ๋ก๊ทธ ๋ชฉ๋ก ํ์ด์ง์ ๋ฃจํธ ์ปดํฌ๋ํธ |
blogPostComponent | string | '@theme/BlogPostPage' | ๊ฐ ๋ธ๋ก๊ทธ ๊ฒ์๋ฌผ ํ์ด์ง์ ๋ฃจํธ ์ปดํฌ๋ํธ |
blogTagsListComponent | string | '@theme/BlogTagsListPage' | ํ๊ทธ ๋ชฉ๋ก ํ์ด์ง์ ๋ฃจํธ ์ปดํฌ๋ํธ |
blogTagsPostsComponent | string | '@theme/BlogTagsPostsPage' | "ํ๊ทธ๋ฅผ ํฌํจํ ๊ฒ์๋ฌผ" ํ์ด์ง์ ๋ฃจํธ ์ปดํฌ๋ํธ |
blogArchiveComponent | string | '@theme/BlogArchivePage' | ๋ธ๋ก๊ทธ ์์นด์ด๋ธ ํ์ด์ง์ ๋ฃจํธ ์ปดํฌ๋ํธ |
remarkPlugins | any[] | [] | MDX์ ์ ๋ฌ๋ Remark ํ๋ฌ๊ทธ์ธ |
rehypePlugins | any[] | [] | MDX์ ์ ๋ฌ๋ Rehype ํ๋ฌ๊ทธ์ธ |
beforeDefaultRemarkPlugins | any[] | [] | ๊ธฐ๋ณธ ๋ํ์ฌ์ฐ๋ฃจ์ค Remark ํ๋ฌ๊ทธ์ธ๋ณด๋ค ๋จผ์ MDX์ ์ ๋ฌ๋ ์ฌ์ฉ์ ์ง์ Remark ํ๋ฌ๊ทธ์ธ |
beforeDefaultRehypePlugins | any[] | [] | ๊ธฐ๋ณธ ๋ํ์ฌ์ฐ๋ฃจ์ค Rehype ํ๋ฌ๊ทธ์ธ๋ณด๋ค ๋จผ์ MDX์ ์ ๋ฌ๋ ์ฌ์ฉ์ ์ง์ Rehype ํ๋ฌ๊ทธ์ธ |
truncateMarker | RegExp | /<!--\s*(truncate)\s*-->/ | ์์ฝ์ด ๋๋๋ ๊ณณ์ ํ์ํ๋ Truncate marker |
showReadingTime | boolean | true | ๋ธ๋ก๊ทธ ๊ฒ์๋ฌผ์ ์์ ์ฝ๊ธฐ ์๊ฐ์ ํ์ |
readingTime | ReadingTimeFn | ๊ธฐ๋ณธ ์ฝ๊ธฐ ์๊ฐ | ํ์๋๋ ์ฝ๊ธฐ ์๊ฐ ์ซ์๋ฅผ ์ฌ์ฉ์ ์ง์ ํ๊ธฐ ์ํ ์ฝ๋ฐฑ |
authorsMapPath | string | 'authors.yml' | ๋ธ๋ก๊ทธ ์ฝํ ์ธ ๋๋ ํ ๋ฆฌ์ ์๋์ ์ธ ์์ฑ์ ๋งต ํ์ผ ๊ฒฝ๋ก |
feedOptions | ์๋๋ฅผ ์ฐธ์กฐํ์ธ์. | {type: ['rss', 'atom']} | ๋ธ๋ก๊ทธ ํผ๋ |
feedOptions.type | FeedType | FeedType[] | 'all' | null | ํ์ | ์์ฑํ ํผ๋ ์ ํ์
๋๋ค. ์์ฑ์ ํ์ง ์์ผ๋ ค๋ฉด null ๋ก ์ค์ ํฉ๋๋ค. |
feedOptions.title | string | siteConfig.title | ํผ๋ ์ ๋ชฉ |
feedOptions.description | string | `${siteConfig.title} Blog` | ํผ๋ ์ค๋ช |
feedOptions.copyright | string | undefined | ์ ์๊ถ ๋ฌธ๊ตฌ |
feedOptions.language | string (์ฌ์ฉํ ์ ์๋ ๊ฐ์ ๋ฌธ์๋ฅผ ์ฐธ๊ณ ) | undefined | ํผ๋ ์ธ์ด ๋ฉํ๋ฐ์ดํฐ |
sortPosts | 'descending' | 'ascending' | 'descending' | ๋ธ๋ก๊ทธ ๊ฒ์๋ฌผ ์ ๋ ฌ ์์ ์ค์ |
ํ์ โ
EditUrlFn
โ
type EditUrlFunction = (params: {
blogDirPath: string;
blogPath: string;
permalink: string;
locale: string;
}) => string | undefined;
ReadingTimeFn
โ
type ReadingTimeOptions = {
wordsPerMinute: number;
wordBound: (char: string) => boolean;
};
type ReadingTimeCalculator = (params: {
content: string;
frontMatter?: BlogPostFrontMatter & Record<string, unknown>;
options?: ReadingTimeOptions;
}) => number;
type ReadingTimeFn = (params: {
content: string;
frontMatter: BlogPostFrontMatter & Record<string, unknown>;
defaultReadingTime: ReadingTimeCalculator;
}) => number | undefined;
FeedType
โ
type FeedType = 'rss' | 'atom' | 'json';
์ค์ ์์โ
ํ๋ฆฌ์ ์ต์ ์ด๋ ํ๋ฌ๊ทธ์ธ ์ต์ ์์ ํ๋ฌ๊ทธ์ธ์ ์ค์ ํ ์ ์์ต๋๋ค.
๋๋ถ๋ถ์ ๋ํ์ฌ์ฐ๋ฃจ์ค ์ฌ์ฉ์๋ ํ๋ฆฌ์ ์ต์ ์ ์ฌ์ฉํด ํ๋ฌ๊ทธ์ธ์ ์ค์ ํฉ๋๋ค.
- ํ๋ฆฌ์ ์ต์
- ํ๋ฌ๊ทธ์ธ ์ต์
ํ๋ฆฌ์ ์ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ ํ๋ฆฌ์ ์ต์ ๋ฅผ ํตํด ํ๋ฌ๊ทธ์ธ์ ๊ตฌ์ฑํฉ๋๋ค.
module.exports = {
presets: [
[
'@docusaurus/preset-classic',
{
blog: {
path: 'blog',
// Simple use-case: string editUrl
// editUrl: 'https://github.com/facebook/docusaurus/edit/main/website/',
// Advanced use-case: functional editUrl
editUrl: ({locale, blogDirPath, blogPath, permalink}) =>
`https://github.com/facebook/docusaurus/edit/main/website/${blogDirPath}/${blogPath}`,
editLocalizedFiles: false,
blogTitle: 'Blog title',
blogDescription: 'Blog',
blogSidebarCount: 5,
blogSidebarTitle: 'All our posts',
routeBasePath: 'blog',
include: ['**/*.{md,mdx}'],
exclude: [
'**/_*.{js,jsx,ts,tsx,md,mdx}',
'**/_*/**',
'**/*.test.{js,jsx,ts,tsx}',
'**/__tests__/**',
],
postsPerPage: 10,
blogListComponent: '@theme/BlogListPage',
blogPostComponent: '@theme/BlogPostPage',
blogTagsListComponent: '@theme/BlogTagsListPage',
blogTagsPostsComponent: '@theme/BlogTagsPostsPage',
remarkPlugins: [require('remark-math')],
rehypePlugins: [],
beforeDefaultRemarkPlugins: [],
beforeDefaultRehypePlugins: [],
truncateMarker: /<!--\s*(truncate)\s*-->/,
showReadingTime: true,
feedOptions: {
type: '',
title: '',
description: '',
copyright: '',
language: undefined,
},
},
},
],
],
};
๋ ๋ฆฝ์ ์ผ๋ก ์คํ ๋๋ ํ๋ฌ๊ทธ์ธ์ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ์๋ ํ๋ฌ๊ทธ์ธ์ ๋ํ ์ต์ ์ ์ง์ ์ค์ ํ ์ ์์ต๋๋ค.
module.exports = {
plugins: [
[
'@docusaurus/plugin-content-blog',
{
path: 'blog',
// Simple use-case: string editUrl
// editUrl: 'https://github.com/facebook/docusaurus/edit/main/website/',
// Advanced use-case: functional editUrl
editUrl: ({locale, blogDirPath, blogPath, permalink}) =>
`https://github.com/facebook/docusaurus/edit/main/website/${blogDirPath}/${blogPath}`,
editLocalizedFiles: false,
blogTitle: 'Blog title',
blogDescription: 'Blog',
blogSidebarCount: 5,
blogSidebarTitle: 'All our posts',
routeBasePath: 'blog',
include: ['**/*.{md,mdx}'],
exclude: [
'**/_*.{js,jsx,ts,tsx,md,mdx}',
'**/_*/**',
'**/*.test.{js,jsx,ts,tsx}',
'**/__tests__/**',
],
postsPerPage: 10,
blogListComponent: '@theme/BlogListPage',
blogPostComponent: '@theme/BlogPostPage',
blogTagsListComponent: '@theme/BlogTagsListPage',
blogTagsPostsComponent: '@theme/BlogTagsPostsPage',
remarkPlugins: [require('remark-math')],
rehypePlugins: [],
beforeDefaultRemarkPlugins: [],
beforeDefaultRehypePlugins: [],
truncateMarker: /<!--\s*(truncate)\s*-->/,
showReadingTime: true,
feedOptions: {
type: '',
title: '',
description: '',
copyright: '',
language: undefined,
},
},
],
],
};
๋งํฌ๋ค์ด ํ๋ฐํธ ๋งคํฐโ
๋งํฌ๋ค์ด ๋ฌธ์์์๋ ---
๋ก ๊ฐ์ผ ๋งํฌ๋ค์ด ํ๋ฐํธ ๋งคํฐ ์์ญ์์ ์๋์ ๊ฐ์ ๋ฉํ๋ฐ์ดํฐ ํ๋๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค.
์ค์ ํ ์ ์๋ ํ๋
์ต์ ๋ช | ํ์ | ๊ธฐ๋ณธ๊ฐ | ์ค๋ช |
---|---|---|---|
authors | Authors | undefined | ๋ธ๋ก๊ทธ ๊ฒ์๋ฌผ ์์ฑ์๋ค(๋๋ ๋จ๋
์์ฑ์) ๋ชฉ๋ก ์์ธํ ์ค๋ช
์ authors ๊ฐ์ด๋๋ฅผ ์ฐธ์กฐํ์ธ์. ๋ธ๋ก๊ทธ ๊ฒ์๋ฌผ ์์ฑ์๊ฐ ํ ๋ช
์ธ ๊ฒฝ์ฐ์๋ author_* ๋ณด๋ค๋ authors ๋ฅผ ํ๋ฐํธ ๋งคํฐ ํ๋๋ก ๊ถ์ฅํฉ๋๋ค. |
author | string | undefined | โ ๏ธ authors ์ฌ์ฉ์ ๊ถ์ฅํฉ๋๋ค. ๋ธ๋ก๊ทธ ๊ฒ์๋ฌผ ์์ฑ์ ์ด๋ฆ์
๋๋ค. |
author_url | string | undefined | โ ๏ธ authors ์ฌ์ฉ์ ๊ถ์ฅํฉ๋๋ค. ์์ฑ์ ์ด๋ฆ์ ๋งํฌ๋ก ์ฐ๊ฒฐ๋ URL์ ์ค์ ํฉ๋๋ค. ๊นํ๋ธ๋ ํธ์ํฐ, ํ์ด์ค๋ถ ํ๋กํ ๋ฑ์ ์ฐ๊ฒฐํ ์ ์์ต๋๋ค. |
author_image_url | string | undefined | โ ๏ธ authors ์ฌ์ฉ์ ๊ถ์ฅํฉ๋๋ค. ์์ฑ์ ์ธ๋ค์ผ ์ด๋ฏธ์ง URL์ ์ค์ ํฉ๋๋ค. |
author_title | string | undefined | โ ๏ธ authors ์ฌ์ฉ์ ๊ถ์ฅํฉ๋๋ค. ์์ฑ์์ ๋ํ ์ค๋ช
์
๋๋ค. |
title | string | ๋งํฌ๋ค์ด ํ์ผ | ๋ธ๋ก๊ทธ ๊ฒ์๋ฌผ ์ ๋ชฉ |
date | string | ํ์ผ๋ช ๋๋ ํ์ผ ์์ฑ ์๊ฐ | ๋ธ๋ก๊ทธ ๊ฒ์๋ฌผ ์์ฑ ์๊ฐ. ํด๋น ํ๋๋ฅผ ์ค์ ํ์ง ์์ผ๋ฉด ํ์ผ ๋๋ ํด๋๋ช
์์ ์ถ์ถํ ์ ์์ต๋๋ค. ์ ๋ฅผ ๋ค๋ฉด ๋ค์๊ณผ ๊ฐ์ ํ์์
๋๋ค. 2021-04-15-blog-post.mdx , 2021-04-15-blog-post/index.mdx , 2021/04/15/blog-post.mdx . ๊ทธ๋ ์ง ์์ผ๋ฉด ๋งํฌ๋ค์ด ํ์ผ์ ์์ฑํ ์๊ฐ์ผ๋ก ์ค์ ๋ฉ๋๋ค. |
tags | Tag[] | undefined | ํฌ์คํธ๋ฅผ ํ๊ทธํ๊ธฐ ์ํ ๋ฌธ์์ด ๋๋ ์ค๋ธ์ ํธ์ ๋ชฉ๋ก์
๋๋ค. label ๊ณผ permalink 2๊ฐ์ ํ๋๋ก ๊ตฌ์ฑ๋ฉ๋๋ค. |
draft | boolean | false | ๋ธ๋ก๊ทธ ๊ฒ์๋ฌผ์ด ์์ ์ค์์ ๋ํ๋ด๋ ๋ถ์ธ ํ๋๊ทธ์ ๋๋ค. ๋น๊ณต๊ฐ ์ค์ ๊ฒ์๋ฌผ์ ๊ฐ๋ฐ ์ํ์์๋ง ํ์ธํ ์ ์์ต๋๋ค. |
hide_table_of_contents | boolean | false | ๋ชฉ์ฐจ๋ฅผ ์ค๋ฅธ์ชฝ์ผ๋ก ์จ๊ธธ์ง ์ฌ๋ถ |
toc_min_heading_level | number | 2 | ๋ชฉ์ฐจ์ ํ์๋๋ ์ต์ ์ ๋ชฉ ์์ค์ ๋๋ค. 2์์ 6 ์ฌ์ด์ ๊ฐ์ผ๋ก ์ค์ ํ ์ ์๊ณ ์ต๋๊ฐ๋ณด๋ค ์๊ฑฐ๋ ๊ฐ์์ผ ํฉ๋๋ค. |
toc_max_heading_level | number | 3 | ๋ชฉ์ฐจ์ ํ์๋๋ ์ต๋ ์ ๋ชฉ ์์ค์ ๋๋ค. 2์์ 6 ์ฌ์ด์ ๊ฐ์ผ๋ก ์ค์ ํ ์ ์์ต๋๋ค. |
keywords | string[] | undefined | <head> ํ๊ทธ ๋ด์ <meta name="keywords" content="keyword1,keyword2,..."/> ํํ๋ก ์์ฑ๋๋ ํค์๋ ๋ฉํ ํ๊ทธ๋ฅผ ์ค์ ํฉ๋๋ค. ๊ฒ์ ์์ง์์ ์ฌ์ฉํฉ๋๋ค. |
description | string | ๋งํฌ๋ค์ด ์ฝํ ์ธ ์ฒซ ๋ฒ์งธ ์ค | ๋ฌธ์์ ์ค๋ช
์ ๊ฒ์์์ง์์ ์ฌ์ฉํ ์ ์๊ฒ <head> ํ๊ทธ ์์ <meta name="description" content="..."/> ์ <meta property="og:description" content="..."/> ๋ก ์ฒ๋ฆฌ๋ฉ๋๋ค. |
image | string | undefined | ๊ฒ์๊ธ์ ๋ํ ๋งํฌ๋ฅผ ํ์ํ ๋ ๋ณด์ฌ์ง๋ ์ปค๋ฒ ๋๋ ์ฌ๋ค์ผ ์ด๋ฏธ์ง๋ฅผ ์ค์ ํฉ๋๋ค. |
slug | string | ํ์ผ ๊ฒฝ๋ก | ๋ธ๋ก๊ทธ ํฌ์คํธ URL์ ๋ณ๊ฒฝํ ์ ์๋๋ก ํ์ฉํฉ๋๋ค(/<routeBasePath>/<slug> ). ์ฌ๋ฌ ํจํด์ ์ค์ ํ ์๋ ์์ต๋๋ค: slug: my-blog-post , slug: /my/path/to/blog/post , slug: / . |
type Tag = string | {label: string; permalink: string};
// author key ๊ฐ์ ์ ์ญ ํ๋ฌ๊ทธ์ธ authors.yml ํ์ผ์์ author ํญ๋ชฉ์ ์ฐธ์กฐํฉ๋๋ค.
type AuthorKey = string;
type Author = {
key?: AuthorKey;
name: string;
title?: string;
url?: string;
image_url?: string;
};
// ํ๋ฐํธ ๋งคํฐ authors ํ๋๋ ๋ค์ํ ํํ๋ก ์ค์ ํ ์ ์์ต๋๋ค.
type Authors = AuthorKey | Author | (AuthorKey | Author)[];
์:
---
title: Welcome Docusaurus v2
authors:
- slorber
- yangshun
- name: Joel Marcey
title: Co-creator of Docusaurus 1
url: https://github.com/JoelMarcey
image_url: https://github.com/JoelMarcey.png
tags: [hello, docusaurus-v2]
description: This is my first post on Docusaurus 2.
image: https://i.imgur.com/mErPwqL.png
hide_table_of_contents: false
---
A Markdown blog post