mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-03 08:49:51 +02:00
Merge branch 'main' of github.com:facebook/docusaurus into lex111/filter-sidebar
This commit is contained in:
commit
aa997da632
47 changed files with 979 additions and 836 deletions
|
@ -129,9 +129,10 @@ export {isRegexpStringMatch} from './utils/regexpUtils';
|
|||
export {useHomePageRoute} from './utils/routesUtils';
|
||||
|
||||
export {
|
||||
PageMetadata,
|
||||
HtmlClassNameProvider,
|
||||
PluginHtmlClassNameProvider,
|
||||
} from './utils/metadataUtilsTemp';
|
||||
} from './utils/metadataUtils';
|
||||
|
||||
export {
|
||||
useColorMode,
|
||||
|
|
|
@ -9,6 +9,53 @@ import React, {type ReactNode} from 'react';
|
|||
import Head from '@docusaurus/Head';
|
||||
import clsx from 'clsx';
|
||||
import useRouteContext from '@docusaurus/useRouteContext';
|
||||
import {useBaseUrlUtils} from '@docusaurus/useBaseUrl';
|
||||
import {useTitleFormatter} from './generalUtils';
|
||||
|
||||
interface PageMetadataProps {
|
||||
readonly title?: string;
|
||||
readonly description?: string;
|
||||
readonly keywords?: readonly string[] | string;
|
||||
readonly image?: string;
|
||||
readonly children?: ReactNode;
|
||||
}
|
||||
|
||||
// Helper component to manipulate page metadata and override site defaults
|
||||
export function PageMetadata({
|
||||
title,
|
||||
description,
|
||||
keywords,
|
||||
image,
|
||||
children,
|
||||
}: PageMetadataProps): JSX.Element {
|
||||
const pageTitle = useTitleFormatter(title);
|
||||
const {withBaseUrl} = useBaseUrlUtils();
|
||||
const pageImage = image ? withBaseUrl(image, {absolute: true}) : undefined;
|
||||
|
||||
return (
|
||||
<Head>
|
||||
{title && <title>{pageTitle}</title>}
|
||||
{title && <meta property="og:title" content={pageTitle} />}
|
||||
|
||||
{description && <meta name="description" content={description} />}
|
||||
{description && <meta property="og:description" content={description} />}
|
||||
|
||||
{keywords && (
|
||||
<meta
|
||||
name="keywords"
|
||||
content={
|
||||
(Array.isArray(keywords) ? keywords.join(',') : keywords) as string
|
||||
}
|
||||
/>
|
||||
)}
|
||||
|
||||
{pageImage && <meta property="og:image" content={pageImage} />}
|
||||
{pageImage && <meta name="twitter:image" content={pageImage} />}
|
||||
|
||||
{children}
|
||||
</Head>
|
||||
);
|
||||
}
|
||||
|
||||
const HtmlClassNameContext = React.createContext<string | undefined>(undefined);
|
||||
|
|
@ -47,7 +47,8 @@ export class ReactContextError extends Error {
|
|||
super();
|
||||
this.name = 'ReactContextError';
|
||||
this.message = `Hook ${
|
||||
this.stack?.split('\n')[1]?.match(/at (?<name>\w+)/)?.groups!.name
|
||||
this.stack?.split('\n')[1]?.match(/at (?:\w+\.)?(?<name>\w+)/)?.groups!
|
||||
.name
|
||||
} is called outside the <${providerName}>. ${additionalInfo || ''}`;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue