mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-22 21:47:01 +02:00
feat: properly type-check the Docusaurus config of new sites (#5589)
* fix: makes types DocusaurusConfig optional to match docs * add UserDocusaurusConfig with required keys for user config * convert UserDocusaurusConfig to use util type * Docusaurus website config should be type-checked by CI + fix all existing issues * add doc for config typechecking * Update template configs for TS autocompletion * fix last config typechecking bugs * reapply prettier * reapply prettier-docs * Fix TS doc: add missing () * fix some docu plugin types * add "const config" for simpler jsdoc annotation Co-authored-by: slorber <lorber.sebastien@gmail.com>
This commit is contained in:
parent
3f1f8255a2
commit
09550b0535
24 changed files with 115 additions and 35 deletions
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
declare module '@docusaurus/plugin-content-blog' {
|
||||
export type Options = import('./types').PluginOptions;
|
||||
export type Options = Partial<import('./types').UserPluginOptions>;
|
||||
}
|
||||
|
||||
declare module '@theme/BlogSidebar' {
|
||||
|
|
|
@ -11,6 +11,7 @@ import type {
|
|||
BrokenMarkdownLink,
|
||||
ContentPaths,
|
||||
} from '@docusaurus/utils/lib/markdownLinks';
|
||||
import {Overwrite} from 'utility-types';
|
||||
|
||||
export type BlogContentPaths = ContentPaths;
|
||||
|
||||
|
@ -24,6 +25,20 @@ export interface BlogContent {
|
|||
|
||||
export type FeedType = 'rss' | 'atom';
|
||||
|
||||
export type FeedOptions = {
|
||||
type?: FeedType[] | null;
|
||||
title?: string;
|
||||
description?: string;
|
||||
copyright: string;
|
||||
language?: string;
|
||||
};
|
||||
|
||||
// Feed options, as provided by user config
|
||||
export type UserFeedOptions = Overwrite<
|
||||
Partial<FeedOptions>,
|
||||
{type?: FeedOptions['type'] | 'all'} // Handle the type: "all" shortcut
|
||||
>;
|
||||
|
||||
export type EditUrlFunction = (editUrlParams: {
|
||||
blogDirPath: string;
|
||||
blogPath: string;
|
||||
|
@ -63,6 +78,12 @@ export type PluginOptions = RemarkAndRehypePluginOptions & {
|
|||
authorsMapPath: string;
|
||||
};
|
||||
|
||||
// Options, as provided in the user config (before normalization)
|
||||
export type UserPluginOptions = Overwrite<
|
||||
Partial<PluginOptions>,
|
||||
{feedOptions?: UserFeedOptions}
|
||||
>;
|
||||
|
||||
export interface BlogTags {
|
||||
[key: string]: BlogTag;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue