π¦ 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';
μ€μ μμβ
ν리μ μ΅μ μ΄λ νλ¬κ·ΈμΈ μ΅μ μμ νλ¬κ·ΈμΈμ μ€μ ν μ μμ΅λλ€.
λλΆλΆμ λνμ¬μ°λ£¨μ€ μ¬μ©μλ ν리μ μ΅μ μ μ¬μ©ν΄ νλ¬κ·ΈμΈμ μ€μ ν©λλ€.
- Preset options
- Plugin options
If you use a preset, configure this plugin through the preset options:
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,
},
},
},
],
],
};
If you are using a standalone plugin, provide options directly to the plugin:
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
i18nβ
i18n μκ° λ¬Έμλ₯Ό λ¨Όμ νμΈν΄μ£ΌμΈμ.
λ²μ νμΌ μμΉβ
- Base path:
website/i18n/[locale]/docusaurus-plugin-content-blog
- Multi-instance path:
website/i18n/[locale]/docusaurus-plugin-content-blog-[pluginId]
- JSON νμΌ:
docusaurus write-translations
λͺ λ Ή μ€ν ν λ§λ€μ΄μ§ νμΌ - Markdown files:
website/i18n/[locale]/docusaurus-plugin-content-blog
νμΌ μμ€ν ꡬ쑰 μβ
website/i18n/[locale]/docusaurus-plugin-content-blog
β
β # website/blogμ λν λ²μ
βββ authors.yml
βββ first-blog-post.md
βββ second-blog-post.md
β
β # λ λλ§λ νλ¬κ·ΈμΈ μ΅μ
μ λν λ²μ
βββ options.json