mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-02 08:19:07 +02:00
feat: TypeScript presets/plugins should expose Options typing (#5456)
* each TS plugin should export option types + preset export option / themeConfig types + remove TS typechecking for the bootstrap theme * each TS plugin should export option types + preset export option / themeConfig types + remove TS typechecking for the bootstrap theme * fix remaining TS errors * fix remaining TS errors * TS fix * Add JSDoc type annotations to init templates and TS docs * missing title char
This commit is contained in:
parent
013cfc07bb
commit
553f914639
23 changed files with 514 additions and 403 deletions
|
@ -42,7 +42,7 @@ It is **not possible** to use a TypeScript config file in Docusaurus, unless you
|
|||
|
||||
We recommend using [JSDoc type annotations](https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html):
|
||||
|
||||
```js title="docusaurus.config.js
|
||||
```js title="docusaurus.config.js"
|
||||
// highlight-start
|
||||
/** @type {import('@docusaurus/types').Plugin} */
|
||||
// highlight-end
|
||||
|
@ -55,15 +55,49 @@ function MyPlugin(context, options) {
|
|||
// highlight-start
|
||||
/** @type {import('@docusaurus/types').DocusaurusConfig} */
|
||||
// highlight-end
|
||||
const config = {
|
||||
(module.exports = {
|
||||
title: 'Docusaurus',
|
||||
tagline: 'Build optimized websites quickly, focus on your content',
|
||||
organizationName: 'facebook',
|
||||
projectName: 'docusaurus',
|
||||
plugins: [MyPlugin],
|
||||
};
|
||||
|
||||
module.exports = config;
|
||||
presets: [
|
||||
[
|
||||
'@docusaurus/preset-classic',
|
||||
// highlight-start
|
||||
/** @type {import('@docusaurus/preset-classic').Options} */
|
||||
// highlight-end
|
||||
({
|
||||
docs: {
|
||||
path: 'docs',
|
||||
sidebarPath: 'sidebars.js',
|
||||
},
|
||||
blog: {
|
||||
path: 'blog',
|
||||
postsPerPage: 5,
|
||||
},
|
||||
}),
|
||||
],
|
||||
],
|
||||
themeConfig:
|
||||
// highlight-start
|
||||
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
|
||||
// highlight-end
|
||||
({
|
||||
colorMode: {
|
||||
defaultMode: 'dark',
|
||||
},
|
||||
navbar: {
|
||||
hideOnScroll: true,
|
||||
title: 'Docusaurus',
|
||||
logo: {
|
||||
alt: 'Docusaurus Logo',
|
||||
src: 'img/docusaurus.svg',
|
||||
srcDark: 'img/docusaurus_keytar.svg',
|
||||
},
|
||||
},
|
||||
}),
|
||||
});
|
||||
```
|
||||
|
||||
:::tip
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue