Skip to main content
Version: 2.0.0-beta.0

πŸ“¦ plugin-content-docs

λ¬Έμ„œ λ§Œλ“€κΈ° κΈ°λŠ₯을 μ œκ³΅ν•˜λŠ” λ„νμ‚¬μš°λ£¨μŠ€μ˜ κΈ°λ³Έ λ¬Έμ„œ ν”ŒλŸ¬κ·ΈμΈμž…λ‹ˆλ‹€.

μ„€μΉ˜#

npm install --save @docusaurus/plugin-content-docs
tip

@docusaurus/preset-classic을 μ„€μΉ˜ν•œ κ²½μš°μ—λŠ” κΈ°λ³Έ νŽ˜μ΄μ§€ ν”ŒλŸ¬κ·ΈμΈμ„ λ”°λ‘œ μ„€μΉ˜ν•  ν•„μš”λŠ” μ—†μŠ΅λ‹ˆλ‹€. μ•„λž˜μ™€ 같이 μ„€μ •ν•˜λŠ” λŒ€μ‹  classic preset optionsμ—μ„œ μ„€μ •ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

μ„€μ •#

docusaurus.config.js
module.exports = {
plugins: [
[
'@docusaurus/plugin-content-docs',
{
/**
* μ‚¬μ΄νŠΈ λ””λ ‰ν„°λ¦¬μ˜ μƒλŒ€ 경둜둜 파일 μ‹œμŠ€ν…œμ˜ 데이터 경둜λ₯Ό μ„€μ •ν•©λ‹ˆλ‹€.
*/
path: 'docs',
/**
* μ—¬λŸ¬λΆ„μ˜ μ‚¬μ΄νŠΈλ₯Ό νŽΈμ§‘ν•˜κΈ° μœ„ν•œ Base url을 μ„€μ •ν•©λ‹ˆλ‹€.
* λ„νμ‚¬μš°λ£¨μŠ€λŠ” "editUrl + relativeDocPath" ν˜•μ‹μœΌλ‘œ μ‹€μ œ νŽΈμ§‘ν•  수 μžˆλŠ” editUrl을 μ²˜λ¦¬ν•©λ‹ˆλ‹€.
*/
editUrl: 'https://github.com/facebook/docusaurus/edit/master/website/',
/**
* ν•„μš”μ— 따라 각 λ§ˆν¬λ‹€μš΄ 파일의 editUrl을 직접 섀정해쀄 수 μžˆμŠ΅λ‹ˆλ‹€.
*/
editUrl: function ({
locale,
version,
versionDocsDirPath,
docPath,
permalink,
}) {
return `https://github.com/facebook/docusaurus/edit/master/website/${versionDocsDirPath}/${docPath}`;
},
/**
* λ²ˆμ—­λœ νŒŒμΌμ„ 깃에 μ»€λ°‹ν•˜λŠ” 경우 μœ μš©ν•œ μ„€μ •μž…λ‹ˆλ‹€.
* When markdown files are localized, the edit url will target the localized file,
* instead of the original unlocalized file.
* μ°Έκ³ : editUrl이 ν•¨μˆ˜μΈ κ²½μš°μ— ν•΄λ‹Ή μ˜΅μ…˜μ€ λ¬΄μ‹œλ©λ‹ˆλ‹€.
*/
editLocalizedFiles: false,
/**
* 이전 버전에 λŒ€ν•œ μ‚¬μš©μžμ˜ ν’€ λ¦¬ν€˜μŠ€νŠΈ μš”μ²­μ„ 막을 경우 μœ μš©ν•©λ‹ˆλ‹€.
* λ¬Έμ„œ 버전이 μ˜¬λΌκ°„ 경우 νŽΈμ§‘ν•  수 μžˆλŠ” url은 이전 버전 λ¬Έμ„œ λŒ€μ‹ 
* ν˜„μž¬ 버전 λ¬Έμ„œλ‘œ μ—°κ²°λ˜λ„λ‘ ν•©λ‹ˆλ‹€.
* μ°Έκ³ : editUrl이 ν•¨μˆ˜μΈ κ²½μš°μ— ν•΄λ‹Ή μ˜΅μ…˜μ€ λ¬΄μ‹œλ©λ‹ˆλ‹€.
*/
editCurrentVersion: false,
/**
* μ—¬λŸ¬λΆ„μ˜ μ‚¬μ΄νŠΈ λ¬Έμ„œ 디렉터리에 λŒ€ν•œ URL 경둜λ₯Ό μ„€μ •ν•©λ‹ˆλ‹€.
* *μ ˆλŒ€* URL 끝에 μŠ¬λž˜μ‹œλ₯Ό 뢙이지 λ§ˆμ„Έμš”.
* μ°Έκ³ : base 경둜 없이 λ°°ν¬λ˜λŠ” λ¬Έμ„œλŠ” `/`을 μ„€μ •ν•  μˆ˜λ„ μžˆμŠ΅λ‹ˆλ‹€.
*/
routeBasePath: 'docs',
include: ['**/*.md', '**/*.mdx'], // Extensions to include.
/**
* λ§ˆν¬λ‹€μš΄ νŽ˜μ΄μ§€ λͺ©λ‘μ„ λ³΄μ—¬μ£ΌλŠ” μ‚¬μ΄λ“œλ°” 경둜λ₯Ό μ„€μ •ν•©λ‹ˆλ‹€.
*/
sidebarPath: 'sidebars.js',
/**
* "autogenerated" νƒ€μž…μ˜ μ‚¬μ΄λ“œλ°” μ•„μ΄ν…œμ„ μ‹€μ œ μ‚¬μ΄λ“œλ°” μ•„μ΄ν…œ(λ¬Έμ„œ, μΉ΄ν…Œκ³ λ¦¬, 링크 λ“±)으둜
* λ°”κΎΈκΈ° μœ„ν•΄ μ‚¬μš©ν•˜λŠ” ν•¨μˆ˜μž…λ‹ˆλ‹€.
*/
sidebarItemsGenerator: async function ({
defaultSidebarItemsGenerator, // λ„νμ‚¬μš°λ£¨μŠ€μ—μ„œ μ‚¬μ΄λ“œλ°”λ₯Ό λ§Œλ“œλŠ” κΈ°λ³Έ λ‘œμ§μ„ μž¬μ‚¬μš©ν•˜κ±°λ‚˜ ν–₯μƒμ‹œν‚¬ λ•Œ μœ μš©ν•©λ‹ˆλ‹€.
numberPrefixParser, // ν”ŒλŸ¬κ·ΈμΈμ„ μœ„ν•œ numberPrefixParserλ₯Ό μ„€μ •ν•©λ‹ˆλ‹€.
item, // "autogenerated" νƒ€μž…μ˜ μ‚¬μ΄λ“œλ°” μ•„μ΄ν…œμž…λ‹ˆλ‹€.
version, // ν˜„μž¬ 버전을 μ„€μ •ν•©λ‹ˆλ‹€.
docs, // ν•΄λ‹Ή λ²„μ „μ˜ λͺ¨λ“  λ¬Έμ„œ(ν•„ν„°λ§ν•˜μ§€ μ•Šμ€)λ₯Ό μ„€μ •ν•©λ‹ˆλ‹€.
}) {
// μ‚¬μš©μž 지정 μ‚¬μ΄λ“œλ°” 슬라이슀λ₯Ό λ§Œλ“€κΈ° μœ„ν•΄ 주어진 데이터λ₯Ό μ‚¬μš©ν•©λ‹ˆλ‹€.
return [
{type: 'doc', id: 'intro'},
{
type: 'category',
label: 'Tutorials',
items: [
{type: 'doc', id: 'tutorial1'},
{type: 'doc', id: 'tutorial2'},
],
},
];
},
/**
* λ¬Έμ„œ ν”ŒλŸ¬κ·ΈμΈμ€ "01-My Folder/02.My Doc.md"같은 숫자 ν˜•μ‹μ˜ 접두사λ₯Ό μ§€μ›ν•©λ‹ˆλ‹€.
* 번호 μ ‘λ‘μ‚¬λŠ” μžλ™μœΌλ‘œ μΆ”μΆœλ˜μ–΄ μžλ™ μƒμ„±λœ μ‚¬μ΄λ“œλ°” μ•„μ΄ν…œμ˜ μ •λ ¬ μˆœμ„œλ‘œ μ‚¬μš©λ©λ‹ˆλ‹€.
* μ‚¬μš©μ„±μ„ μœ„ν•΄ κΈ°λ³Έ λ¬Έμ„œμ˜ id, 이름, 제λͺ©μ—μ„œ 숫자 μ ‘λ‘μ‚¬λŠ” μžλ™μœΌλ‘œ μ œκ±°λ©λ‹ˆλ‹€.
* ꡬ문 뢄석을 μœ„ν•œ λ‘œμ§μ—μ„œ λͺ¨λ“  μ‚¬μš© 방식과 파일λͺ… νŒ¨ν„΄μ„ ν—ˆμš©ν•˜λ„λ‘ μ„€μ •ν•  수 μžˆμŠ΅λ‹ˆλ‹€.
* "false"λ₯Ό μ„€μ •ν•˜λ©΄ 아무 λ™μž‘ 없이 λ¬Έμ„œλ₯Ό κ±΄λ“œλ¦¬μ§€ μ•Šμ€ μƒνƒœλ‘œ μœ μ§€ν•©λ‹ˆλ‹€.
*/
numberPrefixParser: function (filename) {
// 잠재적인 번호 접두사λ₯Ό μΆ”μΆœν•˜κΈ° μœ„ν•œ μ‚¬μš©μž 지정 λ‘œμ§μ„ κ΅¬ν˜„ν•©λ‹ˆλ‹€.
const numberPrefix = findNumberPrefix(filename);
// 접두사λ₯Ό λ°œκ²¬ν•˜λ©΄ μˆ˜μ •λœ 파일λͺ…κ³Ό ν•¨κ»˜ λ°˜ν™˜ν•©λ‹ˆλ‹€.
if (numberPrefix) {
return {
numberPrefix,
filename: filename.replace(prefix, ''),
};
}
// 접두사가 λ³„κ²¬λ˜μ§€ μ•ŠμœΌλ©΄
return {numberPrefix: undefined, filename};
},
/**
* λ¬Έμ„œ νŽ˜μ΄μ§€μ—μ„œ μ‚¬μš©ν•  ν…Œλ§ˆ μ»΄ν¬λ„ŒνŠΈλ₯Ό μ„€μ •ν•©λ‹ˆλ‹€.
*/
docLayoutComponent: '@theme/DocPage',
docItemComponent: '@theme/DocItem',
/**
* MDX에 전달할 Remark, Rehype ν”ŒλŸ¬κ·ΈμΈμ„ μ„€μ •ν•©λ‹ˆλ‹€.
*/
remarkPlugins: [
/* require('remark-math') */
],
rehypePlugins: [],
/**
* κΈ°λ³Έ Remark, Rehype ν”ŒλŸ¬κ·ΈμΈμ΄ 적용되기 전에
* MDX에 μ‚¬μš©μž 지정 Remark, Rehype ν”ŒλŸ¬κ·ΈμΈμ„ μ „λ‹¬ν•˜λ„λ‘ μ„€μ •ν•©λ‹ˆλ‹€.
*/
beforeDefaultRemarkPlugins: [],
beforeDefaultRehypePlugins: [],
/**
* Whether to display the author who last updated the doc.
*/
showLastUpdateAuthor: false,
/**
* Whether to display the last date the doc was updated.
*/
showLastUpdateTime: false,
/**
* By default, versioning is enabled on versioned sites.
* This is a way to explicitly disable the versioning feature.
*/
disableVersioning: false,
/**
* Skip the next release docs when versioning is enabled.
* This will not generate HTML files in the production build for documents
* in `/docs/next` directory, only versioned docs.
*/
excludeNextVersionDocs: false,
/**
* The last version is the one we navigate to in priority on versioned sites
* It is the one displayed by default in docs navbar items
* By default, the last version is the first one to appear in versions.json
* By default, the last version is at the "root" (docs have path=/docs/myDoc)
* Note: it is possible to configure the path and label of the last version
* Tip: using lastVersion: 'current' make sense in many cases
*/
lastVersion: undefined,
/**
* The docusaurus versioning defaults don't make sense for all projects
* This gives the ability customize the label and path of each version
* You may not like that default version
*/
versions: {
/*
Example configuration:
current: {
label: 'Android SDK v2.0.0 (WIP)',
path: 'android-2.0.0',
},
'1.0.0': {
label: 'Android SDK v1.0.0',
path: 'android-1.0.0',
},
*/
},
/**
* Sometimes you only want to include a subset of all available versions.
* Tip: limit to 2 or 3 versions to improve startup and build time in dev and deploy previews
*/
onlyIncludeVersions: undefined, // ex: ["current", "1.0.0", "2.0.0"]
},
],
],
};

λ§ˆν¬λ‹€μš΄ ν”„λŸ°νŠΈ 맀터#

λ§ˆν¬λ‹€μš΄ λ¬Έμ„œμ—μ„œλŠ” ---둜 감싼 λ§ˆν¬λ‹€μš΄ ν”„λŸ°νŠΈ 맀터 μ˜μ—­μ—μ„œ μ•„λž˜μ™€ 같은 메타데이터 ν•„λ“œλ₯Ό μ‚¬μš©ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

  • id: μœ μΌν•œ λ¬Έμ„œ idμž…λ‹ˆλ‹€. 값을 μ„€μ •ν•˜μ§€ μ•ŠμœΌλ©΄ λ¬Έμ„œ idλŠ” 파일λͺ…(ν™•μž₯자λ₯Ό μ œμ™Έν•œ)으둜 κΈ°λ³Έ μ„€μ •λ©λ‹ˆλ‹€.
  • title: λ¬Έμ„œ 제λͺ©μž…λ‹ˆλ‹€. 값을 μ„€μ •ν•˜μ§€ μ•ŠμœΌλ©΄ λ¬Έμ„œ title은 id κ°’μœΌλ‘œ κΈ°λ³Έ μ„€μ •λ©λ‹ˆλ‹€.
  • hide_title: λ¬Έμ„œ μƒλ‹¨μ—μ„œ 제λͺ©μ„ μˆ¨κΈΈμ§€ μ—¬λΆ€λ₯Ό μ„€μ •ν•©λ‹ˆλ‹€. 기본값은 falseμž…λ‹ˆλ‹€
  • hide_table_of_contents: 였λ₯Έμͺ½μ— ν‘œμ‹œλ˜λŠ” λͺ©μ°¨ μˆ¨κΉ€ μ—¬λΆ€λ₯Ό μ„€μ •ν•©λ‹ˆλ‹€. 기본값은 falseμž…λ‹ˆλ‹€
  • sidebar_label: μ‚¬μ΄λ“œλ°”μ™€ λ‹€μŒ/이전 λ²„νŠΌμ— ν‘œμ‹œν•  ν…μŠ€νŠΈλ₯Ό μ„€μ •ν•©λ‹ˆλ‹€. 값을 μ„€μ •ν•˜μ§€ μ•ŠμœΌλ©΄ λ¬Έμ„œ sidebar_label은 title κ°’μœΌλ‘œ κΈ°λ³Έ μ„€μ •λ©λ‹ˆλ‹€.
  • sidebar_position: autogenerated μ‚¬μ΄λ“œλ°” μ•„μ΄ν…œμ„ μ‚¬μš©ν•˜λŠ” 경우 λ§Œλ“€μ–΄μ§„ μ‚¬μ΄λ“œλ°” 슬라이슀 λ‚΄μ—μ„œ λ¬Έμ„œ μœ„μΉ˜λ₯Ό μ‘°μ •ν•  수 μžˆμŠ΅λ‹ˆλ‹€. Int λ˜λŠ” Float 값을 μ„€μ •ν•  수 μžˆμŠ΅λ‹ˆλ‹€.
  • parse_number_prefixes: λ¬Έμ„œμ— 번호 접두사(001 - My Doc.md, 2. MyDoc.md...)κ°€ μžˆλŠ” 경우 numberPrefixParser ν”ŒλŸ¬κ·ΈμΈμ—μ„œ μžλ™μœΌλ‘œ ꡬ문을 λΆ„μ„ν•˜κ³  μΆ”μΆœν•΄ sidebar_position으둜 번호 접두사λ₯Ό μ‚¬μš©ν•©λ‹ˆλ‹€. parse_number_prefixes: false둜 μ„€μ •ν•˜λ©΄ λ¬Έμ„œμ—μ„œ 번호 접두사 ꡬ문 뢄석을 μ‚¬μš©ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.
  • custom_edit_url: The URL for editing this document. If this field is not present, the document's edit URL will fall back to editUrl from options fields passed to docusaurus-plugin-content-docs
  • keywords: Keywords meta tag for the document page, for search engines
  • description: The description of your document, which will become the <meta name="description" content="..."/> and <meta property="og:description" content="..."/> in <head>, used by search engines. If this field is not present, it will default to the first line of the contents
  • image: Cover or thumbnail image that will be used when displaying the link to your post
  • slug: λ¬Έμ„œ url을 λ³€κ²½ν•  수 μžˆλ„λ‘ ν—ˆμš©ν•©λ‹ˆλ‹€(/<routeBasePath>/<slug>). μ—¬λŸ¬ νŒ¨ν„΄μ„ μ„€μ •ν•  μˆ˜λ„ μžˆμŠ΅λ‹ˆλ‹€: slug: my-doc, slug: /my/path/myDoc, slug: /

