主题配置
This configuration applies to all main themes.
Common
Color mode
经典主题默认提供浅色主题和暗黑主题,用户可以通过导航栏切换。
It is possible to customize the color mode support within the colorMode
object.
接受的字段:
参数 | 类型 | 默认值 | 描述 |
---|---|---|---|
defaultMode | 'light' | 'dark' | 'light' | 用户首次访问网站时的色彩模式。 |
disableSwitch | boolean | false | 在导航栏隐藏按钮。 如果你想要只支持一种色彩模式很有用。 |
respectPrefersColorScheme | boolean | false | Whether to use the prefers-color-scheme media-query, using user system preferences, instead of the hardcoded defaultMode . |
示例配置:
docusaurus.config.js
module.exports = {
themeConfig: {
colorMode: {
defaultMode: 'light',
disableSwitch: false,
respectPrefersColorScheme: false,
},
},
};
warning
With respectPrefersColorScheme: true
, the defaultMode
is overridden by user system preferences.
如果你只想支持一种色彩模式,你大概率会想要忽略用户系统的偏好设置。
Meta image
You can configure a default image that will be used for your meta tag, in particular og:image
and twitter:image
.
接受的字段:
参数 | 类型 | 默认值 | 描述 |
---|---|---|---|
image | string | undefined | 网站的元数据图像 URL。 相对于你的网站的静态目录。 不能是 SVG。 可以是外部链接。 |
示例配置:
docusaurus.config.js
module.exports = {
themeConfig: {
image: 'img/docusaurus.png',
},
};