From eac406c8e8e06078a658a65fda4b0dfc65f7c6fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lorber?= Date: Fri, 13 Feb 2026 17:02:45 +0100 Subject: [PATCH 1/3] feat(theme): Split ``, improve extensibility, better handling of emoji icons, stable classNames (#11734) --- .../src/theme-classic.d.ts | 65 +++++++++++ .../src/theme/DocCard/Description/index.tsx | 27 +++++ .../DocCard/Description/styles.module.css | 10 ++ .../src/theme/DocCard/Heading/Icon/index.tsx | 22 ++++ .../DocCard/Heading/Icon/styles.module.css | 11 ++ .../src/theme/DocCard/Heading/Text/index.tsx | 27 +++++ .../DocCard/Heading/Text/styles.module.css | 10 ++ .../src/theme/DocCard/Heading/index.tsx | 28 +++++ .../theme/DocCard/Heading/styles.module.css | 11 ++ .../src/theme/DocCard/Layout/index.tsx | 55 +++++++++ .../DocCard/{ => Layout}/styles.module.css | 8 -- .../src/theme/DocCard/index.tsx | 107 +++++------------- .../docusaurus-theme-common/src/internal.ts | 3 + .../src/translations/docsTranslations.tsx | 28 +++++ .../src/utils/ThemeClassNames.ts | 7 ++ .../src/utils/__tests__/emojiUtils.test.ts | 66 +++++++++++ .../src/utils/emojiUtils.ts | 41 +++++++ website/docs/api/misc/_category_.yml | 2 + 18 files changed, 441 insertions(+), 87 deletions(-) create mode 100644 packages/docusaurus-theme-classic/src/theme/DocCard/Description/index.tsx create mode 100644 packages/docusaurus-theme-classic/src/theme/DocCard/Description/styles.module.css create mode 100644 packages/docusaurus-theme-classic/src/theme/DocCard/Heading/Icon/index.tsx create mode 100644 packages/docusaurus-theme-classic/src/theme/DocCard/Heading/Icon/styles.module.css create mode 100644 packages/docusaurus-theme-classic/src/theme/DocCard/Heading/Text/index.tsx create mode 100644 packages/docusaurus-theme-classic/src/theme/DocCard/Heading/Text/styles.module.css create mode 100644 packages/docusaurus-theme-classic/src/theme/DocCard/Heading/index.tsx create mode 100644 packages/docusaurus-theme-classic/src/theme/DocCard/Heading/styles.module.css create mode 100644 packages/docusaurus-theme-classic/src/theme/DocCard/Layout/index.tsx rename packages/docusaurus-theme-classic/src/theme/DocCard/{ => Layout}/styles.module.css (89%) create mode 100644 packages/docusaurus-theme-common/src/translations/docsTranslations.tsx create mode 100644 packages/docusaurus-theme-common/src/utils/__tests__/emojiUtils.test.ts create mode 100644 packages/docusaurus-theme-common/src/utils/emojiUtils.ts diff --git a/packages/docusaurus-theme-classic/src/theme-classic.d.ts b/packages/docusaurus-theme-classic/src/theme-classic.d.ts index 03a00f833a76..8dd8f87f8a19 100644 --- a/packages/docusaurus-theme-classic/src/theme-classic.d.ts +++ b/packages/docusaurus-theme-classic/src/theme-classic.d.ts @@ -582,6 +582,71 @@ declare module '@theme/DocCard' { export default function DocCard(props: Props): ReactNode; } +declare module '@theme/DocCard/Heading' { + import type {ReactNode} from 'react'; + import type {PropSidebarItem} from '@docusaurus/plugin-content-docs'; + + export interface Props { + readonly item: PropSidebarItem; + readonly icon: ReactNode; + readonly title: string; + } + + export default function DocCardHeading(props: Props): ReactNode; +} + +declare module '@theme/DocCard/Heading/Icon' { + import type {ReactNode} from 'react'; + import type {PropSidebarItem} from '@docusaurus/plugin-content-docs'; + + export interface Props { + readonly item: PropSidebarItem; + readonly icon: ReactNode; + } + + export default function DocCardHeadingIcon(props: Props): ReactNode; +} + +declare module '@theme/DocCard/Heading/Text' { + import type {ReactNode} from 'react'; + import type {PropSidebarItem} from '@docusaurus/plugin-content-docs'; + + export interface Props { + readonly item: PropSidebarItem; + readonly title: string; + } + + export default function DocCardHeadingText(props: Props): ReactNode; +} + +declare module '@theme/DocCard/Description' { + import type {ReactNode} from 'react'; + import type {PropSidebarItem} from '@docusaurus/plugin-content-docs'; + + export interface Props { + readonly item: PropSidebarItem; + readonly description: string; + } + + export default function DocCardDescription(props: Props): ReactNode; +} + +declare module '@theme/DocCard/Layout' { + import type {ReactNode} from 'react'; + import type {PropSidebarItem} from '@docusaurus/plugin-content-docs'; + + export interface Props { + readonly item: PropSidebarItem; + readonly className?: string; + readonly href: string; + readonly icon: ReactNode; + readonly title: string; + readonly description?: string; + } + + export default function DocCardLayout(props: Props): ReactNode; +} + declare module '@theme/DocCardList' { import type {ReactNode} from 'react'; import type {PropSidebarItem} from '@docusaurus/plugin-content-docs'; diff --git a/packages/docusaurus-theme-classic/src/theme/DocCard/Description/index.tsx b/packages/docusaurus-theme-classic/src/theme/DocCard/Description/index.tsx new file mode 100644 index 000000000000..55d2ce312b8e --- /dev/null +++ b/packages/docusaurus-theme-classic/src/theme/DocCard/Description/index.tsx @@ -0,0 +1,27 @@ +/** + * 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 clsx from 'clsx'; +import {ThemeClassNames} from '@docusaurus/theme-common'; +import type {Props} from '@theme/DocCard/Description'; + +import styles from './styles.module.css'; + +export default function DocCardDescription({description}: Props): ReactNode { + return ( +

+ {description} +

+ ); +} diff --git a/packages/docusaurus-theme-classic/src/theme/DocCard/Description/styles.module.css b/packages/docusaurus-theme-classic/src/theme/DocCard/Description/styles.module.css new file mode 100644 index 000000000000..c28ebe6cd137 --- /dev/null +++ b/packages/docusaurus-theme-classic/src/theme/DocCard/Description/styles.module.css @@ -0,0 +1,10 @@ +/** + * 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. + */ + +.cardDescription { + font-size: 0.8rem; +} diff --git a/packages/docusaurus-theme-classic/src/theme/DocCard/Heading/Icon/index.tsx b/packages/docusaurus-theme-classic/src/theme/DocCard/Heading/Icon/index.tsx new file mode 100644 index 000000000000..d646aa277082 --- /dev/null +++ b/packages/docusaurus-theme-classic/src/theme/DocCard/Heading/Icon/index.tsx @@ -0,0 +1,22 @@ +/** + * 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 clsx from 'clsx'; +import {ThemeClassNames} from '@docusaurus/theme-common'; +import type {Props} from '@theme/DocCard/Heading/Icon'; + +import styles from './styles.module.css'; + +export default function DocCardHeadingIcon({icon}: Props): ReactNode { + return ( + + {icon} + + ); +} diff --git a/packages/docusaurus-theme-classic/src/theme/DocCard/Heading/Icon/styles.module.css b/packages/docusaurus-theme-classic/src/theme/DocCard/Heading/Icon/styles.module.css new file mode 100644 index 000000000000..0362537d321d --- /dev/null +++ b/packages/docusaurus-theme-classic/src/theme/DocCard/Heading/Icon/styles.module.css @@ -0,0 +1,11 @@ +/** + * 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. + */ + +.cardTitleIcon { + font-size: 1.6rem; + margin-right: 0.6rem; +} diff --git a/packages/docusaurus-theme-classic/src/theme/DocCard/Heading/Text/index.tsx b/packages/docusaurus-theme-classic/src/theme/DocCard/Heading/Text/index.tsx new file mode 100644 index 000000000000..9b091534331f --- /dev/null +++ b/packages/docusaurus-theme-classic/src/theme/DocCard/Heading/Text/index.tsx @@ -0,0 +1,27 @@ +/** + * 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 clsx from 'clsx'; +import {ThemeClassNames} from '@docusaurus/theme-common'; +import type {Props} from '@theme/DocCard/Heading/Text'; + +import styles from './styles.module.css'; + +export default function DocCardHeadingText({title}: Props): ReactNode { + return ( + + {title} + + ); +} diff --git a/packages/docusaurus-theme-classic/src/theme/DocCard/Heading/Text/styles.module.css b/packages/docusaurus-theme-classic/src/theme/DocCard/Heading/Text/styles.module.css new file mode 100644 index 000000000000..a240e033473d --- /dev/null +++ b/packages/docusaurus-theme-classic/src/theme/DocCard/Heading/Text/styles.module.css @@ -0,0 +1,10 @@ +/** + * 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. + */ + +.cardTitleText { + font-size: 1.2rem; +} diff --git a/packages/docusaurus-theme-classic/src/theme/DocCard/Heading/index.tsx b/packages/docusaurus-theme-classic/src/theme/DocCard/Heading/index.tsx new file mode 100644 index 000000000000..7e5487e3ff9c --- /dev/null +++ b/packages/docusaurus-theme-classic/src/theme/DocCard/Heading/index.tsx @@ -0,0 +1,28 @@ +/** + * 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 clsx from 'clsx'; +import {ThemeClassNames} from '@docusaurus/theme-common'; +import Heading from '@theme/Heading'; +import Icon from '@theme/DocCard/Heading/Icon'; +import Text from '@theme/DocCard/Heading/Text'; +import type {Props} from '@theme/DocCard/Heading'; + +import styles from './styles.module.css'; + +export default function DocCardHeading({item, title, icon}: Props): ReactNode { + return ( + + {icon && } + + + ); +} diff --git a/packages/docusaurus-theme-classic/src/theme/DocCard/Heading/styles.module.css b/packages/docusaurus-theme-classic/src/theme/DocCard/Heading/styles.module.css new file mode 100644 index 000000000000..9054ee359fa6 --- /dev/null +++ b/packages/docusaurus-theme-classic/src/theme/DocCard/Heading/styles.module.css @@ -0,0 +1,11 @@ +/** + * 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. + */ + +.cardTitle { + display: inline-flex; + align-items: center; +} diff --git a/packages/docusaurus-theme-classic/src/theme/DocCard/Layout/index.tsx b/packages/docusaurus-theme-classic/src/theme/DocCard/Layout/index.tsx new file mode 100644 index 000000000000..448ec09921c8 --- /dev/null +++ b/packages/docusaurus-theme-classic/src/theme/DocCard/Layout/index.tsx @@ -0,0 +1,55 @@ +/** + * 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 clsx from 'clsx'; +import Link from '@docusaurus/Link'; +import {ThemeClassNames} from '@docusaurus/theme-common'; +import Heading from '@theme/DocCard/Heading'; +import Description from '@theme/DocCard/Description'; +import type {Props} from '@theme/DocCard/Layout'; + +import styles from './styles.module.css'; + +function Container({ + className, + href, + children, +}: { + className?: string; + href: string; + children: ReactNode; +}): ReactNode { + return ( + + {children} + + ); +} + +export default function DocCardLayout({ + item, + className, + href, + icon, + title, + description, +}: Props): ReactNode { + return ( + + + {description && } + + ); +} diff --git a/packages/docusaurus-theme-classic/src/theme/DocCard/styles.module.css b/packages/docusaurus-theme-classic/src/theme/DocCard/Layout/styles.module.css similarity index 89% rename from packages/docusaurus-theme-classic/src/theme/DocCard/styles.module.css rename to packages/docusaurus-theme-classic/src/theme/DocCard/Layout/styles.module.css index 63c3d9856b70..41ab7bb7d12a 100644 --- a/packages/docusaurus-theme-classic/src/theme/DocCard/styles.module.css +++ b/packages/docusaurus-theme-classic/src/theme/DocCard/Layout/styles.module.css @@ -24,11 +24,3 @@ .cardContainer *:last-child { margin-bottom: 0; } - -.cardTitle { - font-size: 1.2rem; -} - -.cardDescription { - font-size: 0.8rem; -} diff --git a/packages/docusaurus-theme-classic/src/theme/DocCard/index.tsx b/packages/docusaurus-theme-classic/src/theme/DocCard/index.tsx index 076235d68702..643e0063dff6 100644 --- a/packages/docusaurus-theme-classic/src/theme/DocCard/index.tsx +++ b/packages/docusaurus-theme-classic/src/theme/DocCard/index.tsx @@ -6,122 +6,71 @@ */ import React, {type ReactNode} from 'react'; -import clsx from 'clsx'; -import Link from '@docusaurus/Link'; import { useDocById, findFirstSidebarItemLink, } from '@docusaurus/plugin-content-docs/client'; -import {usePluralForm} from '@docusaurus/theme-common'; +import { + extractLeadingEmoji, + useDocCardDescriptionCategoryItemsPlural, +} from '@docusaurus/theme-common/internal'; import isInternalUrl from '@docusaurus/isInternalUrl'; -import {translate} from '@docusaurus/Translate'; +import Layout from '@theme/DocCard/Layout'; import type {Props} from '@theme/DocCard'; -import Heading from '@theme/Heading'; import type { PropSidebarItemCategory, PropSidebarItemLink, } from '@docusaurus/plugin-content-docs'; -import styles from './styles.module.css'; - -function useCategoryItemsPlural() { - const {selectMessage} = usePluralForm(); - return (count: number) => - selectMessage( - count, - translate( - { - message: '1 item|{count} items', - id: 'theme.docs.DocCard.categoryDescription.plurals', - description: - 'The default description for a category card in the generated index about how many items this category includes', - }, - {count}, - ), - ); -} - -function CardContainer({ - className, - href, - children, -}: { - className?: string; - href: string; - children: ReactNode; -}): ReactNode { - return ( - - {children} - - ); +function getFallbackEmojiIcon( + item: PropSidebarItemLink | PropSidebarItemCategory, +): string { + if (item.type === 'category') { + return '๐Ÿ—ƒ'; + } + return isInternalUrl(item.href) ? '๐Ÿ“„๏ธ' : '๐Ÿ”—'; } -function CardLayout({ - className, - href, - icon, - title, - description, -}: { - className?: string; - href: string; - icon: ReactNode; - title: string; - description?: string; -}): ReactNode { - return ( - - - {icon} {title} - - {description && ( -

- {description} -

- )} -
- ); +function getIconTitleProps( + item: PropSidebarItemLink | PropSidebarItemCategory, +): {icon: ReactNode; title: string} { + const extracted = extractLeadingEmoji(item.label); + const emoji = extracted.emoji ?? getFallbackEmojiIcon(item); + return { + icon: emoji, + title: extracted.rest.trim(), + }; } function CardCategory({item}: {item: PropSidebarItemCategory}): ReactNode { const href = findFirstSidebarItemLink(item); - const categoryItemsPlural = useCategoryItemsPlural(); + const categoryItemsPlural = useDocCardDescriptionCategoryItemsPlural(); // Unexpected: categories that don't have a link have been filtered upfront if (!href) { return null; } - return ( - ); } function CardLink({item}: {item: PropSidebarItemLink}): ReactNode { - const icon = isInternalUrl(item.href) ? '๐Ÿ“„๏ธ' : '๐Ÿ”—'; const doc = useDocById(item.docId ?? undefined); return ( - ); } diff --git a/packages/docusaurus-theme-common/src/internal.ts b/packages/docusaurus-theme-common/src/internal.ts index 9d8b904cd8bd..02c5776173d1 100644 --- a/packages/docusaurus-theme-common/src/internal.ts +++ b/packages/docusaurus-theme-common/src/internal.ts @@ -91,6 +91,8 @@ export {PluginHtmlClassNameProvider} from './utils/metadataUtils'; export {splitNavbarItems, NavbarProvider} from './utils/navbarUtils'; +export {extractLeadingEmoji} from './utils/emojiUtils'; + export { useTOCHighlight, type TOCHighlightConfig, @@ -103,6 +105,7 @@ export {useLockBodyScroll} from './hooks/useLockBodyScroll'; export {useCodeWordWrap} from './hooks/useCodeWordWrap'; export {useBackToTopButton} from './hooks/useBackToTopButton'; +export {useDocCardDescriptionCategoryItemsPlural} from './translations/docsTranslations'; export { useBlogTagsPostsPageTitle, useBlogAuthorPageTitle, diff --git a/packages/docusaurus-theme-common/src/translations/docsTranslations.tsx b/packages/docusaurus-theme-common/src/translations/docsTranslations.tsx new file mode 100644 index 000000000000..5d6d76f5f69f --- /dev/null +++ b/packages/docusaurus-theme-common/src/translations/docsTranslations.tsx @@ -0,0 +1,28 @@ +/** + * 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 {translate} from '@docusaurus/Translate'; +import {usePluralForm} from '../utils/usePluralForm'; + +export function useDocCardDescriptionCategoryItemsPlural(): ( + count: number, +) => string { + const {selectMessage} = usePluralForm(); + return (count: number) => + selectMessage( + count, + translate( + { + message: '1 item|{count} items', + id: 'theme.docs.DocCard.categoryDescription.plurals', + description: + 'The default description for a category card in the generated index about how many items this category includes', + }, + {count}, + ), + ); +} diff --git a/packages/docusaurus-theme-common/src/utils/ThemeClassNames.ts b/packages/docusaurus-theme-common/src/utils/ThemeClassNames.ts index a414908d8870..4b039f652dca 100644 --- a/packages/docusaurus-theme-common/src/utils/ThemeClassNames.ts +++ b/packages/docusaurus-theme-common/src/utils/ThemeClassNames.ts @@ -100,6 +100,13 @@ export const ThemeClassNames = { docSidebarItemLinkLevel: (level: number) => `theme-doc-sidebar-item-link-level-${level}` as const, // TODO add other stable classNames here + docCard: { + container: 'theme-doc-card-container', + heading: 'theme-doc-card-heading', + icon: 'theme-doc-card-icon', + title: 'theme-doc-card-title', + description: 'theme-doc-card-description', + }, }, blog: { // TODO add other stable classNames here diff --git a/packages/docusaurus-theme-common/src/utils/__tests__/emojiUtils.test.ts b/packages/docusaurus-theme-common/src/utils/__tests__/emojiUtils.test.ts new file mode 100644 index 000000000000..267702ff8504 --- /dev/null +++ b/packages/docusaurus-theme-common/src/utils/__tests__/emojiUtils.test.ts @@ -0,0 +1,66 @@ +/** + * 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 {extractLeadingEmoji} from '../emojiUtils'; + +describe('extractLeadingEmoji', () => { + it('extracts simple leading emoji', () => { + expect(extractLeadingEmoji('๐Ÿ˜€ Hello World')).toEqual({ + emoji: '๐Ÿ˜€', + rest: ' Hello World', + }); + }); + + it('extracts only the first emoji', () => { + expect(extractLeadingEmoji('๐Ÿ˜€๐Ÿ˜€ Hello World')).toEqual({ + emoji: '๐Ÿ˜€', + rest: '๐Ÿ˜€ Hello World', + }); + }); + + it('extracts emoji with multiple code points - ๐Ÿ‡ซ๐Ÿ‡ท', () => { + expect(extractLeadingEmoji('๐Ÿ‡ซ๐Ÿ‡ท Hello World')).toEqual({ + emoji: '๐Ÿ‡ซ๐Ÿ‡ท', + rest: ' Hello World', + }); + }); + + it('extracts emoji with multiple code points - ๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ', () => { + expect(extractLeadingEmoji('๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ Hello World')).toEqual({ + emoji: '๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ', + rest: ' Hello World', + }); + }); + + it('preserves original string', () => { + expect(extractLeadingEmoji('Hello World')).toEqual({ + emoji: null, + rest: 'Hello World', + }); + }); + + it('preserves original string - leading emoji after space', () => { + expect(extractLeadingEmoji(' ๐Ÿ˜€ Hello World')).toEqual({ + emoji: null, + rest: ' ๐Ÿ˜€ Hello World', + }); + }); + + it('preserves original string - middle emoji', () => { + expect(extractLeadingEmoji('Hello ๐Ÿ˜€ World')).toEqual({ + emoji: null, + rest: 'Hello ๐Ÿ˜€ World', + }); + }); + + it('preserves original string - trailing emoji', () => { + expect(extractLeadingEmoji('Hello World ๐Ÿ˜€')).toEqual({ + emoji: null, + rest: 'Hello World ๐Ÿ˜€', + }); + }); +}); diff --git a/packages/docusaurus-theme-common/src/utils/emojiUtils.ts b/packages/docusaurus-theme-common/src/utils/emojiUtils.ts new file mode 100644 index 000000000000..c66cbfb3fa01 --- /dev/null +++ b/packages/docusaurus-theme-common/src/utils/emojiUtils.ts @@ -0,0 +1,41 @@ +/** + * 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. + */ + +const segmenter = new Intl.Segmenter(undefined, {granularity: 'grapheme'}); + +/** + * This method splits "โš ๏ธ Hello World" into "โš ๏ธ" + " Hello World". + * It is quite strict and dumb, only useful to handle best-effort heuristics. + * It only extracts a leading emoji if it is the first grapheme of the string. + * It only extracts one emoji, even if multiples are present. + * It doesn't trim the remaining string. + * If you need something more clever, it should be built on top. + * @param input + */ +export function extractLeadingEmoji(input: string): { + emoji: string | null; + rest: string; +} { + const it = segmenter.segment(input)[Symbol.iterator](); + + // const first = segmenter.segment(input).containing(0)?.segment; + const grapheme = it.next().value?.segment; + + if (!grapheme) { + return {emoji: null, rest: input}; + } + + // Leading grapheme contains an emoji (covers flags/ZWJ/skin tones) + if ( + !/\p{Extended_Pictographic}/u.test(grapheme) && + !/\p{Emoji}/u.test(grapheme) + ) { + return {emoji: null, rest: input}; + } + + return {emoji: grapheme, rest: input.slice(grapheme.length)}; +} diff --git a/website/docs/api/misc/_category_.yml b/website/docs/api/misc/_category_.yml index 2fb307376467..738a412be53a 100644 --- a/website/docs/api/misc/_category_.yml +++ b/website/docs/api/misc/_category_.yml @@ -1,2 +1,4 @@ label: Miscellaneous position: 4 +link: + type: generated-index From 63d6f3079d56b65a83c2a68433d4d4681386cdd9 Mon Sep 17 00:00:00 2001 From: Akshat Sinha <113134119+akshatsinha0@users.noreply.github.com> Date: Fri, 13 Feb 2026 22:56:59 +0530 Subject: [PATCH 2/3] fix(content-blog): fix wrong path variable in feed XSLT CSS file validation (#11736) fix(content-blog): validate CSS file path instead of XSLT path in feed XSLT resolver Co-authored-by: Akshat Sinha --- packages/docusaurus-plugin-content-blog/src/feed.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/docusaurus-plugin-content-blog/src/feed.ts b/packages/docusaurus-plugin-content-blog/src/feed.ts index 96f252f23070..55dc59703747 100644 --- a/packages/docusaurus-plugin-content-blog/src/feed.ts +++ b/packages/docusaurus-plugin-content-blog/src/feed.ts @@ -213,7 +213,7 @@ async function resolveXsltFilePaths({ parsedPath.dir, `${parsedPath.name}.css`, ); - if (!(await fs.pathExists(xsltAbsolutePath))) { + if (!(await fs.pathExists(cssAbsolutePath))) { throw new Error( logger.interpolate`Blog feed XSLT file was found at path=${path.relative( process.cwd(), From b0255cd5434dfab1f1ba0708d9e893918c72edd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lorber?= Date: Fri, 13 Feb 2026 19:15:00 +0100 Subject: [PATCH 3/3] fix(algolia): upgrade to DocSearch 4.5 + fix types (#11683) * add empty resolution * upgrade to DocSearch 4.5 * Add AI SDK to unblock typechecking libs * empty --- package.json | 1 + .../package.json | 1 + yarn.lock | 149 ++++++++++-------- 3 files changed, 82 insertions(+), 69 deletions(-) diff --git a/package.json b/package.json index 99353960576b..8f6ce6d52964 100644 --- a/package.json +++ b/package.json @@ -75,6 +75,7 @@ "update-translations": "yarn workspace @docusaurus/theme-translations update" }, "devDependencies": { + "@ai-sdk/react": "^2.0.30", "@crowdin/cli": "^3.13.0", "@prettier/plugin-xml": "^2.2.0", "@swc/core": "^1.7.14", diff --git a/packages/docusaurus-theme-search-algolia/package.json b/packages/docusaurus-theme-search-algolia/package.json index 8b78fcbf1544..9df55645c93e 100644 --- a/packages/docusaurus-theme-search-algolia/package.json +++ b/packages/docusaurus-theme-search-algolia/package.json @@ -41,6 +41,7 @@ "@docusaurus/theme-translations": "3.9.2", "@docusaurus/utils": "3.9.2", "@docusaurus/utils-validation": "3.9.2", + "@algolia/autocomplete-core": "^1.19.2", "algoliasearch": "^5.37.0", "algoliasearch-helper": "^3.26.0", "clsx": "^2.0.0", diff --git a/yarn.lock b/yarn.lock index 9d9114e0fce5..f167bed86c4b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7,37 +7,38 @@ resolved "https://registry.yarnpkg.com/@adobe/css-tools/-/css-tools-4.4.4.tgz#2856c55443d3d461693f32d2b96fb6ea92e1ffa9" integrity sha512-Elp+iwUx5rN5+Y8xLt5/GRoG20WGoDCQ/1Fb+1LiGtvwbDavuSk0jhD/eZdckHAuzcDzccnkv+rEjyWfRx18gg== -"@ai-sdk/gateway@1.0.29": - version "1.0.29" - resolved "https://registry.yarnpkg.com/@ai-sdk/gateway/-/gateway-1.0.29.tgz#b7e902c2d7139e2ca2a94cb6076febe517088fa0" - integrity sha512-o9LtmBiG2WAgs3GAmL79F8idan/UupxHG8Tyr2gP4aUSOzflM0bsvfzozBp8x6WatQnOx+Pio7YNw45Y6I16iw== +"@ai-sdk/gateway@2.0.37": + version "2.0.37" + resolved "https://registry.yarnpkg.com/@ai-sdk/gateway/-/gateway-2.0.37.tgz#d4f2f3c77f30118010c24e4441aef10d511ea57e" + integrity sha512-9ZxIFZS6f1zjYO5vMkUKkhgT9c1H6agZnPEePz87KHlFCmdV21F5Vnh5kz6Dq/9A4Z1OFwM1pQf7GdxBrbiZHg== dependencies: - "@ai-sdk/provider" "2.0.0" - "@ai-sdk/provider-utils" "3.0.9" + "@ai-sdk/provider" "2.0.1" + "@ai-sdk/provider-utils" "3.0.21" + "@vercel/oidc" "3.1.0" -"@ai-sdk/provider-utils@3.0.9": - version "3.0.9" - resolved "https://registry.yarnpkg.com/@ai-sdk/provider-utils/-/provider-utils-3.0.9.tgz#ac35a11eaafb5943a6c1bb024b4d2fdda6a8a0a3" - integrity sha512-Pm571x5efqaI4hf9yW4KsVlDBDme8++UepZRnq+kqVBWWjgvGhQlzU8glaFq0YJEB9kkxZHbRRyVeHoV2sRYaQ== +"@ai-sdk/provider-utils@3.0.21": + version "3.0.21" + resolved "https://registry.yarnpkg.com/@ai-sdk/provider-utils/-/provider-utils-3.0.21.tgz#b98175079d2787f0dda7027d74482f4ae1acfbc8" + integrity sha512-veuMwTLxsgh31Jjn0SnBABnM1f7ebHhRWcV2ZuY3hP3iJDCZ8VXBaYqcHXoOQDqUXTCas08sKQcHyWK+zl882Q== dependencies: - "@ai-sdk/provider" "2.0.0" + "@ai-sdk/provider" "2.0.1" "@standard-schema/spec" "^1.0.0" - eventsource-parser "^3.0.5" + eventsource-parser "^3.0.6" -"@ai-sdk/provider@2.0.0": - version "2.0.0" - resolved "https://registry.yarnpkg.com/@ai-sdk/provider/-/provider-2.0.0.tgz#b853c739d523b33675bc74b6c506b2c690bc602b" - integrity sha512-6o7Y2SeO9vFKB8lArHXehNuusnpddKPk7xqL7T2/b+OvXMRIXUO1rR4wcv1hAFUAT9avGZshty3Wlua/XA7TvA== +"@ai-sdk/provider@2.0.1": + version "2.0.1" + resolved "https://registry.yarnpkg.com/@ai-sdk/provider/-/provider-2.0.1.tgz#4aba415f1815da33a7a81e5f41a0219af53278c0" + integrity sha512-KCUwswvsC5VsW2PWFqF8eJgSCu5Ysj7m1TxiHTVA6g7k360bk0RNQENT8KTMAYEs+8fWPD3Uu4dEmzGHc+jGng== dependencies: json-schema "^0.4.0" "@ai-sdk/react@^2.0.30": - version "2.0.52" - resolved "https://registry.yarnpkg.com/@ai-sdk/react/-/react-2.0.52.tgz#851f1c2136b1c3d14bf8cb6f58dd87ea3d171946" - integrity sha512-4/i40pykN4gTGH264+k1g4tMGdw4xN7vZ1qESFCIm/lhS/8YiJPYheBOk9c349hytOT1sGxp3UNPcOWzWS0H2A== + version "2.0.133" + resolved "https://registry.yarnpkg.com/@ai-sdk/react/-/react-2.0.133.tgz#a37ea298764f1f8e0a8883e1658a0d2e2b4c7f14" + integrity sha512-b99d3klxm+3UPMeWuYr4DLL9P5fZmthO+2nnhvGvVzDWl3fEwfKUGyRCegJmvMAAAUa6WTilwTLcrTx2Ld95mw== dependencies: - "@ai-sdk/provider-utils" "3.0.9" - ai "5.0.52" + "@ai-sdk/provider-utils" "3.0.21" + ai "5.0.131" swr "^2.2.5" throttleit "2.1.0" @@ -59,6 +60,14 @@ "@algolia/autocomplete-plugin-algolia-insights" "1.19.2" "@algolia/autocomplete-shared" "1.19.2" +"@algolia/autocomplete-core@^1.19.2": + version "1.19.5" + resolved "https://registry.yarnpkg.com/@algolia/autocomplete-core/-/autocomplete-core-1.19.5.tgz#52d99aafce19493161220e417071f0222eeea7d6" + integrity sha512-/kAE3mMBage/9m0OGnKQteSa7/eIfvhiKx28OWj857+dJ6qYepEBuw5L8its2oTX8ZNM/6TA3fo49kMwgcwjlg== + dependencies: + "@algolia/autocomplete-plugin-algolia-insights" "1.19.5" + "@algolia/autocomplete-shared" "1.19.5" + "@algolia/autocomplete-plugin-algolia-insights@1.19.2": version "1.19.2" resolved "https://registry.yarnpkg.com/@algolia/autocomplete-plugin-algolia-insights/-/autocomplete-plugin-algolia-insights-1.19.2.tgz#3584b625b9317e333d1ae43664d02358e175c52d" @@ -66,11 +75,23 @@ dependencies: "@algolia/autocomplete-shared" "1.19.2" +"@algolia/autocomplete-plugin-algolia-insights@1.19.5": + version "1.19.5" + resolved "https://registry.yarnpkg.com/@algolia/autocomplete-plugin-algolia-insights/-/autocomplete-plugin-algolia-insights-1.19.5.tgz#05246356fe9837475b08664ff4d6f55960127edc" + integrity sha512-5zbetV9h2VxH+Mxx27I7BH2EIACVRUBE1FNykBK+2c2M+mhXYMY4npHbbGYj6QDEw3VVvH2UxAnghFpCtC6B/w== + dependencies: + "@algolia/autocomplete-shared" "1.19.5" + "@algolia/autocomplete-shared@1.19.2": version "1.19.2" resolved "https://registry.yarnpkg.com/@algolia/autocomplete-shared/-/autocomplete-shared-1.19.2.tgz#c0b7b8dc30a5c65b70501640e62b009535e4578f" integrity sha512-jEazxZTVD2nLrC+wYlVHQgpBoBB5KPStrJxLzsIFl6Kqd1AlG9sIAGl39V5tECLpIQzB3Qa2T6ZPJ1ChkwMK/w== +"@algolia/autocomplete-shared@1.19.5": + version "1.19.5" + resolved "https://registry.yarnpkg.com/@algolia/autocomplete-shared/-/autocomplete-shared-1.19.5.tgz#1a20f60fd400fd5641718358a2d5c3eb1893cf9c" + integrity sha512-yblBczNXtm2cCVzX4UAY3KkjdefmZPn1gWbIi8Q7qfBw7FjcKq2EjEl/65x4kU9nUc/ZkB5SeUf/bkqLEnA5gA== + "@algolia/client-abtesting@5.38.0": version "5.38.0" resolved "https://registry.yarnpkg.com/@algolia/client-abtesting/-/client-abtesting-5.38.0.tgz#3362d7aa3c6732f800665d3e24e98eb9046779d1" @@ -2095,29 +2116,24 @@ resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz#1d572bfbbe14b7704e0ba0f39b74815b84870d70" integrity sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw== -"@docsearch/core@4.4.0": - version "4.4.0" - resolved "https://registry.yarnpkg.com/@docsearch/core/-/core-4.4.0.tgz#206c0df38ee08cf0d6e33c4eaee140706931b311" - integrity sha512-kiwNo5KEndOnrf5Kq/e5+D9NBMCFgNsDoRpKQJ9o/xnSlheh6b8AXppMuuUVVdAUIhIfQFk/07VLjjk/fYyKmw== +"@docsearch/core@4.5.4": + version "4.5.4" + resolved "https://registry.yarnpkg.com/@docsearch/core/-/core-4.5.4.tgz#5f93dd99ed4de136bdd38988124b369b5d51e946" + integrity sha512-DbkfZbJyYAPFJtF71eAFOTQSy5z5c/hdSN0UrErORKDwXKLTJBR0c+5WxE5l+IKZx4xIaEa8RkrL7T28DTCOYw== -"@docsearch/css@4.4.0": - version "4.4.0" - resolved "https://registry.yarnpkg.com/@docsearch/css/-/css-4.4.0.tgz#b8eebd21a1f79720bf037fda5242b910367f157e" - integrity sha512-e9vPgtih6fkawakmYo0Y6V4BKBmDV7Ykudn7ADWXUs5b6pmtBRwDbpSG/WiaUG63G28OkJDEnsMvgIAnZgGwYw== +"@docsearch/css@4.5.4": + version "4.5.4" + resolved "https://registry.yarnpkg.com/@docsearch/css/-/css-4.5.4.tgz#99b69988bc061cd3772c25a2b155c9ee0813a0a2" + integrity sha512-gzO4DJwyM9c4YEPHwaLV1nUCDC2N6yoh0QJj44dce2rcfN71mB+jpu3+F+Y/KMDF1EKV0C3m54leSWsraE94xg== "@docsearch/react@^3.9.0 || ^4.3.2": - version "4.4.0" - resolved "https://registry.yarnpkg.com/@docsearch/react/-/react-4.4.0.tgz#f69bd533305a07247f4850ee74af11e784b99658" - integrity sha512-z12zeg1mV7WD4Ag4pKSuGukETJLaucVFwszDXL/qLaEgRqxEaVacO9SR1qqnCXvZztlvz2rt7cMqryi/7sKfjA== + version "4.5.4" + resolved "https://registry.yarnpkg.com/@docsearch/react/-/react-4.5.4.tgz#9eaa9e8c56afb8f5d6da9239221ca9dee1a8d043" + integrity sha512-iBNFfvWoUFRUJmGQ/r+0AEp2OJgJMoYIKRiRcTDON0hObBRSLlrv2ktb7w3nc1MeNm1JIpbPA99i59TiIR49fA== dependencies: - "@ai-sdk/react" "^2.0.30" "@algolia/autocomplete-core" "1.19.2" - "@docsearch/core" "4.4.0" - "@docsearch/css" "4.4.0" - ai "^5.0.30" - algoliasearch "^5.28.0" - marked "^16.3.0" - zod "^4.1.8" + "@docsearch/core" "4.5.4" + "@docsearch/css" "4.5.4" "@docusaurus/responsive-loader@^1.7.0": version "1.7.0" @@ -3567,9 +3583,9 @@ integrity sha512-9BCxFwvbGg/RsZK9tjXd8s4UcwR0MWeFQ1XEKIQVVvAGJyINdrqKMcTRyLoK8Rse1GjzLV9cwjWV1olXRWEXVA== "@standard-schema/spec@^1.0.0": - version "1.0.0" - resolved "https://registry.yarnpkg.com/@standard-schema/spec/-/spec-1.0.0.tgz#f193b73dc316c4170f2e82a881da0f550d551b9c" - integrity sha512-m2bOd0f2RT9k8QJx1JN85cZYyH1RqFBdlwtkSlf4tBDYLCiiZnv1fIIwacK6cqwXavOydf0NPToMQgpKq+dVlA== + version "1.1.0" + resolved "https://registry.yarnpkg.com/@standard-schema/spec/-/spec-1.1.0.tgz#a79b55dbaf8604812f52d140b2c9ab41bc150bb8" + integrity sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w== "@surma/rollup-plugin-off-main-thread@^2.2.3": version "2.2.3" @@ -5048,6 +5064,11 @@ dependencies: server-only "^0.0.1" +"@vercel/oidc@3.1.0": + version "3.1.0" + resolved "https://registry.yarnpkg.com/@vercel/oidc/-/oidc-3.1.0.tgz#066caee449b84079f33c7445fc862464fe10ec32" + integrity sha512-Fw28YZpRnA3cAHHDlkt7xQHiJ0fcL+NRcIqsocZQUSmbzeIKRpwttJjik5ZGanXP+vlA4SbTg+AbA3bP363l+w== + "@webassemblyjs/ast@1.14.1", "@webassemblyjs/ast@^1.14.1": version "1.14.1" resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.14.1.tgz#a9f6a07f2b03c95c8d38c4536a1fdfb521ff55b6" @@ -5314,14 +5335,14 @@ aggregate-error@^3.0.0: clean-stack "^2.0.0" indent-string "^4.0.0" -ai@5.0.52, ai@^5.0.30: - version "5.0.52" - resolved "https://registry.yarnpkg.com/ai/-/ai-5.0.52.tgz#3aa9a6eab56505db2c94ce7a16a7ea089760977e" - integrity sha512-GLlRHjMlvN9+w7UYGxCpUQ8GgCRv5Z+JCprRH3Q8YbXJ/JyIc6EP9+YRUmQsyExX/qQsuehe7y/LLygarbSTOw== +ai@5.0.131: + version "5.0.131" + resolved "https://registry.yarnpkg.com/ai/-/ai-5.0.131.tgz#7a6fcc0efb01ee5e222d222a099ad9d82dd0a04f" + integrity sha512-KYuhcpiigvPCpFbNzNKcoZ7AWKnTeE++HRqnWqX0MgSbk1xVi0Q5wvfMmnF71n7l5JjytefLV3NkJwbU+7AR/g== dependencies: - "@ai-sdk/gateway" "1.0.29" - "@ai-sdk/provider" "2.0.0" - "@ai-sdk/provider-utils" "3.0.9" + "@ai-sdk/gateway" "2.0.37" + "@ai-sdk/provider" "2.0.1" + "@ai-sdk/provider-utils" "3.0.21" "@opentelemetry/api" "1.9.0" ajv-formats@^2.1.1: @@ -5370,7 +5391,7 @@ algoliasearch-helper@^3.26.0: dependencies: "@algolia/events" "^4.0.1" -algoliasearch@^5.28.0, algoliasearch@^5.37.0: +algoliasearch@^5.37.0: version "5.38.0" resolved "https://registry.yarnpkg.com/algoliasearch/-/algoliasearch-5.38.0.tgz#43615d81c493ca4a4efd74edb93910b2e71c91e1" integrity sha512-8VJKIzheeI9cjuVJhU1hYEVetOTe7LvA+CujAI7yqvYsPtZfVEvv1pg9AeFNtHBg/ZoSLGU5LPijhcY5l3Ea9g== @@ -8802,7 +8823,7 @@ events@^3.2.0: resolved "https://registry.yarnpkg.com/events/-/events-3.3.0.tgz#31a95ad0a924e2d2c419a813aeb2c4e878ea7400" integrity sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q== -eventsource-parser@^3.0.5: +eventsource-parser@^3.0.6: version "3.0.6" resolved "https://registry.yarnpkg.com/eventsource-parser/-/eventsource-parser-3.0.6.tgz#292e165e34cacbc936c3c92719ef326d4aeb4e90" integrity sha512-Vo1ab+QXPzZ4tCa8SwIHJFaSzy4R6SHf7BY79rFBDf0idraZWAkYrDjDj8uWaSm3S2TK+hJ7/t1CEmZ7jXw+pg== @@ -12344,11 +12365,6 @@ marked@^15.0.7: resolved "https://registry.yarnpkg.com/marked/-/marked-15.0.12.tgz#30722c7346e12d0a2d0207ab9b0c4f0102d86c4e" integrity sha512-8dD6FusOQSrpv9Z1rdNMdlSgQOIP880DHqnohobOmYLElGEqAL/JvxvuxZO16r4HtjTlfPRDC1hbvxC9dPN2nA== -marked@^16.3.0: - version "16.3.0" - resolved "https://registry.yarnpkg.com/marked/-/marked-16.3.0.tgz#2f513891f867d6edc4772b4a026db9cc331eb94f" - integrity sha512-K3UxuKu6l6bmA5FUwYho8CfJBlsUWAooKtdGgMcERSpF7gcBUrCGsLH7wDaaNOzwq18JzSUDyoEb/YsrqMac3w== - math-intrinsics@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/math-intrinsics/-/math-intrinsics-1.1.0.tgz#a0dd74be81e2aa5c2f27e65ce283605ee4e2b7f9" @@ -17313,12 +17329,12 @@ swc-loader@^0.2.6: "@swc/counter" "^0.1.3" swr@^2.2.5: - version "2.3.6" - resolved "https://registry.yarnpkg.com/swr/-/swr-2.3.6.tgz#5fee0ee8a0762a16871ee371075cb09422b64f50" - integrity sha512-wfHRmHWk/isGNMwlLGlZX5Gzz/uTgo0o2IRuTMcf4CPuPFJZlq0rDaKUx+ozB5nBOReNV1kiOyzMfj+MBMikLw== + version "2.4.0" + resolved "https://registry.yarnpkg.com/swr/-/swr-2.4.0.tgz#cd11e368cb13597f61ee3334428aa20b5e81f36e" + integrity sha512-sUlC20T8EOt1pHmDiqueUWMmRRX03W7w5YxovWX7VR2KHEPCTMly85x05vpkP5i6Bu4h44ePSMD9Tc+G2MItFw== dependencies: dequal "^2.0.3" - use-sync-external-store "^1.4.0" + use-sync-external-store "^1.6.0" symbol-tree@^3.2.4: version "3.2.4" @@ -18187,10 +18203,10 @@ use-editable@^2.3.3: resolved "https://registry.yarnpkg.com/use-editable/-/use-editable-2.3.3.tgz#a292fe9ba4c291cd28d1cc2728c75a5fc8d9a33f" integrity sha512-7wVD2JbfAFJ3DK0vITvXBdpd9JAz5BcKAAolsnLBuBn6UDDwBGuCIAGvR3yA2BNKm578vAMVHFCWaOcA+BhhiA== -use-sync-external-store@^1.4.0: - version "1.5.0" - resolved "https://registry.yarnpkg.com/use-sync-external-store/-/use-sync-external-store-1.5.0.tgz#55122e2a3edd2a6c106174c27485e0fd59bcfca0" - integrity sha512-Rb46I4cGGVBmjamjphe8L/UnvJD+uPPtTkNvX5mZgqdbavhI4EbgIWJiIHXJ8bc/i9EQGPRh4DwEURJ552Do0A== +use-sync-external-store@^1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/use-sync-external-store/-/use-sync-external-store-1.6.0.tgz#b174bfa65cb2b526732d9f2ac0a408027876f32d" + integrity sha512-Pp6GSwGP/NrPIrxVFAIkOQeyw8lFenOHijQWkUTrDvrF4ALqylP2C/KCkeS9dpUM3KvYRQhna5vt7IL95+ZQ9w== util-deprecate@^1.0.1, util-deprecate@^1.0.2, util-deprecate@~1.0.1: version "1.0.2" @@ -19097,11 +19113,6 @@ zod@^3.22.4: resolved "https://registry.yarnpkg.com/zod/-/zod-3.25.76.tgz#26841c3f6fd22a6a2760e7ccb719179768471e34" integrity sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ== -zod@^4.1.8: - version "4.1.11" - resolved "https://registry.yarnpkg.com/zod/-/zod-4.1.11.tgz#4aab62f76cfd45e6c6166519ba31b2ea019f75f5" - integrity sha512-WPsqwxITS2tzx1bzhIKsEs19ABD5vmCVa4xBo2tq/SrV4RNZtfws1EnCWQXM6yh8bD08a1idvkB5MZSBiZsjwg== - zwitch@^2.0.0, zwitch@^2.0.4: version "2.0.4" resolved "https://registry.yarnpkg.com/zwitch/-/zwitch-2.0.4.tgz#c827d4b0acb76fc3e685a4c6ec2902d51070e9d7"