Skip to content

Commit 51d92e0

Browse files
committed
feat(docusaurus-website): Allow theme override
1 parent bb06743 commit 51d92e0

File tree

1 file changed

+82
-75
lines changed

1 file changed

+82
-75
lines changed

modules/docusaurus-website/src/get-default-config.ts

Lines changed: 82 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ export type OcularWebsiteConfig = {
9696
/** Search settings */
9797
search?: false | 'local' | ThemeConfig['algolia'];
9898

99+
/** Custom overrides of the theme */
100+
themeConfig?: ThemeConfig;
101+
99102
/** Additional CSS files to include */
100103
customCss?: string[];
101104

@@ -119,6 +122,7 @@ export function getDocusaurusConfig(config: OcularWebsiteConfig): Config {
119122
examplesDir,
120123
exampleTableOfContents,
121124
webpackConfig = {},
125+
themeConfig = {},
122126
customCss = [],
123127
navbarItems = [],
124128
plugins = []
@@ -189,82 +193,85 @@ export function getDocusaurusConfig(config: OcularWebsiteConfig): Config {
189193
...plugins
190194
].filter(Boolean),
191195

192-
themeConfig: {
193-
navbar: {
194-
title: projectName,
195-
logo: {
196-
alt: 'vis.gl Logo',
197-
src: '/visgl-logo-dark.png',
198-
srcDark: '/visgl-logo-light.png'
199-
},
200-
items: [
201-
hasExamples && {
202-
to: '/examples',
203-
position: 'left',
204-
label: 'Examples'
205-
},
206-
{
207-
to: '/docs',
208-
position: 'left',
209-
label: 'Docs'
196+
themeConfig: deepmerge(
197+
{
198+
navbar: {
199+
title: projectName,
200+
logo: {
201+
alt: 'vis.gl Logo',
202+
src: '/visgl-logo-dark.png',
203+
srcDark: '/visgl-logo-light.png'
210204
},
211-
{
212-
href: repoUrl,
213-
label: 'GitHub',
214-
position: 'right'
215-
},
216-
...navbarItems
217-
].filter(Boolean)
218-
},
219-
footer: {
220-
style: 'dark',
221-
links: [
222-
{
223-
title: 'Other vis.gl Libraries',
224-
items: [
225-
{
226-
label: 'deck.gl',
227-
href: 'https:/deck.gl'
228-
},
229-
{
230-
label: 'luma.gl',
231-
href: 'https://luma.gl'
232-
},
233-
{
234-
label: 'loaders.gl',
235-
href: 'https://loaders.gl'
236-
},
237-
{
238-
label: 'react-map-gl',
239-
href: 'https://visgl.github.io/react-map-gl'
240-
},
241-
{
242-
label: 'deck.gl-community',
243-
href: 'https://visgl.github.io/deck.gl-community/'
244-
}
245-
].filter((item) => item.label !== projectName)
246-
},
247-
{
248-
title: 'More',
249-
items: [
250-
{
251-
label: 'vis.gl blog on Medium',
252-
href: 'https://medium.com/vis-gl'
253-
},
254-
{
255-
label: 'GitHub',
256-
href: repoUrl
257-
}
258-
]
259-
}
260-
],
261-
copyright: `Copyright © ${new Date().getFullYear()} OpenJS Foundation`
205+
items: [
206+
hasExamples && {
207+
to: '/examples',
208+
position: 'left',
209+
label: 'Examples'
210+
},
211+
{
212+
to: '/docs',
213+
position: 'left',
214+
label: 'Docs'
215+
},
216+
{
217+
href: repoUrl,
218+
label: 'GitHub',
219+
position: 'right'
220+
},
221+
...navbarItems
222+
].filter(Boolean)
223+
},
224+
footer: {
225+
style: 'dark',
226+
links: [
227+
{
228+
title: 'Other vis.gl Libraries',
229+
items: [
230+
{
231+
label: 'deck.gl',
232+
href: 'https:/deck.gl'
233+
},
234+
{
235+
label: 'luma.gl',
236+
href: 'https://luma.gl'
237+
},
238+
{
239+
label: 'loaders.gl',
240+
href: 'https://loaders.gl'
241+
},
242+
{
243+
label: 'react-map-gl',
244+
href: 'https://visgl.github.io/react-map-gl'
245+
},
246+
{
247+
label: 'deck.gl-community',
248+
href: 'https://visgl.github.io/deck.gl-community/'
249+
}
250+
].filter((item) => item.label !== projectName)
251+
},
252+
{
253+
title: 'More',
254+
items: [
255+
{
256+
label: 'vis.gl blog on Medium',
257+
href: 'https://medium.com/vis-gl'
258+
},
259+
{
260+
label: 'GitHub',
261+
href: repoUrl
262+
}
263+
]
264+
}
265+
],
266+
copyright: `Copyright © ${new Date().getFullYear()} OpenJS Foundation`
267+
},
268+
algolia: typeof search === 'object' ? search : undefined,
269+
prism: {
270+
theme: lightCodeTheme,
271+
darkTheme: darkCodeTheme
272+
}
262273
},
263-
algolia: typeof search === 'object' ? search : undefined,
264-
prism: {
265-
theme: lightCodeTheme,
266-
darkTheme: darkCodeTheme
267-
}
268-
} as ThemeConfig
274+
themeConfig
275+
) as ThemeConfig
269276
} as Config;
270277
}

0 commit comments

Comments
 (0)