Configuração
Docusaurus tem uma visão única das configurações. We encourage you to congregate information about your site into one place. We guard the fields of this file and facilitate making this data object accessible across your site.
Keeping a well-maintained docusaurus.config.js
helps you, your collaborators, and your open source contributors to be able to focus on documentation while still being able to customize the site.
What goes into a docusaurus.config.js
?
You should not have to write your docusaurus.config.js
from scratch even if you are developing your site. All templates come with a docusaurus.config.js
that includes defaults for the common options.
No entanto, pode ser útil se você tiver um alto nível de compreensão de como as configurações são projetadas e implementadas.
A visão geral de alto nível da configuração do Docusaurus pode ser categorizada em:
For exact reference to each of the configurable fields, you may refer to docusaurus.config.js
API reference.
Site metadata
Site metadata contains the essential global metadata such as title
, url
, baseUrl
, and favicon
.
They are used in several places such as your site's title and headings, browser tab icon, social sharing (Facebook, Twitter) information or even to generate the correct path to serve your static files.
Deployment configurations
Deployment configurations such as projectName
, organizationName
, and optionally deploymentBranch
are used when you deploy your site with the deploy
command.
It is recommended to check the deployment docs for more information.
Theme, plugin, and preset configurations
List the themes, plugins, and presets for your site in the themes
, plugins
, and presets
fields, respectively. Estes são normalmente pacotes npm:
module.exports = {
// ...
plugins: [
'@docusaurus/plugin-content-blog',
'@docusaurus/plugin-content-pages',
],
themes: ['@docusaurus/theme-classic'],
};
Docusaurus supports module shorthands, allowing you to simplify the above configuration as:
module.exports = {
// ...
plugins: ['content-blog', 'content-pages'],
themes: ['classic'],
};
Eles também podem ser carregados a partir de diretórios locais:
const path = require('path');
module.exports = {
// ...
themes: [path.resolve(__dirname, '/path/to/docusaurus-local-theme')],
};