mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 15:47:23 +02:00
fix(*): make TypeScript realize that each plugin package has a default export (#7294)
This commit is contained in:
parent
b49ae67521
commit
a2c993bf9a
43 changed files with 208 additions and 187 deletions
|
@ -3,7 +3,7 @@
|
|||
"version": "2.0.0-beta.18",
|
||||
"description": "Client redirects plugin for Docusaurus.",
|
||||
"main": "lib/index.js",
|
||||
"types": "src/plugin-client-redirects.d.ts",
|
||||
"types": "lib/index.d.ts",
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"watch": "tsc --watch"
|
||||
|
|
|
@ -10,7 +10,7 @@ import collectRedirects from '../collectRedirects';
|
|||
import {validateOptions} from '../options';
|
||||
import {removeTrailingSlash} from '@docusaurus/utils';
|
||||
import {normalizePluginOptions} from '@docusaurus/utils-validation';
|
||||
import type {Options} from '@docusaurus/plugin-client-redirects';
|
||||
import type {Options} from '../options';
|
||||
|
||||
function createTestPluginContext(
|
||||
options?: Options,
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import {validateOptions, DEFAULT_OPTIONS} from '../options';
|
||||
import {normalizePluginOptions} from '@docusaurus/utils-validation';
|
||||
import type {Options} from '@docusaurus/plugin-client-redirects';
|
||||
import type {Options} from '../options';
|
||||
|
||||
function testValidate(options: Options) {
|
||||
return validateOptions({validate: normalizePluginOptions, options});
|
||||
|
|
|
@ -6,10 +6,7 @@
|
|||
*/
|
||||
|
||||
import _ from 'lodash';
|
||||
import type {
|
||||
PluginOptions,
|
||||
RedirectOption,
|
||||
} from '@docusaurus/plugin-client-redirects';
|
||||
import type {PluginOptions, RedirectOption} from './options';
|
||||
import type {PluginContext, RedirectMetadata} from './types';
|
||||
import {
|
||||
createFromExtensionsRedirects,
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import type {LoadContext, Plugin} from '@docusaurus/types';
|
||||
import type {PluginContext, RedirectMetadata} from './types';
|
||||
import type {PluginOptions} from '@docusaurus/plugin-client-redirects';
|
||||
import type {PluginOptions, Options} from './options';
|
||||
|
||||
import collectRedirects from './collectRedirects';
|
||||
import writeRedirectFiles, {
|
||||
|
@ -52,3 +52,4 @@ export default function pluginClientRedirectsPages(
|
|||
}
|
||||
|
||||
export {validateOptions} from './options';
|
||||
export type {PluginOptions, Options};
|
||||
|
|
|
@ -5,14 +5,35 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import type {
|
||||
PluginOptions,
|
||||
Options,
|
||||
RedirectOption,
|
||||
} from '@docusaurus/plugin-client-redirects';
|
||||
import type {OptionValidationContext} from '@docusaurus/types';
|
||||
import {Joi, PathnameSchema} from '@docusaurus/utils-validation';
|
||||
|
||||
export type RedirectOption = {
|
||||
to: string;
|
||||
from: string | string[];
|
||||
};
|
||||
|
||||
export type PluginOptions = {
|
||||
/** Plugin ID. */
|
||||
id: string;
|
||||
/** The extensions to be removed from the route after redirecting. */
|
||||
fromExtensions: string[];
|
||||
/** The extensions to be appended to the route after redirecting. */
|
||||
toExtensions: string[];
|
||||
/** The list of redirect rules, each one with multiple `from`s → one `to`. */
|
||||
redirects: RedirectOption[];
|
||||
/**
|
||||
* A callback to create a redirect rule.
|
||||
* @returns All the paths from which we should redirect to `path`
|
||||
*/
|
||||
createRedirects?: (
|
||||
/** An existing Docusaurus route path */
|
||||
path: string,
|
||||
) => string[] | string | null | undefined;
|
||||
};
|
||||
|
||||
export type Options = Partial<PluginOptions>;
|
||||
|
||||
export const DEFAULT_OPTIONS: Partial<PluginOptions> = {
|
||||
fromExtensions: [],
|
||||
toExtensions: [],
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
export type RedirectOption = {
|
||||
to: string;
|
||||
from: string | string[];
|
||||
};
|
||||
|
||||
export type PluginOptions = {
|
||||
/** Plugin ID. */
|
||||
id: string;
|
||||
/** The extensions to be removed from the route after redirecting. */
|
||||
fromExtensions: string[];
|
||||
/** The extensions to be appended to the route after redirecting. */
|
||||
toExtensions: string[];
|
||||
/** The list of redirect rules, each one with multiple `from`s → one `to`. */
|
||||
redirects: RedirectOption[];
|
||||
/**
|
||||
* A callback to create a redirect rule.
|
||||
* @returns All the paths from which we should redirect to `path`
|
||||
*/
|
||||
createRedirects?: (
|
||||
/** An existing Docusaurus route path */
|
||||
path: string,
|
||||
) => string[] | string | null | undefined;
|
||||
};
|
||||
|
||||
export type Options = Partial<PluginOptions>;
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
import type {Props} from '@docusaurus/types';
|
||||
import type {PluginOptions} from '@docusaurus/plugin-client-redirects';
|
||||
import type {PluginOptions} from './options';
|
||||
|
||||
/**
|
||||
* The minimal infos the plugin needs to work
|
||||
|
|
|
@ -9,13 +9,7 @@ import fs from 'fs-extra';
|
|||
import path from 'path';
|
||||
import readingTime from 'reading-time';
|
||||
import _ from 'lodash';
|
||||
import type {
|
||||
BlogPost,
|
||||
BlogContentPaths,
|
||||
BlogMarkdownLoaderOptions,
|
||||
BlogTags,
|
||||
BlogPaginated,
|
||||
} from './types';
|
||||
import type {BlogContentPaths, BlogMarkdownLoaderOptions} from './types';
|
||||
import {
|
||||
parseMarkdownString,
|
||||
normalizeUrl,
|
||||
|
@ -37,6 +31,9 @@ import logger from '@docusaurus/logger';
|
|||
import type {
|
||||
PluginOptions,
|
||||
ReadingTimeFunction,
|
||||
BlogPost,
|
||||
BlogTags,
|
||||
BlogPaginated,
|
||||
} from '@docusaurus/plugin-content-blog';
|
||||
|
||||
export function truncate(fileString: string, truncateMarker: RegExp): string {
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
*/
|
||||
|
||||
import {Feed, type Author as FeedAuthor, type Item as FeedItem} from 'feed';
|
||||
import type {BlogPost} from './types';
|
||||
import {normalizeUrl, readOutputHTMLFile} from '@docusaurus/utils';
|
||||
import {load as cheerioLoad} from 'cheerio';
|
||||
import type {DocusaurusConfig} from '@docusaurus/types';
|
||||
|
@ -16,6 +15,7 @@ import type {
|
|||
FeedType,
|
||||
PluginOptions,
|
||||
Author,
|
||||
BlogPost,
|
||||
} from '@docusaurus/plugin-content-blog';
|
||||
import {blogPostContainerID} from '@docusaurus/utils-common';
|
||||
|
||||
|
|
|
@ -25,14 +25,7 @@ import {
|
|||
} from '@docusaurus/utils';
|
||||
import {translateContent, getTranslationFiles} from './translations';
|
||||
|
||||
import type {
|
||||
BlogTag,
|
||||
BlogTags,
|
||||
BlogContent,
|
||||
BlogPaginated,
|
||||
BlogContentPaths,
|
||||
BlogMarkdownLoaderOptions,
|
||||
} from './types';
|
||||
import type {BlogContentPaths, BlogMarkdownLoaderOptions} from './types';
|
||||
import type {LoadContext, Plugin, HtmlTags} from '@docusaurus/types';
|
||||
import {
|
||||
generateBlogPosts,
|
||||
|
@ -46,6 +39,10 @@ import type {
|
|||
BlogPostFrontMatter,
|
||||
BlogPostMetadata,
|
||||
Assets,
|
||||
BlogTag,
|
||||
BlogTags,
|
||||
BlogContent,
|
||||
BlogPaginated,
|
||||
} from '@docusaurus/plugin-content-blog';
|
||||
|
||||
export default async function pluginContentBlog(
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
declare module '@docusaurus/plugin-content-blog' {
|
||||
import type {MDXOptions} from '@docusaurus/mdx-loader';
|
||||
import type {FrontMatterTag, Tag} from '@docusaurus/utils';
|
||||
import type {Plugin, LoadContext} from '@docusaurus/types';
|
||||
import type {Overwrite} from 'utility-types';
|
||||
|
||||
export type Assets = {
|
||||
|
@ -410,6 +411,62 @@ declare module '@docusaurus/plugin-content-blog' {
|
|||
title: string;
|
||||
items: {title: string; permalink: string}[];
|
||||
};
|
||||
|
||||
export type BlogContent = {
|
||||
blogSidebarTitle: string;
|
||||
blogPosts: BlogPost[];
|
||||
blogListPaginated: BlogPaginated[];
|
||||
blogTags: BlogTags;
|
||||
blogTagsListPath: string;
|
||||
};
|
||||
|
||||
export type BlogTags = {
|
||||
[permalink: string]: BlogTag;
|
||||
};
|
||||
|
||||
export type BlogTag = Tag & {
|
||||
/** Blog post permalinks. */
|
||||
items: string[];
|
||||
pages: BlogPaginated[];
|
||||
};
|
||||
|
||||
export type BlogPost = {
|
||||
id: string;
|
||||
metadata: BlogPostMetadata;
|
||||
content: string;
|
||||
};
|
||||
|
||||
export type BlogPaginatedMetadata = {
|
||||
/** Title of the entire blog. */
|
||||
readonly blogTitle: string;
|
||||
/** Blog description. */
|
||||
readonly blogDescription: string;
|
||||
/** Permalink to the next list page. */
|
||||
readonly nextPage?: string;
|
||||
/** Permalink of the current page. */
|
||||
readonly permalink: string;
|
||||
/** Permalink to the previous list page. */
|
||||
readonly previousPage?: string;
|
||||
/** Index of the current page, 1-based. */
|
||||
readonly page: number;
|
||||
/** Posts displayed on each list page. */
|
||||
readonly postsPerPage: number;
|
||||
/** Total number of posts in the entire blog. */
|
||||
readonly totalCount: number;
|
||||
/** Total number of list pages. */
|
||||
readonly totalPages: number;
|
||||
};
|
||||
|
||||
export type BlogPaginated = {
|
||||
metadata: BlogPaginatedMetadata;
|
||||
/** Blog post permalinks. */
|
||||
items: string[];
|
||||
};
|
||||
|
||||
export default function pluginContentBlog(
|
||||
context: LoadContext,
|
||||
options: PluginOptions,
|
||||
): Promise<Plugin<BlogContent>>;
|
||||
}
|
||||
|
||||
declare module '@theme/BlogPostPage' {
|
||||
|
@ -446,34 +503,16 @@ declare module '@theme/BlogPostPage' {
|
|||
|
||||
declare module '@theme/BlogListPage' {
|
||||
import type {Content} from '@theme/BlogPostPage';
|
||||
import type {BlogSidebar} from '@docusaurus/plugin-content-blog';
|
||||
|
||||
export type Metadata = {
|
||||
/** Title of the entire blog. */
|
||||
readonly blogTitle: string;
|
||||
/** Blog description. */
|
||||
readonly blogDescription: string;
|
||||
/** Permalink to the next list page. */
|
||||
readonly nextPage?: string;
|
||||
/** Permalink of the current page. */
|
||||
readonly permalink: string;
|
||||
/** Permalink to the previous list page. */
|
||||
readonly previousPage?: string;
|
||||
/** Index of the current page, 1-based. */
|
||||
readonly page: number;
|
||||
/** Posts displayed on each list page. */
|
||||
readonly postsPerPage: number;
|
||||
/** Total number of posts in the entire blog. */
|
||||
readonly totalCount: number;
|
||||
/** Total number of list pages. */
|
||||
readonly totalPages: number;
|
||||
};
|
||||
import type {
|
||||
BlogSidebar,
|
||||
BlogPaginatedMetadata,
|
||||
} from '@docusaurus/plugin-content-blog';
|
||||
|
||||
export interface Props {
|
||||
/** Blog sidebar. */
|
||||
readonly sidebar: BlogSidebar;
|
||||
/** Metadata of the current listing page. */
|
||||
readonly metadata: Metadata;
|
||||
readonly metadata: BlogPaginatedMetadata;
|
||||
/**
|
||||
* Array of blog posts included on this page. Every post's metadata is also
|
||||
* available.
|
||||
|
@ -499,9 +538,11 @@ declare module '@theme/BlogTagsListPage' {
|
|||
}
|
||||
|
||||
declare module '@theme/BlogTagsPostsPage' {
|
||||
import type {BlogSidebar} from '@docusaurus/plugin-content-blog';
|
||||
import type {
|
||||
BlogSidebar,
|
||||
BlogPaginatedMetadata,
|
||||
} from '@docusaurus/plugin-content-blog';
|
||||
import type {Content} from '@theme/BlogPostPage';
|
||||
import type {Metadata} from '@theme/BlogListPage';
|
||||
import type {TagModule} from '@docusaurus/utils';
|
||||
|
||||
export interface Props {
|
||||
|
@ -510,7 +551,7 @@ declare module '@theme/BlogTagsPostsPage' {
|
|||
/** Metadata of this tag. */
|
||||
readonly tag: TagModule;
|
||||
/** Looks exactly the same as the posts list page */
|
||||
readonly listMetadata: Metadata;
|
||||
readonly listMetadata: BlogPaginatedMetadata;
|
||||
/**
|
||||
* Array of blog posts included on this page. Every post's metadata is also
|
||||
* available.
|
||||
|
|
|
@ -5,9 +5,12 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import type {BlogContent, BlogPaginated} from './types';
|
||||
import type {TranslationFileContent, TranslationFile} from '@docusaurus/types';
|
||||
import type {PluginOptions} from '@docusaurus/plugin-content-blog';
|
||||
import type {
|
||||
PluginOptions,
|
||||
BlogContent,
|
||||
BlogPaginated,
|
||||
} from '@docusaurus/plugin-content-blog';
|
||||
|
||||
function translateListPage(
|
||||
blogListPaginated: BlogPaginated[],
|
||||
|
|
|
@ -5,42 +5,10 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import type {BrokenMarkdownLink, ContentPaths, Tag} from '@docusaurus/utils';
|
||||
import type {BlogPostMetadata} from '@docusaurus/plugin-content-blog';
|
||||
import type {Metadata as BlogPaginatedMetadata} from '@theme/BlogListPage';
|
||||
import type {BrokenMarkdownLink, ContentPaths} from '@docusaurus/utils';
|
||||
|
||||
export type BlogContentPaths = ContentPaths;
|
||||
|
||||
export type BlogContent = {
|
||||
blogSidebarTitle: string;
|
||||
blogPosts: BlogPost[];
|
||||
blogListPaginated: BlogPaginated[];
|
||||
blogTags: BlogTags;
|
||||
blogTagsListPath: string;
|
||||
};
|
||||
|
||||
export type BlogTags = {
|
||||
[permalink: string]: BlogTag;
|
||||
};
|
||||
|
||||
export type BlogTag = Tag & {
|
||||
/** Blog post permalinks. */
|
||||
items: string[];
|
||||
pages: BlogPaginated[];
|
||||
};
|
||||
|
||||
export type BlogPost = {
|
||||
id: string;
|
||||
metadata: BlogPostMetadata;
|
||||
content: string;
|
||||
};
|
||||
|
||||
export type BlogPaginated = {
|
||||
metadata: BlogPaginatedMetadata;
|
||||
/** Blog post permalinks. */
|
||||
items: string[];
|
||||
};
|
||||
|
||||
export type BlogBrokenMarkdownLink = BrokenMarkdownLink<BlogContentPaths>;
|
||||
export type BlogMarkdownLoaderOptions = {
|
||||
siteDir: string;
|
||||
|
|
|
@ -22,7 +22,7 @@ import {
|
|||
import type {LoadContext} from '@docusaurus/types';
|
||||
|
||||
import {getFileLastUpdate} from './lastUpdate';
|
||||
import type {DocFile, LoadedVersion} from './types';
|
||||
import type {DocFile} from './types';
|
||||
import getSlug from './slug';
|
||||
import {CURRENT_VERSION_NAME} from './constants';
|
||||
import {stripPathNumberPrefixes} from './numberPrefix';
|
||||
|
@ -39,6 +39,7 @@ import type {
|
|||
LastUpdateData,
|
||||
VersionMetadata,
|
||||
DocFrontMatter,
|
||||
LoadedVersion,
|
||||
} from '@docusaurus/plugin-content-docs';
|
||||
|
||||
type LastUpdateOptions = Pick<
|
||||
|
|
|
@ -26,9 +26,7 @@ import type {DocEnv} from './docs';
|
|||
import {readVersionDocs, processDocMetadata, addDocNavigation} from './docs';
|
||||
import {readVersionsMetadata} from './versions';
|
||||
import type {
|
||||
LoadedContent,
|
||||
SourceToPermalink,
|
||||
LoadedVersion,
|
||||
DocFile,
|
||||
DocsMarkdownOption,
|
||||
VersionTag,
|
||||
|
@ -53,6 +51,8 @@ import type {
|
|||
DocMetadataBase,
|
||||
VersionMetadata,
|
||||
DocFrontMatter,
|
||||
LoadedContent,
|
||||
LoadedVersion,
|
||||
} from '@docusaurus/plugin-content-docs';
|
||||
import {createSidebarsUtils} from './sidebars/utils';
|
||||
import _ from 'lodash';
|
||||
|
|
|
@ -14,6 +14,7 @@ declare module '@docusaurus/plugin-content-docs' {
|
|||
TagModule,
|
||||
Tag,
|
||||
} from '@docusaurus/utils';
|
||||
import type {Plugin, LoadContext} from '@docusaurus/types';
|
||||
import type {Required} from 'utility-types';
|
||||
|
||||
export type Assets = {
|
||||
|
@ -504,6 +505,21 @@ declare module '@docusaurus/plugin-content-docs' {
|
|||
export type PropTagsListPage = {
|
||||
tags: TagsListItem[];
|
||||
};
|
||||
|
||||
export type LoadedVersion = VersionMetadata & {
|
||||
docs: DocMetadata[];
|
||||
drafts: DocMetadata[];
|
||||
sidebars: import('./sidebars/types').Sidebars;
|
||||
};
|
||||
|
||||
export type LoadedContent = {
|
||||
loadedVersions: LoadedVersion[];
|
||||
};
|
||||
|
||||
export default function pluginContentDocs(
|
||||
context: LoadContext,
|
||||
options: PluginOptions,
|
||||
): Promise<Plugin<LoadedContent>>;
|
||||
}
|
||||
|
||||
declare module '@theme/DocItem' {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import type {LoadedVersion, VersionTag} from './types';
|
||||
import type {VersionTag} from './types';
|
||||
import type {
|
||||
SidebarItemDoc,
|
||||
SidebarItem,
|
||||
|
@ -22,6 +22,7 @@ import type {
|
|||
PropSidebarItemLink,
|
||||
PropVersionDocs,
|
||||
DocMetadata,
|
||||
LoadedVersion,
|
||||
} from '@docusaurus/plugin-content-docs';
|
||||
import _ from 'lodash';
|
||||
import {createDocsByIdIndex} from './docs';
|
||||
|
|
|
@ -5,7 +5,10 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import type {LoadedVersion, LoadedContent} from './types';
|
||||
import type {
|
||||
LoadedVersion,
|
||||
LoadedContent,
|
||||
} from '@docusaurus/plugin-content-docs';
|
||||
import type {
|
||||
Sidebar,
|
||||
SidebarItemCategory,
|
||||
|
|
|
@ -7,12 +7,11 @@
|
|||
|
||||
/// <reference types="@docusaurus/module-type-aliases" />
|
||||
|
||||
import type {Sidebars} from './sidebars/types';
|
||||
import type {BrokenMarkdownLink, Tag} from '@docusaurus/utils';
|
||||
import type {
|
||||
VersionMetadata,
|
||||
LastUpdateData,
|
||||
DocMetadata,
|
||||
LoadedVersion,
|
||||
CategoryGeneratedIndexMetadata,
|
||||
} from '@docusaurus/plugin-content-docs';
|
||||
import type {SidebarsUtils} from './sidebars/utils';
|
||||
|
@ -37,16 +36,6 @@ export type VersionTags = {
|
|||
[permalink: string]: VersionTag;
|
||||
};
|
||||
|
||||
export type LoadedVersion = VersionMetadata & {
|
||||
docs: DocMetadata[];
|
||||
drafts: DocMetadata[];
|
||||
sidebars: Sidebars;
|
||||
};
|
||||
|
||||
export type LoadedContent = {
|
||||
loadedVersions: LoadedVersion[];
|
||||
};
|
||||
|
||||
export type FullVersion = LoadedVersion & {
|
||||
sidebarsUtils: SidebarsUtils;
|
||||
categoryGeneratedIndices: CategoryGeneratedIndexMetadata[];
|
||||
|
|
|
@ -25,8 +25,12 @@ import type {LoadContext, Plugin} from '@docusaurus/types';
|
|||
import admonitions from 'remark-admonitions';
|
||||
import {validatePageFrontMatter} from './frontMatter';
|
||||
|
||||
import type {LoadedContent, PagesContentPaths} from './types';
|
||||
import type {PluginOptions, Metadata} from '@docusaurus/plugin-content-pages';
|
||||
import type {PagesContentPaths} from './types';
|
||||
import type {
|
||||
PluginOptions,
|
||||
Metadata,
|
||||
LoadedContent,
|
||||
} from '@docusaurus/plugin-content-pages';
|
||||
|
||||
export function getContentPathList(contentPaths: PagesContentPaths): string[] {
|
||||
return [contentPaths.contentPathLocalized, contentPaths.contentPath];
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
declare module '@docusaurus/plugin-content-pages' {
|
||||
import type {MDXOptions} from '@docusaurus/mdx-loader';
|
||||
import type {LoadContext, Plugin} from '@docusaurus/types';
|
||||
|
||||
export type PluginOptions = MDXOptions & {
|
||||
id?: string;
|
||||
|
@ -45,6 +46,13 @@ declare module '@docusaurus/plugin-content-pages' {
|
|||
};
|
||||
|
||||
export type Metadata = JSXPageMetadata | MDXPageMetadata;
|
||||
|
||||
export type LoadedContent = Metadata[];
|
||||
|
||||
export default function pluginContentPages(
|
||||
context: LoadContext,
|
||||
options: PluginOptions,
|
||||
): Promise<Plugin<LoadedContent | null>>;
|
||||
}
|
||||
|
||||
declare module '@theme/MDXPage' {
|
||||
|
|
|
@ -5,10 +5,6 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import type {Metadata} from '@docusaurus/plugin-content-pages';
|
||||
|
||||
export type LoadedContent = Metadata[];
|
||||
|
||||
export type PagesContentPaths = {
|
||||
contentPath: string;
|
||||
contentPathLocalized: string;
|
||||
|
|
|
@ -12,7 +12,7 @@ import path from 'path';
|
|||
export default function pluginDebug({
|
||||
siteConfig: {baseUrl},
|
||||
generatedFilesDir,
|
||||
}: LoadContext): Plugin<void> {
|
||||
}: LoadContext): Plugin<undefined> {
|
||||
const pluginDataDirRoot = path.join(
|
||||
generatedFilesDir,
|
||||
'docusaurus-plugin-debug',
|
||||
|
|
|
@ -7,6 +7,12 @@
|
|||
|
||||
/// <reference types="@docusaurus/module-type-aliases" />
|
||||
|
||||
declare module '@docusaurus/plugin-debug' {
|
||||
import type {LoadContext, Plugin} from '@docusaurus/types';
|
||||
|
||||
export default function pluginDebug(context: LoadContext): Plugin<undefined>;
|
||||
}
|
||||
|
||||
declare module '@theme/DebugConfig' {
|
||||
export default function DebugMetadata(): JSX.Element;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"version": "2.0.0-beta.18",
|
||||
"description": "Global analytics (analytics.js) plugin for Docusaurus.",
|
||||
"main": "lib/index.js",
|
||||
"types": "src/plugin-google-analytics.d.ts",
|
||||
"types": "lib/index.d.ts",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
|
|
|
@ -13,7 +13,7 @@ import type {
|
|||
ThemeConfig,
|
||||
ThemeConfigValidationContext,
|
||||
} from '@docusaurus/types';
|
||||
import type {PluginOptions, Options} from '@docusaurus/plugin-google-analytics';
|
||||
import type {PluginOptions, Options} from './options';
|
||||
|
||||
export default function pluginGoogleAnalytics(
|
||||
context: LoadContext,
|
||||
|
@ -87,3 +87,5 @@ export function validateThemeConfig({
|
|||
}
|
||||
return themeConfig;
|
||||
}
|
||||
|
||||
export type {PluginOptions, Options};
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"version": "2.0.0-beta.18",
|
||||
"description": "Global Site Tag (gtag.js) plugin for Docusaurus.",
|
||||
"main": "lib/index.js",
|
||||
"types": "src/plugin-google-gtag.d.ts",
|
||||
"types": "lib/index.d.ts",
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"watch": "tsc --watch"
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
import globalData from '@generated/globalData';
|
||||
import type {PluginOptions} from '@docusaurus/plugin-google-gtag';
|
||||
import type {PluginOptions} from './options';
|
||||
import type {ClientModule} from '@docusaurus/types';
|
||||
|
||||
const {trackingID} = globalData['docusaurus-plugin-google-gtag']!
|
||||
|
|
|
@ -13,7 +13,7 @@ import type {
|
|||
ThemeConfig,
|
||||
ThemeConfigValidationContext,
|
||||
} from '@docusaurus/types';
|
||||
import type {PluginOptions, Options} from '@docusaurus/plugin-google-gtag';
|
||||
import type {PluginOptions, Options} from './options';
|
||||
|
||||
export default function pluginGoogleGtag(
|
||||
context: LoadContext,
|
||||
|
@ -101,3 +101,5 @@ export function validateThemeConfig({
|
|||
}
|
||||
return themeConfig;
|
||||
}
|
||||
|
||||
export type {PluginOptions, Options};
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"version": "2.0.0-beta.18",
|
||||
"description": "Simple sitemap generation plugin for Docusaurus.",
|
||||
"main": "lib/index.js",
|
||||
"types": "src/plugin-sitemap.d.ts",
|
||||
"types": "lib/index.d.ts",
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"watch": "tsc --watch"
|
||||
|
|
|
@ -5,9 +5,8 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import {validateOptions, DEFAULT_OPTIONS} from '../options';
|
||||
import {validateOptions, DEFAULT_OPTIONS, type Options} from '../options';
|
||||
import {normalizePluginOptions} from '@docusaurus/utils-validation';
|
||||
import type {Options} from '@docusaurus/plugin-sitemap';
|
||||
|
||||
function testValidate(options: Options) {
|
||||
return validateOptions({validate: normalizePluginOptions, options});
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
*/
|
||||
|
||||
import {SitemapStream, streamToPromise} from 'sitemap';
|
||||
import type {PluginOptions} from '@docusaurus/plugin-sitemap';
|
||||
import type {DocusaurusConfig} from '@docusaurus/types';
|
||||
import {applyTrailingSlash} from '@docusaurus/utils-common';
|
||||
import {createMatcher} from '@docusaurus/utils';
|
||||
import type {DocusaurusConfig} from '@docusaurus/types';
|
||||
import type {HelmetServerState} from 'react-helmet-async';
|
||||
import type {PluginOptions} from './options';
|
||||
import type {ReactElement} from 'react';
|
||||
|
||||
export default async function createSitemap(
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
|
||||
import fs from 'fs-extra';
|
||||
import path from 'path';
|
||||
import type {PluginOptions} from '@docusaurus/plugin-sitemap';
|
||||
import createSitemap from './createSitemap';
|
||||
import type {PluginOptions, Options} from './options';
|
||||
import type {LoadContext, Plugin} from '@docusaurus/types';
|
||||
|
||||
export default function pluginSitemap(
|
||||
|
@ -42,3 +42,4 @@ export default function pluginSitemap(
|
|||
}
|
||||
|
||||
export {validateOptions} from './options';
|
||||
export type {PluginOptions, Options};
|
||||
|
|
|
@ -7,9 +7,22 @@
|
|||
|
||||
import {Joi} from '@docusaurus/utils-validation';
|
||||
import {EnumChangefreq} from 'sitemap';
|
||||
import type {Options, PluginOptions} from '@docusaurus/plugin-sitemap';
|
||||
import type {OptionValidationContext} from '@docusaurus/types';
|
||||
|
||||
export type PluginOptions = {
|
||||
/** @see https://www.sitemaps.org/protocol.html#xmlTagDefinitions */
|
||||
changefreq: EnumChangefreq;
|
||||
/** @see https://www.sitemaps.org/protocol.html#xmlTagDefinitions */
|
||||
priority: number;
|
||||
/**
|
||||
* A list of glob patterns; matching route paths will be filtered from the
|
||||
* sitemap. Note that you may need to include the base URL in here.
|
||||
*/
|
||||
ignorePatterns: string[];
|
||||
};
|
||||
|
||||
export type Options = Partial<PluginOptions>;
|
||||
|
||||
export const DEFAULT_OPTIONS: PluginOptions = {
|
||||
changefreq: EnumChangefreq.WEEKLY,
|
||||
priority: 0.5,
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import type {EnumChangefreq} from 'sitemap';
|
||||
|
||||
export type PluginOptions = {
|
||||
/** @see https://www.sitemaps.org/protocol.html#xmlTagDefinitions */
|
||||
changefreq: EnumChangefreq;
|
||||
/** @see https://www.sitemaps.org/protocol.html#xmlTagDefinitions */
|
||||
priority: number;
|
||||
/**
|
||||
* A list of glob patterns; matching route paths will be filtered from the
|
||||
* sitemap. Note that you may need to include the base URL in here.
|
||||
*/
|
||||
ignorePatterns: string[];
|
||||
};
|
||||
|
||||
export type Options = Partial<PluginOptions>;
|
|
@ -3,7 +3,7 @@
|
|||
"version": "2.0.0-beta.18",
|
||||
"description": "Classic preset for Docusaurus.",
|
||||
"main": "lib/index.js",
|
||||
"types": "src/preset-classic.d.ts",
|
||||
"types": "lib/index.d.ts",
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"watch": "tsc --watch"
|
||||
|
|
|
@ -11,7 +11,7 @@ import type {
|
|||
PluginConfig,
|
||||
PluginOptions,
|
||||
} from '@docusaurus/types';
|
||||
import type {Options, ThemeConfig} from '@docusaurus/preset-classic';
|
||||
import type {Options, ThemeConfig} from './options';
|
||||
|
||||
function makePluginConfig(
|
||||
source: string,
|
||||
|
@ -93,3 +93,5 @@ export default function preset(
|
|||
|
||||
return {themes, plugins};
|
||||
}
|
||||
|
||||
export type {Options, ThemeConfig};
|
||||
|
|
|
@ -91,10 +91,10 @@ function getInfimaCSSFile(direction: string) {
|
|||
}.css`;
|
||||
}
|
||||
|
||||
export default function docusaurusThemeClassic(
|
||||
export default function themeClassic(
|
||||
context: LoadContext,
|
||||
options: Options,
|
||||
): Plugin<void> {
|
||||
): Plugin<undefined> {
|
||||
const {
|
||||
i18n: {currentLocale, localeConfigs},
|
||||
} = context;
|
||||
|
|
|
@ -21,9 +21,16 @@
|
|||
// in their tsconfig.
|
||||
|
||||
declare module '@docusaurus/theme-classic' {
|
||||
import type {LoadContext, Plugin} from '@docusaurus/types';
|
||||
|
||||
export type Options = {
|
||||
customCss?: string | string[];
|
||||
};
|
||||
|
||||
export default function themeClassic(
|
||||
context: LoadContext,
|
||||
options: Options,
|
||||
): Plugin<undefined>;
|
||||
}
|
||||
|
||||
declare module '@theme/Admonition' {
|
||||
|
@ -47,10 +54,10 @@ declare module '@theme/BackToTopButton' {
|
|||
}
|
||||
|
||||
declare module '@theme/BlogListPaginator' {
|
||||
import type {Metadata} from '@theme/BlogListPage';
|
||||
import type {BlogPaginatedMetadata} from '@docusaurus/plugin-content-blog';
|
||||
|
||||
export interface Props {
|
||||
readonly metadata: Metadata;
|
||||
readonly metadata: BlogPaginatedMetadata;
|
||||
}
|
||||
export default function BlogListPaginator(props: Props): JSX.Element;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue