feat(theme): show unlisted/draft banners in dev mode (#10376)

Co-authored-by: OzakIOne <OzakIOne@users.noreply.github.com>
Co-authored-by: sebastien <lorber.sebastien@gmail.com>
This commit is contained in:
ozaki 2024-08-08 20:48:42 +02:00 committed by GitHub
parent c58fcbdecd
commit 95ab9f8ee4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
48 changed files with 411 additions and 140 deletions

View file

@ -123,7 +123,9 @@ export {
UnlistedBannerTitle,
UnlistedBannerMessage,
UnlistedMetadata,
} from './utils/unlistedUtils';
DraftBannerTitle,
DraftBannerMessage,
} from './translations/contentVisibilityTranslations';
export {
ErrorBoundaryTryAgainButton,

View file

@ -12,7 +12,7 @@ import Head from '@docusaurus/Head';
export function UnlistedBannerTitle(): JSX.Element {
return (
<Translate
id="theme.unlistedContent.title"
id="theme.contentVisibility.unlistedBanner.title"
description="The unlisted content banner title">
Unlisted page
</Translate>
@ -22,7 +22,7 @@ export function UnlistedBannerTitle(): JSX.Element {
export function UnlistedBannerMessage(): JSX.Element {
return (
<Translate
id="theme.unlistedContent.message"
id="theme.contentVisibility.unlistedBanner.message"
description="The unlisted content banner message">
This page is unlisted. Search engines will not index it, and only users
having a direct link can access it.
@ -30,6 +30,8 @@ export function UnlistedBannerMessage(): JSX.Element {
);
}
// TODO Docusaurus v4 breaking change (since it's v3 public theme-common API :/)
// Move this to theme/ContentVisibility/Unlisted
export function UnlistedMetadata(): JSX.Element {
return (
<Head>
@ -37,3 +39,24 @@ export function UnlistedMetadata(): JSX.Element {
</Head>
);
}
export function DraftBannerTitle(): JSX.Element {
return (
<Translate
id="theme.contentVisibility.draftBanner.title"
description="The draft content banner title">
Draft page
</Translate>
);
}
export function DraftBannerMessage(): JSX.Element {
return (
<Translate
id="theme.contentVisibility.draftBanner.message"
description="The draft content banner message">
This page is a draft. It will only be visible in dev and be excluded from
the production build.
</Translate>
);
}

View file

@ -43,6 +43,7 @@ export const ThemeClassNames = {
codeBlock: 'theme-code-block',
admonition: 'theme-admonition',
unlistedBanner: 'theme-unlisted-banner',
draftBanner: 'theme-draft-banner',
admonitionType: (type: string) => `theme-admonition-${type}`,
},