플러그인 사용하기
The Docusaurus core doesn't provide any feature of its own. All features are delegated to individual plugins: the docs feature provided by the docs plugin; the blog feature provided by the blog plugin; or individual pages provided by the pages plugin. 플러그인이 설치되어 있지 않으면 사이트에 어떤 경로도 포함할 수 없습니다.
You may not need to install common plugins one-by-one though: they can be distributed as a bundle in a preset. 대부분 사용자의 경우 플러그인은 사전 설정된 구성을 통해 제공됩니다.
We maintain a list of official plugins, but the community has also created some unofficial plugins. If you want to add any feature: autogenerating doc pages, executing custom scripts, integrating other services... be sure to check out the list: someone may have implemented it for you!
If you are feeling energetic, you can also read the plugin guide or plugin method references for how to make a plugin yourself.
Installing a plugin
플러그인은 npm 패키지 형태로 제공됩니다. npm을 사용해 다른 npm 패키지처럼 설치할 수 있습니다.
- npm
- Yarn
- pnpm
npm install --save docusaurus-plugin-name
yarn add docusaurus-plugin-name
pnpm add docusaurus-plugin-name
Then you add it in your site's docusaurus.config.js
's plugins
option:
export default {
// ...
plugins: ['@docusaurus/plugin-content-pages'],
};
도큐사우루스는 로컬 디렉터리에서 플러그인을 불러올 수도 있습니다. 다음과 같이 설정합니다.
export default {
// ...
plugins: ['./src/plugins/docusaurus-local-plugin'],
};
경로는 구성 파일에 절대적이거나 상대적이어야 합니다.
Configuring plugins
대부분 플러그인을 기본적으로 사용하려면 플러그인 이름과 플러그인이 설치된 경로를 설정해주어야 합니다.
하지만 플러그인은 설정 시 이름과 옵션 오브젝트를 2개의 멤버를 가지는 튜플 형태로 감싸서 설정할 수 있는 기능을 지원합니다. 이런 형식을 "Babel Style"이라고 합니다.
export default {
// ...
plugins: [
[
'@docusaurus/plugin-xxx',
{
/* options */
},
],
],
};
예:
export default {
plugins: [
// Basic usage.
'@docusaurus/plugin-debug',
// With options object (babel style)
[
'@docusaurus/plugin-sitemap',
{
changefreq: 'weekly',
},
],
],
};
Multi-instance plugins and plugin IDs
모든 도큐사우루스 콘텐츠 플러그인은 멀티 플러그인 인스턴스를 지원합니다. For example, it may be useful to have multiple docs plugin instances or multiple blogs. It is required to assign a unique ID to each plugin instance, and by default, the plugin ID is default
.
export default {
plugins: [
[
'@docusaurus/plugin-content-docs',
{
id: 'docs-1',
// other options
},
],
[
'@docusaurus/plugin-content-docs',
{
id: 'docs-2',
// other options
},
],
],
};
At most one plugin instance can be the "default plugin instance", by omitting the id
attribute, or using id: 'default'
.
Using themes
테마는 플러그인과 똑같은 방식으로 로드됩니다. From the consumer perspective, the themes
and plugins
entries are interchangeable when installing and configuring a plugin. The only nuance is that themes are loaded after plugins, and it's possible for a theme to override a plugin's default theme components.
The themes
and plugins
options lead to different shorthand resolutions, so if you want to take advantage of shorthands, be sure to use the right entry!
export default {
// ...
themes: ['@docusaurus/theme-classic', '@docusaurus/theme-live-codeblock'],
};
Using presets
프리셋(Preset)은 플러그인과 테마의 번들입니다. For example, instead of letting you register and configure @docusaurus/plugin-content-docs
, @docusaurus/plugin-content-blog
, etc. one after the other in the config file, we have @docusaurus/preset-classic
preset allows you to configure them in one centralized place.
@docusaurus/preset-classic
The classic preset is shipped by default to new Docusaurus websites created with create-docusaurus
. 다음 테마와 플러그인이 포함되어 있습니다.
@docusaurus/theme-classic
@docusaurus/theme-search-algolia
@docusaurus/plugin-content-docs
@docusaurus/plugin-content-blog
@docusaurus/plugin-content-pages
@docusaurus/plugin-debug
@docusaurus/plugin-google-gtag
@docusaurus/plugin-google-tag-manager
@docusaurus/plugin-google-analytics
(deprecated)@docusaurus/plugin-sitemap
classic 프리셋은 각 옵션 항목을 해당 플러그인/테마로 전달합니다.
export default {
presets: [
[
'@docusaurus/preset-classic',
{
// Debug defaults to true in dev, false in prod
debug: undefined,
// Will be passed to @docusaurus/theme-classic.
theme: {
customCss: ['./src/css/custom.css'],
},
// Will be passed to @docusaurus/plugin-content-docs (false to disable)
docs: {},
// Will be passed to @docusaurus/plugin-content-blog (false to disable)
blog: {},
// Will be passed to @docusaurus/plugin-content-pages (false to disable)
pages: {},
// Will be passed to @docusaurus/plugin-sitemap (false to disable)
sitemap: {},
// Will be passed to @docusaurus/plugin-google-gtag (only enabled when explicitly specified)
gtag: {},
// Will be passed to @docusaurus/plugin-google-tag-manager (only enabled when explicitly specified)
googleTagManager: {},
// DEPRECATED: Will be passed to @docusaurus/plugin-google-analytics (only enabled when explicitly specified)
googleAnalytics: {},
},
],
],
};
Installing presets
프리셋은 npm 패키지 형태로 제공됩니다. npm을 사용해 다른 npm 패키지처럼 설치할 수 있습니다.
- npm
- Yarn
- pnpm
npm install --save @docusaurus/preset-classic
yarn add @docusaurus/preset-classic
pnpm add @docusaurus/preset-classic
Then, add it in your site's docusaurus.config.js
's presets
option:
export default {
// ...
presets: ['@docusaurus/preset-classic'],
};