예:

---
id: doc-markdown
title: Markdown Features
hide_title: false
hide_table_of_contents: false
sidebar_label: Markdown :)
custom_edit_url: https://github.com/facebook/docusaurus/edit/master/docs/api-doc-markdown.md
description: How do I find you when I cannot solve this problem
keywords:
- docs
- docusaurus
image: https://i.imgur.com/mErPwqL.png
slug: /myDoc
---
My Document Markdown content

i18n#

i18n μ†Œκ°œ λ¬Έμ„œλ₯Ό λ¨Όμ € ν™•μΈν•΄μ£Όμ„Έμš”.

λ²ˆμ—­ 파일 μœ„μΉ˜#

  • κΈ°λ³Έ 경둜: website/i18n/<locale>/docusaurus-plugin-content-docs
  • λ©€ν‹° μΈμŠ€ν„΄μŠ€ 경둜: website/i18n/<locale>/docusaurus-plugin-content-docs-<pluginId>
  • JSON 파일: extracted with docusaurus write-translations
  • λ§ˆν¬λ‹€μš΄ 파일: website/i18n/<locale>/docusaurus-plugin-content-docs/<version>

파일 μ‹œμŠ€ν…œ ꡬ쑰 예#

website/i18n/<locale>/docusaurus-plugin-content-docs
β”‚
β”‚ # translations for website/docs
β”œβ”€β”€ current
β”‚Β Β  β”œβ”€β”€ api
β”‚Β Β  β”‚Β Β  └── config.md
β”‚Β Β  └── getting-started.md
β”œβ”€β”€ current.json
β”‚
β”‚ # translations for website/versioned_docs/version-1.0.0
β”œβ”€β”€ version-1.0.0
β”‚Β Β  β”œβ”€β”€ api
β”‚Β Β  β”‚Β Β  └── config.md
β”‚Β Β  └── getting-started.md
└── version-1.0.0.json