mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 15:47:23 +02:00
refactor: replace non-prop interface with type; allow plugin lifecycles to have sync type (#7080)
* refactor: replace non-prop interface with type; allow plugin lifecycles to have sync type * fix
This commit is contained in:
parent
ce2b631455
commit
24c205a835
38 changed files with 145 additions and 138 deletions
|
@ -265,10 +265,13 @@ describe('validateDocFrontMatter tags', () => {
|
|||
validFrontMatters: [{}, {tags: undefined}, {tags: ['tag1', 'tag2']}],
|
||||
convertibleFrontMatter: [[{tags: ['tag1', 42]}, {tags: ['tag1', '42']}]],
|
||||
invalidFrontMatters: [
|
||||
[{tags: 42}, '"tags" does not look like a valid FrontMatter Yaml array.'],
|
||||
[
|
||||
{tags: 42},
|
||||
'"tags" does not look like a valid front matter Yaml array.',
|
||||
],
|
||||
[
|
||||
{tags: 'tag1, tag2'},
|
||||
'"tags" does not look like a valid FrontMatter Yaml array.',
|
||||
'"tags" does not look like a valid front matter Yaml array.',
|
||||
],
|
||||
[{tags: [{}]}, '"tags[0]" does not look like a valid tag'],
|
||||
[{tags: [true]}, '"tags[0]" does not look like a valid tag'],
|
||||
|
|
|
@ -106,7 +106,7 @@ export default async function pluginContentDocs(
|
|||
});
|
||||
},
|
||||
|
||||
async getTranslationFiles({content}) {
|
||||
getTranslationFiles({content}) {
|
||||
return getLoadedContentTranslationFiles(content);
|
||||
},
|
||||
|
||||
|
|
|
@ -10,9 +10,9 @@ declare module '@docusaurus/plugin-content-docs' {
|
|||
import type {ContentPaths, Tag, FrontMatterTag} from '@docusaurus/utils';
|
||||
import type {Required} from 'utility-types';
|
||||
|
||||
export interface Assets {
|
||||
export type Assets = {
|
||||
image?: string;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Custom callback for parsing number prefixes from file/folder names.
|
||||
|
|
|
@ -254,18 +254,15 @@ export type SidebarItemsGenerator = (
|
|||
generatorArgs: SidebarItemsGeneratorArgs,
|
||||
) => Promise<NormalizedSidebar>;
|
||||
|
||||
// Also inject the default generator to conveniently wrap/enhance/sort the
|
||||
// default sidebar gen logic
|
||||
// see https://github.com/facebook/docusaurus/issues/4640#issuecomment-822292320
|
||||
export type SidebarItemsGeneratorOptionArgs = {
|
||||
/**
|
||||
* Useful to re-use/enhance the default sidebar generation logic from
|
||||
* Docusaurus.
|
||||
*/
|
||||
defaultSidebarItemsGenerator: SidebarItemsGenerator;
|
||||
} & SidebarItemsGeneratorArgs;
|
||||
export type SidebarItemsGeneratorOption = (
|
||||
generatorArgs: SidebarItemsGeneratorOptionArgs,
|
||||
generatorArgs: {
|
||||
/**
|
||||
* Useful to re-use/enhance the default sidebar generation logic from
|
||||
* Docusaurus.
|
||||
* @see https://github.com/facebook/docusaurus/issues/4640#issuecomment-822292320
|
||||
*/
|
||||
defaultSidebarItemsGenerator: SidebarItemsGenerator;
|
||||
} & SidebarItemsGeneratorArgs,
|
||||
) => Promise<NormalizedSidebarItem[]>;
|
||||
|
||||
export type SidebarProcessorParams = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue