diff --git a/.prettierignore b/.prettierignore
index e523352d6cd..2255dc18b29 100644
--- a/.prettierignore
+++ b/.prettierignore
@@ -1,5 +1,14 @@
-src/theme/DocItem
-src/theme/DocRoot
+# Ejected components keep upstream's formatting so they stay diffable against
+# @docusaurus/theme-classic. Refer to `src/theme/README.md`.
+# Wrapped components are our own code, so they follow the repo's formatting.
+src/theme/DocItem/Layout/index.tsx
+src/theme/EditMetaRow/index.tsx
+src/theme/Icon/Edit/index.tsx
+src/theme/Icon/Language/index.tsx
+src/theme/Layout/index.tsx
+src/theme/NavbarItem/LocaleDropdownNavbarItem/index.tsx
+src/theme/prism-include-languages.ts
+
legacy-stencil-components
scripts/bak
diff --git a/src/theme/DocItem/Layout/index.tsx b/src/theme/DocItem/Layout/index.tsx
index 03747ce145e..4e64afe30e9 100644
--- a/src/theme/DocItem/Layout/index.tsx
+++ b/src/theme/DocItem/Layout/index.tsx
@@ -1,10 +1,10 @@
/**
* DocItemLayout is a component that renders the layout of a page like
* the individual component pages, guide pages, etc.
- *
+ *
* Original source:
* @link https://github.com/facebook/docusaurus/blob/main/packages/docusaurus-theme-classic/src/theme/DocItem/Layout/index.tsx
- *
+ *
* Reason for overriding:
* - Add a phone demo to the right of the page, e.g. /docs
*/
@@ -95,8 +95,8 @@ export default function DocItemLayout({children, ...props}: Props): ReactNode {
{/* ------- CUSTOM CODE -------- */}
{/* Ideally this would only render if there is a demoUrl and the it's a mobile device. However,the `windowSize` does not provide a tablet so we have to hide it through CSS. */}
{demoUrl && (
-
-
+
+
diff --git a/src/theme/DocRoot/Layout/Main/index.tsx b/src/theme/DocRoot/Layout/Main/index.tsx
index b8a6cf10363..1675410fc68 100644
--- a/src/theme/DocRoot/Layout/Main/index.tsx
+++ b/src/theme/DocRoot/Layout/Main/index.tsx
@@ -5,10 +5,10 @@
* - Moved the navbar to the top of the page. Originally, the navbar would be placed along the top of the entire site, but we want it to be placed along the top of the docs page only.
*/
-import React, {type ReactNode} from 'react';
+import React, { type ReactNode } from 'react';
import Main from '@theme-original/DocRoot/Layout/Main';
import Navbar from '@theme/Navbar';
-import type {Props} from '@theme/DocRoot/Layout/Main';
+import type { Props } from '@theme/DocRoot/Layout/Main';
export default function MainWrapper(props: Props): ReactNode {
return (
diff --git a/src/theme/EditMetaRow/index.tsx b/src/theme/EditMetaRow/index.tsx
index 778bf57bded..9cf50b7229f 100644
--- a/src/theme/EditMetaRow/index.tsx
+++ b/src/theme/EditMetaRow/index.tsx
@@ -13,29 +13,35 @@
* row.
*/
-import React, { type ReactNode } from 'react';
+import React, {type ReactNode} from 'react';
import clsx from 'clsx';
// CUSTOM CODE
import CopyPageButton from 'docusaurus-plugin-copy-page-button/react';
// CUSTOM CODE END
import EditThisPage from '@theme/EditThisPage';
-import type { Props } from '@theme/EditMetaRow';
+import type {Props} from '@theme/EditMetaRow';
import LastUpdated from '@theme/LastUpdated';
import globalStyles from '@docusaurus/theme-classic/lib/theme/EditMetaRow/styles.module.css';
import styles from './styles.module.css';
-export default function EditMetaRow({ className, editUrl, lastUpdatedAt, lastUpdatedBy }: Props): ReactNode {
+export default function EditMetaRow({
+ className,
+ editUrl,
+ lastUpdatedAt,
+ lastUpdatedBy,
+}: Props): ReactNode {
return (
{/* CUSTOM CODE — "Edit this page | Copy page" as peer links on one row */}
-
+
{editUrl && }
@@ -43,7 +49,10 @@ export default function EditMetaRow({ className, editUrl, lastUpdatedAt, lastUpd
{/* CUSTOM CODE — wrap the whole column in the conditional, not just its contents */}
{(lastUpdatedAt || lastUpdatedBy) && (
-
+
)}
{/* CUSTOM CODE END */}
diff --git a/src/theme/Icon/Edit/index.tsx b/src/theme/Icon/Edit/index.tsx
index dfadeaab866..c598a12f2e0 100644
--- a/src/theme/Icon/Edit/index.tsx
+++ b/src/theme/Icon/Edit/index.tsx
@@ -6,13 +6,13 @@
* - Changed the icon to be the GitHub icon since the icon is used on the `Edit this page` link, which links to the GitHub repo.
*/
-import React, { type ReactNode } from 'react';
+import React, {type ReactNode} from 'react';
import clsx from 'clsx';
-import type { Props } from '@theme/Icon/Edit';
+import type {Props} from '@theme/Icon/Edit';
import styles from '@docusaurus/theme-classic/src/theme/Icon/Edit/styles.module.css';
-export default function IconEdit({ className, ...restProps }: Props): ReactNode {
+export default function IconEdit({className, ...restProps}: Props): ReactNode {
return (
{!noFooter && }
diff --git a/src/theme/NavbarItem/LocaleDropdownNavbarItem/index.tsx b/src/theme/NavbarItem/LocaleDropdownNavbarItem/index.tsx
index 39277cee9de..dc5469c2383 100644
--- a/src/theme/NavbarItem/LocaleDropdownNavbarItem/index.tsx
+++ b/src/theme/NavbarItem/LocaleDropdownNavbarItem/index.tsx
@@ -7,15 +7,15 @@
* - Removed the original styles that were applied to the language icon. We want to use our own styles.
*/
-import React, { type ReactNode } from 'react';
+import React, {type ReactNode} from 'react';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
-import { useAlternatePageUtils } from '@docusaurus/theme-common/internal';
-import { translate } from '@docusaurus/Translate';
-import { mergeSearchStrings, useHistorySelector } from '@docusaurus/theme-common';
+import {useAlternatePageUtils} from '@docusaurus/theme-common/internal';
+import {translate} from '@docusaurus/Translate';
+import {mergeSearchStrings, useHistorySelector} from '@docusaurus/theme-common';
import DropdownNavbarItem from '@theme/NavbarItem/DropdownNavbarItem';
import IconLanguage from '@theme/Icon/Language';
-import type { LinkLikeNavbarItemProps } from '@theme/NavbarItem';
-import type { Props } from '@theme/NavbarItem/LocaleDropdownNavbarItem';
+import type {LinkLikeNavbarItemProps} from '@theme/NavbarItem';
+import type {Props} from '@theme/NavbarItem/LocaleDropdownNavbarItem';
import styles from '@docusaurus/theme-classic/lib/theme/NavbarItem/LocaleDropdownNavbarItem/styles.module.css';
import customStyles from './styles.module.css';
@@ -23,7 +23,7 @@ import customStyles from './styles.module.css';
function useLocaleDropdownUtils() {
const {
siteConfig,
- i18n: { localeConfigs },
+ i18n: {localeConfigs},
} = useDocusaurusContext();
const alternatePageUtils = useAlternatePageUtils();
const search = useHistorySelector((history) => history.location.search);
@@ -32,7 +32,9 @@ function useLocaleDropdownUtils() {
const getLocaleConfig = (locale: string) => {
const localeConfig = localeConfigs[locale];
if (!localeConfig) {
- throw new Error(`Docusaurus bug, no locale config found for locale=${locale}`);
+ throw new Error(
+ `Docusaurus bug, no locale config found for locale=${locale}`,
+ );
}
return localeConfig;
};
@@ -55,12 +57,15 @@ function useLocaleDropdownUtils() {
};
return {
- getURL: (locale: string, options: { queryString: string | undefined }) => {
+ getURL: (locale: string, options: {queryString: string | undefined}) => {
// We have 2 query strings because
// - there's the current one
// - there's one user can provide through navbar config
// see https://github.com/facebook/docusaurus/pull/8915
- const finalSearch = mergeSearchStrings([search, options.queryString], 'append');
+ const finalSearch = mergeSearchStrings(
+ [search, options.queryString],
+ 'append',
+ );
return `${getBaseURLForLocale(locale)}${finalSearch}${hash}`;
},
getLabel: (locale: string) => {
@@ -82,14 +87,14 @@ export default function LocaleDropdownNavbarItem({
const utils = useLocaleDropdownUtils();
const {
- i18n: { currentLocale, locales },
+ i18n: {currentLocale, locales},
} = useDocusaurusContext();
const localeItems = locales.map((locale): LinkLikeNavbarItemProps => {
return {
label: utils.getLabel(locale),
lang: utils.getLang(locale),
- to: utils.getURL(locale, { queryString }),
+ to: utils.getURL(locale, {queryString}),
target: '_self',
autoAddBaseUrl: false,
className:
@@ -124,7 +129,9 @@ export default function LocaleDropdownNavbarItem({
<>
{/* CUSTOM CODE - added span in order to hide the text */}
- {dropdownLabel}
+
+ {dropdownLabel}
+
>
}
items={items}
diff --git a/src/theme/README.md b/src/theme/README.md
index 2fed55ad2ea..0a67156fd09 100644
--- a/src/theme/README.md
+++ b/src/theme/README.md
@@ -3,4 +3,4 @@
This folder is used to override the base docusaurus theme. It houses [swizzled components](https://docusaurus.io/docs/swizzling). Components should NOT be swizzled unless absolutely necessary to allow for changes in future versions. If it is possible to shallow swizzle a component using the `@theme-original` alias, then that should be heavily considered. Swizzled components should be added to the prettier ignore and all code updates should be marked with comments to allow more seamless version updating. The styles file for components that have been unsafely swizzle should absolutely not be edited. All styling should be done from the [component partials](/src/styles/components).
- Original theme: [`@docusaurus/theme-classic`](https://docusaurus.io/docs/api/themes/@docusaurus/theme-classic)
-- [Original theme source](https://github.com/facebook/docusaurus/tree/26ae4164d6f90c231c6687363a3907b5f9f172b8/packages/docusaurus-theme-classic/src/theme)
+- [Original theme source](https://github.com/facebook/docusaurus/tree/main/packages/docusaurus-theme-classic/src/theme)
diff --git a/src/theme/prism-include-languages.ts b/src/theme/prism-include-languages.ts
index 032dfd597e3..d60b064eba5 100644
--- a/src/theme/prism-include-languages.ts
+++ b/src/theme/prism-include-languages.ts
@@ -10,13 +10,15 @@
import siteConfig from '@generated/docusaurus.config';
import type * as PrismNamespace from 'prismjs';
-import type { Optional } from 'utility-types';
+import type {Optional} from 'utility-types';
-export default function prismIncludeLanguages(PrismObject: typeof PrismNamespace): void {
+export default function prismIncludeLanguages(
+ PrismObject: typeof PrismNamespace,
+): void {
const {
- themeConfig: { prism },
+ themeConfig: {prism},
} = siteConfig;
- const { additionalLanguages } = prism as { additionalLanguages: string[] };
+ const {additionalLanguages} = prism as {additionalLanguages: string[]};
// Prism components work on the Prism instance on the window, while prism-
// react-renderer uses its own Prism instance. We temporarily mount the