Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for browser-based theme config file (docusaurus.theme.js) #9619

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
76 changes: 0 additions & 76 deletions examples/classic-typescript/docusaurus.config.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

78 changes: 78 additions & 0 deletions examples/classic-typescript/docusaurus.theme.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

79 changes: 0 additions & 79 deletions examples/classic/docusaurus.config.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

74 changes: 74 additions & 0 deletions examples/classic/docusaurus.theme.jsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions packages/docusaurus-module-type-aliases/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ declare module '@generated/docusaurus.config' {
export default config;
}

declare module '@generated/docusaurus.theme' {
import type {ThemeConfig} from '@docusaurus/types';

const themeConfig: ThemeConfig;
export default themeConfig;
}

declare module '@generated/site-metadata' {
import type {SiteMetadata} from '@docusaurus/types';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,23 @@ export default function AnnouncementBarContent(
props: Props,
): JSX.Element | null {
const {announcementBar} = useThemeConfig();
const {content} = announcementBar!;
const {content: Content} = announcementBar!;

// TODO Docusaurus v4: remove legacy announcement bar html string form?
if (typeof Content === 'string') {
return (
<div
{...props}
className={clsx(styles.content, props.className)}
// Developer provided the HTML, so assume it's safe.
// eslint-disable-next-line react/no-danger
dangerouslySetInnerHTML={{__html: Content}}
/>
);
}
return (
<div
{...props}
className={clsx(styles.content, props.className)}
// Developer provided the HTML, so assume it's safe.
// eslint-disable-next-line react/no-danger
dangerouslySetInnerHTML={{__html: content}}
/>
<div {...props} className={clsx(styles.content, props.className)}>
<Content />
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

import React from 'react';
import {type FooterLinkItem} from '@docusaurus/theme-common';
import LinkItem from '@theme/Footer/LinkItem';
import type {Props} from '@theme/Footer/Links/Simple';

Expand All @@ -30,7 +31,7 @@ export default function FooterLinksSimple({links}: Props): JSX.Element {
return (
<div className="footer__links text--center">
<div className="footer__links">
{links.map((item, i) => (
{links.map((item: FooterLinkItem, i: number) => (
<React.Fragment key={i}>
<SimpleLinkItem item={item} />
{links.length !== i + 1 && <Separator />}
Expand Down
Loading