diff --git a/.eslintrc.js b/.eslintrc.js index 6a0b15228fd0..c6cea664f8dd 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -203,7 +203,10 @@ module.exports = { })), ], 'no-template-curly-in-string': WARNING, - 'no-unused-expressions': [WARNING, {allowTaggedTemplates: true}], + 'no-unused-expressions': [ + WARNING, + {allowTaggedTemplates: true, allowShortCircuit: true}, + ], 'no-useless-escape': WARNING, 'no-void': [ERROR, {allowAsStatement: true}], 'prefer-destructuring': WARNING, diff --git a/packages/docusaurus-module-type-aliases/src/index.d.ts b/packages/docusaurus-module-type-aliases/src/index.d.ts index 5cb44f06e402..0819c6efeaad 100644 --- a/packages/docusaurus-module-type-aliases/src/index.d.ts +++ b/packages/docusaurus-module-type-aliases/src/index.d.ts @@ -262,8 +262,8 @@ declare module '@docusaurus/useRouteContext' { declare module '@docusaurus/useBrokenLinks' { export type BrokenLinks = { - collectLink: (link: string) => void; - collectAnchor: (anchor: string) => void; + collectLink: (link: string | undefined) => void; + collectAnchor: (anchor: string | undefined) => void; }; export default function useBrokenLinks(): BrokenLinks; diff --git a/packages/docusaurus-theme-classic/src/theme-classic.d.ts b/packages/docusaurus-theme-classic/src/theme-classic.d.ts index b894974807d8..a54f0799a81e 100644 --- a/packages/docusaurus-theme-classic/src/theme-classic.d.ts +++ b/packages/docusaurus-theme-classic/src/theme-classic.d.ts @@ -867,6 +867,14 @@ declare module '@theme/MDXComponents/Ul' { export default function MDXUl(props: Props): JSX.Element; } +declare module '@theme/MDXComponents/Li' { + import type {ComponentProps} from 'react'; + + export interface Props extends ComponentProps<'li'> {} + + export default function MDXLi(props: Props): JSX.Element; +} + declare module '@theme/MDXComponents/Img' { import type {ComponentProps} from 'react'; diff --git a/packages/docusaurus-theme-classic/src/theme/MDXComponents/Li.tsx b/packages/docusaurus-theme-classic/src/theme/MDXComponents/Li.tsx new file mode 100644 index 000000000000..74a8a4add4f1 --- /dev/null +++ b/packages/docusaurus-theme-classic/src/theme/MDXComponents/Li.tsx @@ -0,0 +1,17 @@ +/** + * 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 React, {type ReactNode} from 'react'; +import useBrokenLinks from '@docusaurus/useBrokenLinks'; +import type {Props} from '@theme/MDXComponents/Li'; + +export default function MDXLi(props: Props): ReactNode | undefined { + // MDX Footnotes have ids such as
string \| EditUrlFn
| `undefined` | Base URL to edit your site. The final URL is computed by `editUrl + relativePostPath`. Using a function allows more nuanced control for each file. Omitting this variable entirely will disable edit links. |
+| `editLocalizedFiles` | `boolean` | `false` | The edit URL will target the localized file, instead of the original unlocalized file. Ignored when `editUrl` is a function. |
+| `blogTitle` | `string` | `'Blog'` | Blog page title for better SEO. |
+| `blogDescription` | `string` | `'Blog'` | Blog page meta description for better SEO. |
+| `blogSidebarCount` | number \| 'ALL'
| `5` | Number of blog post elements to show in the blog sidebar. `'ALL'` to show all blog posts; `0` to disable. |
+| `blogSidebarTitle` | `string` | `'Recent posts'` | Title of the blog sidebar. |
+| `routeBasePath` | `string` | `'blog'` | URL route for the blog section of your site. **DO NOT** include a trailing slash. Use `/` to put the blog at root path. |
+| `tagsBasePath` | `string` | `'tags'` | URL route for the tags section of your blog. Will be appended to `routeBasePath`. **DO NOT** include a trailing slash. |
+| `archiveBasePath` | string \| null
| `'archive'` | URL route for the archive section of your blog. Will be appended to `routeBasePath`. **DO NOT** include a trailing slash. Use `null` to disable generation of archive. |
+| `include` | `string[]` | `['**/*.{md,mdx}']` | Array of glob patterns matching Markdown files to be built, relative to the content path. |
+| `exclude` | `string[]` | _See example configuration_ | Array of glob patterns matching Markdown files to be excluded. Serves as refinement based on the `include` option. |
+| `postsPerPage` | number \| 'ALL'
| `10` | Number of posts to show per page in the listing page. Use `'ALL'` to display all posts on one listing page. |
+| `blogListComponent` | `string` | `'@theme/BlogListPage'` | Root component of the blog listing page. |
+| `blogPostComponent` | `string` | `'@theme/BlogPostPage'` | Root component of each blog post page. |
+| `blogTagsListComponent` | `string` | `'@theme/BlogTagsListPage'` | Root component of the tags list page. |
+| `blogTagsPostsComponent` | `string` | `'@theme/BlogTagsPostsPage'` | Root component of the "posts containing tag" page. |
+| `blogArchiveComponent` | `string` | `'@theme/BlogArchivePage'` | Root component of the blog archive page. |
+| `remarkPlugins` | `any[]` | `[]` | Remark plugins passed to MDX. |
+| `rehypePlugins` | `any[]` | `[]` | Rehype plugins passed to MDX. |
+| `beforeDefaultRemarkPlugins` | `any[]` | `[]` | Custom Remark plugins passed to MDX before the default Docusaurus Remark plugins. |
+| `beforeDefaultRehypePlugins` | `any[]` | `[]` | Custom Rehype plugins passed to MDX before the default Docusaurus Rehype plugins. |
+| `truncateMarker` | `RegExp` | `//` \| `\{\/\*\s*truncate\s*\*\/\}/` | Truncate marker marking where the summary ends. |
+| `showReadingTime` | `boolean` | `true` | Show estimated reading time for the blog post. |
+| `readingTime` | `ReadingTimeFn` | The default reading time | A callback to customize the reading time number displayed. |
+| `authorsMapPath` | `string` | `'authors.yml'` | Path to the authors map file, relative to the blog content directory. |
+| `feedOptions` | _See below_ | `{type: ['rss', 'atom']}` | Blog feed. |
+| `feedOptions.type` | FeedType \| FeedType[] \| 'all' \| null
| **Required** | Type of feed to be generated. Use `null` to disable generation. |
+| `feedOptions.createFeedItems` | CreateFeedItemsFn \| undefined
| `undefined` | An optional function which can be used to transform and / or filter the items in the feed. |
+| `feedOptions.limit` | `number \| null \| false` | `20` | Limits the feed to the specified number of posts, `false` or `null` for all entries. Defaults to `20`. |
+| `feedOptions.title` | `string` | `siteConfig.title` | Title of the feed. |
+| `feedOptions.description` | `string` | \`$\{siteConfig.title} Blog\`
| Description of the feed. |
+| `feedOptions.copyright` | `string` | `undefined` | Copyright message. |
+| `feedOptions.language` | `string` (See [documentation](http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes) for possible values) | `undefined` | Language metadata of the feed. |
+| `sortPosts` | 'descending' \| 'ascending'
| `'descending'` | Governs the direction of blog post sorting. |
+
+```mdx-code-block
+string \| EditUrlFunction
| `undefined` | Base URL to edit your site. The final URL is computed by `editUrl + relativeDocPath`. Using a function allows more nuanced control for each file. Omitting this variable entirely will disable edit links. |
+| `editLocalizedFiles` | `boolean` | `false` | The edit URL will target the localized file, instead of the original unlocalized file. Ignored when `editUrl` is a function. |
+| `editCurrentVersion` | `boolean` | `false` | The edit URL will always target the current version doc instead of older versions. Ignored when `editUrl` is a function. |
+| `routeBasePath` | `string` | `'docs'` | URL route for the docs section of your site. **DO NOT** include a trailing slash. Use `/` for shipping docs without base path. |
+| `tagsBasePath` | `string` | `'tags'` | URL route for the tags list page of your site. It is prepended to the `routeBasePath`. |
+| `include` | `string[]` | `['**/*.{md,mdx}']` | Array of glob patterns matching Markdown files to be built, relative to the content path. |
+| `exclude` | `string[]` | _See example configuration_ | Array of glob patterns matching Markdown files to be excluded. Serves as refinement based on the `include` option. |
+| `sidebarPath` | false \| string
| `undefined` | Path to sidebar configuration. Use `false` to disable sidebars, or `undefined` to create a fully autogenerated sidebar. |
+| `sidebarCollapsible` | `boolean` | `true` | Whether sidebar categories are collapsible by default. See also [Collapsible categories](/docs/sidebar/items#collapsible-categories) |
+| `sidebarCollapsed` | `boolean` | `true` | Whether sidebar categories are collapsed by default. See also [Expanded categories by default](/docs/sidebar/items#expanded-categories-by-default) |
+| `sidebarItemsGenerator` | SidebarGenerator
| _Omitted_ | Function used to replace the sidebar items of type `'autogenerated'` with real sidebar items (docs, categories, links...). See also [Customize the sidebar items generator](/docs/sidebar/autogenerated#customize-the-sidebar-items-generator) |
+| `numberPrefixParser` | boolean \|
PrefixParser
| _Omitted_ | Custom parsing logic to extract number prefixes from file names. Use `false` to disable this behavior and leave the docs untouched, and `true` to use the default parser. See also [Using number prefixes](/docs/sidebar/autogenerated#using-number-prefixes) |
+| `docsRootComponent` | `string` | `'@theme/DocsRoot'` | Parent component of all the docs plugin pages (including all versions). Stays mounted when navigation between docs pages and versions. |
+| `docVersionRootComponent` | `string` | `'@theme/DocVersionLayout'` | Parent component of all docs pages of an individual version (doc pages with sidebars, tags pages). Stays mounted when navigation between pages of that specific version. |
+| `docRootComponent` | `string` | `'@theme/DocPage'` | Parent component of all doc pages with sidebars (regular docs pages, category generated index pages). Stays mounted when navigation between such pages. |
+| `docItemComponent` | `string` | `'@theme/DocItem'` | Main doc container, with TOC, pagination, etc. |
+| `docTagsListComponent` | `string` | `'@theme/DocTagsListPage'` | Root component of the tags list page |
+| `docTagDocListComponent` | `string` | `'@theme/DocTagDocListPage'` | Root component of the "docs containing tag X" page. |
+| `docCategoryGeneratedIndexComponent` | `string` | `'@theme/DocCategoryGeneratedIndexPage'` | Root component of the generated category index page. |
+| `remarkPlugins` | `any[]` | `[]` | Remark plugins passed to MDX. |
+| `rehypePlugins` | `any[]` | `[]` | Rehype plugins passed to MDX. |
+| `beforeDefaultRemarkPlugins` | `any[]` | `[]` | Custom Remark plugins passed to MDX before the default Docusaurus Remark plugins. |
+| `beforeDefaultRehypePlugins` | `any[]` | `[]` | Custom Rehype plugins passed to MDX before the default Docusaurus Rehype plugins. |
+| `showLastUpdateAuthor` | `boolean` | `false` | Whether to display the author who last updated the doc. |
+| `showLastUpdateTime` | `boolean` | `false` | Whether to display the last date the doc was updated. |
+| `breadcrumbs` | `boolean` | `true` | Enable or disable the breadcrumbs on doc pages. |
+| `disableVersioning` | `boolean` | `false` | Explicitly disable versioning even when multiple versions exist. This will make the site only include the current version. Will error if `includeCurrentVersion: false` and `disableVersioning: true`. |
+| `includeCurrentVersion` | `boolean` | `true` | Include the current version of your docs. |
+| `lastVersion` | `string` | First version in `versions.json` | The version navigated to in priority and displayed by default for docs navbar items. |
+| `onlyIncludeVersions` | `string[]` | All versions available | Only include a subset of all available versions. |
+| `versions` | VersionsConfig
| `{}` | Independent customization of each version's properties. |
+
+```mdx-code-block
+string \| null
| Next doc in the sidebar | The ID of the documentation you want the "Next" pagination to link to. Use `null` to disable showing "Next" for this page. |
+| `pagination_prev` | string \| null
| Previous doc in the sidebar | The ID of the documentation you want the "Previous" pagination to link to. Use `null` to disable showing "Previous" for this page. |
+| `parse_number_prefixes` | `boolean` | `numberPrefixParser` plugin option | Whether number prefix parsing is disabled on this doc. See also [Using number prefixes](/docs/sidebar/autogenerated#using-number-prefixes). |
+| `custom_edit_url` | string \| null
| Computed using the `editUrl` plugin option | The URL for editing this document. Use `null` to disable showing "Edit this page" for this page. |
+| `keywords` | `string[]` | `undefined` | Keywords meta tag for the document page, for search engines. |
+| `description` | `string` | The first line of Markdown content | The description of your document, which will become the `` and `` in ``, used by search engines. |
+| `image` | `string` | `undefined` | Cover or thumbnail image that will be used when displaying the link to your post. |
+| `slug` | `string` | File path | Allows to customize the document URL (`/string \| string[]
| **Required** | The tracking ID of your gtag service. It is possible to provide multiple ids. |
+| `anonymizeIP` | `boolean` | `false` | Whether the IP should be anonymized when sending requests. |
+
+```mdx-code-block
+This component crashed because of error: {error.message}.
+ ++ {/* highlight-next-line */} + Check out my blog! +
++ {/* highlight-next-line */} + Follow me on Twitter! +
+