diff --git a/packages/docusaurus-plugin-client-redirects/package.json b/packages/docusaurus-plugin-client-redirects/package.json index 5cd0e1016168..43565ecb24a7 100644 --- a/packages/docusaurus-plugin-client-redirects/package.json +++ b/packages/docusaurus-plugin-client-redirects/package.json @@ -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" diff --git a/packages/docusaurus-plugin-client-redirects/src/__tests__/collectRedirects.test.ts b/packages/docusaurus-plugin-client-redirects/src/__tests__/collectRedirects.test.ts index 3e7f47e5f853..266b36911ee3 100644 --- a/packages/docusaurus-plugin-client-redirects/src/__tests__/collectRedirects.test.ts +++ b/packages/docusaurus-plugin-client-redirects/src/__tests__/collectRedirects.test.ts @@ -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, diff --git a/packages/docusaurus-plugin-client-redirects/src/__tests__/options.test.ts b/packages/docusaurus-plugin-client-redirects/src/__tests__/options.test.ts index 0354dcfe995a..3243076acba1 100644 --- a/packages/docusaurus-plugin-client-redirects/src/__tests__/options.test.ts +++ b/packages/docusaurus-plugin-client-redirects/src/__tests__/options.test.ts @@ -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}); diff --git a/packages/docusaurus-plugin-client-redirects/src/collectRedirects.ts b/packages/docusaurus-plugin-client-redirects/src/collectRedirects.ts index 9fb14e85a239..8a62cae4f4ab 100644 --- a/packages/docusaurus-plugin-client-redirects/src/collectRedirects.ts +++ b/packages/docusaurus-plugin-client-redirects/src/collectRedirects.ts @@ -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, diff --git a/packages/docusaurus-plugin-client-redirects/src/index.ts b/packages/docusaurus-plugin-client-redirects/src/index.ts index 21ec1195f373..9bfac10d9498 100644 --- a/packages/docusaurus-plugin-client-redirects/src/index.ts +++ b/packages/docusaurus-plugin-client-redirects/src/index.ts @@ -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}; diff --git a/packages/docusaurus-plugin-client-redirects/src/options.ts b/packages/docusaurus-plugin-client-redirects/src/options.ts index d81b535482b8..34891a1c9b70 100644 --- a/packages/docusaurus-plugin-client-redirects/src/options.ts +++ b/packages/docusaurus-plugin-client-redirects/src/options.ts @@ -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; + export const DEFAULT_OPTIONS: Partial = { fromExtensions: [], toExtensions: [], diff --git a/packages/docusaurus-plugin-client-redirects/src/plugin-client-redirects.d.ts b/packages/docusaurus-plugin-client-redirects/src/plugin-client-redirects.d.ts deleted file mode 100644 index a943eace5e8f..000000000000 --- a/packages/docusaurus-plugin-client-redirects/src/plugin-client-redirects.d.ts +++ /dev/null @@ -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; diff --git a/packages/docusaurus-plugin-client-redirects/src/types.ts b/packages/docusaurus-plugin-client-redirects/src/types.ts index ca0f61a6fb01..8ad61ae06c47 100644 --- a/packages/docusaurus-plugin-client-redirects/src/types.ts +++ b/packages/docusaurus-plugin-client-redirects/src/types.ts @@ -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 diff --git a/packages/docusaurus-plugin-content-blog/src/blogUtils.ts b/packages/docusaurus-plugin-content-blog/src/blogUtils.ts index 6b839cee9d42..5daf3983e09a 100644 --- a/packages/docusaurus-plugin-content-blog/src/blogUtils.ts +++ b/packages/docusaurus-plugin-content-blog/src/blogUtils.ts @@ -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 { diff --git a/packages/docusaurus-plugin-content-blog/src/feed.ts b/packages/docusaurus-plugin-content-blog/src/feed.ts index af453979243c..0a465f8582a7 100644 --- a/packages/docusaurus-plugin-content-blog/src/feed.ts +++ b/packages/docusaurus-plugin-content-blog/src/feed.ts @@ -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'; diff --git a/packages/docusaurus-plugin-content-blog/src/index.ts b/packages/docusaurus-plugin-content-blog/src/index.ts index 57fc7840ea03..3b19b9bbab2e 100644 --- a/packages/docusaurus-plugin-content-blog/src/index.ts +++ b/packages/docusaurus-plugin-content-blog/src/index.ts @@ -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( diff --git a/packages/docusaurus-plugin-content-blog/src/plugin-content-blog.d.ts b/packages/docusaurus-plugin-content-blog/src/plugin-content-blog.d.ts index e17128655bc4..d74bba9fc274 100644 --- a/packages/docusaurus-plugin-content-blog/src/plugin-content-blog.d.ts +++ b/packages/docusaurus-plugin-content-blog/src/plugin-content-blog.d.ts @@ -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>; } 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. diff --git a/packages/docusaurus-plugin-content-blog/src/translations.ts b/packages/docusaurus-plugin-content-blog/src/translations.ts index 28c233dd99c8..9cf763de3b42 100644 --- a/packages/docusaurus-plugin-content-blog/src/translations.ts +++ b/packages/docusaurus-plugin-content-blog/src/translations.ts @@ -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[], diff --git a/packages/docusaurus-plugin-content-blog/src/types.ts b/packages/docusaurus-plugin-content-blog/src/types.ts index f40e57e00adf..9774a412300f 100644 --- a/packages/docusaurus-plugin-content-blog/src/types.ts +++ b/packages/docusaurus-plugin-content-blog/src/types.ts @@ -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; export type BlogMarkdownLoaderOptions = { siteDir: string; diff --git a/packages/docusaurus-plugin-content-docs/src/docs.ts b/packages/docusaurus-plugin-content-docs/src/docs.ts index 1c04edc05efe..7f631f21c781 100644 --- a/packages/docusaurus-plugin-content-docs/src/docs.ts +++ b/packages/docusaurus-plugin-content-docs/src/docs.ts @@ -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< diff --git a/packages/docusaurus-plugin-content-docs/src/index.ts b/packages/docusaurus-plugin-content-docs/src/index.ts index 3c0c0a9531df..b4c72107f312 100644 --- a/packages/docusaurus-plugin-content-docs/src/index.ts +++ b/packages/docusaurus-plugin-content-docs/src/index.ts @@ -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'; diff --git a/packages/docusaurus-plugin-content-docs/src/plugin-content-docs.d.ts b/packages/docusaurus-plugin-content-docs/src/plugin-content-docs.d.ts index 644477d0375b..412a08cdb08f 100644 --- a/packages/docusaurus-plugin-content-docs/src/plugin-content-docs.d.ts +++ b/packages/docusaurus-plugin-content-docs/src/plugin-content-docs.d.ts @@ -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>; } declare module '@theme/DocItem' { diff --git a/packages/docusaurus-plugin-content-docs/src/props.ts b/packages/docusaurus-plugin-content-docs/src/props.ts index 43d3028d455c..bf4393c631ff 100644 --- a/packages/docusaurus-plugin-content-docs/src/props.ts +++ b/packages/docusaurus-plugin-content-docs/src/props.ts @@ -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'; diff --git a/packages/docusaurus-plugin-content-docs/src/translations.ts b/packages/docusaurus-plugin-content-docs/src/translations.ts index 10b058defa57..f5f2f7e71916 100644 --- a/packages/docusaurus-plugin-content-docs/src/translations.ts +++ b/packages/docusaurus-plugin-content-docs/src/translations.ts @@ -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, diff --git a/packages/docusaurus-plugin-content-docs/src/types.ts b/packages/docusaurus-plugin-content-docs/src/types.ts index ee964f533e03..df3579b856d8 100644 --- a/packages/docusaurus-plugin-content-docs/src/types.ts +++ b/packages/docusaurus-plugin-content-docs/src/types.ts @@ -7,12 +7,11 @@ /// -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[]; diff --git a/packages/docusaurus-plugin-content-pages/src/index.ts b/packages/docusaurus-plugin-content-pages/src/index.ts index c205743e6a00..5bd819610ba1 100644 --- a/packages/docusaurus-plugin-content-pages/src/index.ts +++ b/packages/docusaurus-plugin-content-pages/src/index.ts @@ -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]; diff --git a/packages/docusaurus-plugin-content-pages/src/plugin-content-pages.d.ts b/packages/docusaurus-plugin-content-pages/src/plugin-content-pages.d.ts index 2f35040cebe5..dd754b175940 100644 --- a/packages/docusaurus-plugin-content-pages/src/plugin-content-pages.d.ts +++ b/packages/docusaurus-plugin-content-pages/src/plugin-content-pages.d.ts @@ -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>; } declare module '@theme/MDXPage' { diff --git a/packages/docusaurus-plugin-content-pages/src/types.ts b/packages/docusaurus-plugin-content-pages/src/types.ts index e2833c5692f5..2d11492cb04e 100644 --- a/packages/docusaurus-plugin-content-pages/src/types.ts +++ b/packages/docusaurus-plugin-content-pages/src/types.ts @@ -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; diff --git a/packages/docusaurus-plugin-debug/src/index.ts b/packages/docusaurus-plugin-debug/src/index.ts index 01a9e0a4e03f..62e650824f93 100644 --- a/packages/docusaurus-plugin-debug/src/index.ts +++ b/packages/docusaurus-plugin-debug/src/index.ts @@ -12,7 +12,7 @@ import path from 'path'; export default function pluginDebug({ siteConfig: {baseUrl}, generatedFilesDir, -}: LoadContext): Plugin { +}: LoadContext): Plugin { const pluginDataDirRoot = path.join( generatedFilesDir, 'docusaurus-plugin-debug', diff --git a/packages/docusaurus-plugin-debug/src/plugin-debug.d.ts b/packages/docusaurus-plugin-debug/src/plugin-debug.d.ts index 93b666dd4f31..f66d093a1ba7 100644 --- a/packages/docusaurus-plugin-debug/src/plugin-debug.d.ts +++ b/packages/docusaurus-plugin-debug/src/plugin-debug.d.ts @@ -7,6 +7,12 @@ /// +declare module '@docusaurus/plugin-debug' { + import type {LoadContext, Plugin} from '@docusaurus/types'; + + export default function pluginDebug(context: LoadContext): Plugin; +} + declare module '@theme/DebugConfig' { export default function DebugMetadata(): JSX.Element; } diff --git a/packages/docusaurus-plugin-google-analytics/package.json b/packages/docusaurus-plugin-google-analytics/package.json index ba4e08a1a4ff..e094188d43ca 100644 --- a/packages/docusaurus-plugin-google-analytics/package.json +++ b/packages/docusaurus-plugin-google-analytics/package.json @@ -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" }, diff --git a/packages/docusaurus-plugin-google-analytics/src/index.ts b/packages/docusaurus-plugin-google-analytics/src/index.ts index 0219c748f12c..6250becb1244 100644 --- a/packages/docusaurus-plugin-google-analytics/src/index.ts +++ b/packages/docusaurus-plugin-google-analytics/src/index.ts @@ -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}; diff --git a/packages/docusaurus-plugin-google-analytics/src/plugin-google-analytics.d.ts b/packages/docusaurus-plugin-google-analytics/src/options.ts similarity index 100% rename from packages/docusaurus-plugin-google-analytics/src/plugin-google-analytics.d.ts rename to packages/docusaurus-plugin-google-analytics/src/options.ts diff --git a/packages/docusaurus-plugin-google-gtag/package.json b/packages/docusaurus-plugin-google-gtag/package.json index 1ddd7df24a51..342888e66234 100644 --- a/packages/docusaurus-plugin-google-gtag/package.json +++ b/packages/docusaurus-plugin-google-gtag/package.json @@ -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" diff --git a/packages/docusaurus-plugin-google-gtag/src/gtag.ts b/packages/docusaurus-plugin-google-gtag/src/gtag.ts index 0beaac7f0a07..dab90146d1fc 100644 --- a/packages/docusaurus-plugin-google-gtag/src/gtag.ts +++ b/packages/docusaurus-plugin-google-gtag/src/gtag.ts @@ -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']! diff --git a/packages/docusaurus-plugin-google-gtag/src/index.ts b/packages/docusaurus-plugin-google-gtag/src/index.ts index 66ed0365e0a9..7724c9676683 100644 --- a/packages/docusaurus-plugin-google-gtag/src/index.ts +++ b/packages/docusaurus-plugin-google-gtag/src/index.ts @@ -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}; diff --git a/packages/docusaurus-plugin-google-gtag/src/plugin-google-gtag.d.ts b/packages/docusaurus-plugin-google-gtag/src/options.ts similarity index 100% rename from packages/docusaurus-plugin-google-gtag/src/plugin-google-gtag.d.ts rename to packages/docusaurus-plugin-google-gtag/src/options.ts diff --git a/packages/docusaurus-plugin-sitemap/package.json b/packages/docusaurus-plugin-sitemap/package.json index 769d5d046f75..a3629d6848f3 100644 --- a/packages/docusaurus-plugin-sitemap/package.json +++ b/packages/docusaurus-plugin-sitemap/package.json @@ -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" diff --git a/packages/docusaurus-plugin-sitemap/src/__tests__/options.test.ts b/packages/docusaurus-plugin-sitemap/src/__tests__/options.test.ts index 9e93e57de8ec..c581cbece0ec 100644 --- a/packages/docusaurus-plugin-sitemap/src/__tests__/options.test.ts +++ b/packages/docusaurus-plugin-sitemap/src/__tests__/options.test.ts @@ -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}); diff --git a/packages/docusaurus-plugin-sitemap/src/createSitemap.ts b/packages/docusaurus-plugin-sitemap/src/createSitemap.ts index fa4aefb75e52..5e1b619d356f 100644 --- a/packages/docusaurus-plugin-sitemap/src/createSitemap.ts +++ b/packages/docusaurus-plugin-sitemap/src/createSitemap.ts @@ -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( diff --git a/packages/docusaurus-plugin-sitemap/src/index.ts b/packages/docusaurus-plugin-sitemap/src/index.ts index 5f66eeaa3e5a..3f52b8cf60f0 100644 --- a/packages/docusaurus-plugin-sitemap/src/index.ts +++ b/packages/docusaurus-plugin-sitemap/src/index.ts @@ -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}; diff --git a/packages/docusaurus-plugin-sitemap/src/options.ts b/packages/docusaurus-plugin-sitemap/src/options.ts index e5f2053931c0..5a8302424e83 100644 --- a/packages/docusaurus-plugin-sitemap/src/options.ts +++ b/packages/docusaurus-plugin-sitemap/src/options.ts @@ -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; + export const DEFAULT_OPTIONS: PluginOptions = { changefreq: EnumChangefreq.WEEKLY, priority: 0.5, diff --git a/packages/docusaurus-plugin-sitemap/src/plugin-sitemap.d.ts b/packages/docusaurus-plugin-sitemap/src/plugin-sitemap.d.ts deleted file mode 100644 index 6f175bd1f7a1..000000000000 --- a/packages/docusaurus-plugin-sitemap/src/plugin-sitemap.d.ts +++ /dev/null @@ -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; diff --git a/packages/docusaurus-preset-classic/package.json b/packages/docusaurus-preset-classic/package.json index 850c52f9e030..b727d31e6e3b 100644 --- a/packages/docusaurus-preset-classic/package.json +++ b/packages/docusaurus-preset-classic/package.json @@ -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" diff --git a/packages/docusaurus-preset-classic/src/index.ts b/packages/docusaurus-preset-classic/src/index.ts index e3059a520665..a695121c9d0f 100644 --- a/packages/docusaurus-preset-classic/src/index.ts +++ b/packages/docusaurus-preset-classic/src/index.ts @@ -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}; diff --git a/packages/docusaurus-preset-classic/src/preset-classic.d.ts b/packages/docusaurus-preset-classic/src/options.ts similarity index 100% rename from packages/docusaurus-preset-classic/src/preset-classic.d.ts rename to packages/docusaurus-preset-classic/src/options.ts diff --git a/packages/docusaurus-theme-classic/src/index.ts b/packages/docusaurus-theme-classic/src/index.ts index d24c0b3f87e3..6a3d46c827d7 100644 --- a/packages/docusaurus-theme-classic/src/index.ts +++ b/packages/docusaurus-theme-classic/src/index.ts @@ -91,10 +91,10 @@ function getInfimaCSSFile(direction: string) { }.css`; } -export default function docusaurusThemeClassic( +export default function themeClassic( context: LoadContext, options: Options, -): Plugin { +): Plugin { const { i18n: {currentLocale, localeConfigs}, } = context; diff --git a/packages/docusaurus-theme-classic/src/theme-classic.d.ts b/packages/docusaurus-theme-classic/src/theme-classic.d.ts index cbbf6bf58d61..cd8929d73389 100644 --- a/packages/docusaurus-theme-classic/src/theme-classic.d.ts +++ b/packages/docusaurus-theme-classic/src/theme-classic.d.ts @@ -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; } 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; }