allow partial overriding of the theme config.

This commit is contained in:
Hossein Mehrabi
2022-10-28 11:38:40 +03:30
parent 9d583f8967
commit bb831e059c
4 changed files with 28 additions and 12 deletions
@@ -8,6 +8,7 @@ import { themeConfigs } from './theme-config/index'
import { PluginOptions, ThemeNames } from './types'
import { createCommonDataDir, createTeamFile } from './utils/data.utils'
import { findDocInstances, validateDocPluginOptions } from './utils/docs.utils'
import { defaultsDeep } from './utils/object.utils'
const makeSearchPluginConfig = (
plugins: PluginConfig[],
@@ -53,7 +54,10 @@ export default function logosPreset(
siteConfigs[options.businessUnit],
)
context.siteConfig.themeConfig = themeConfigs[options.businessUnit]
context.siteConfig.themeConfig = defaultsDeep(
[{}, context.siteConfig.themeConfig, themeConfigs[options.businessUnit]],
false,
)
createCommonDataDir()
createTeamFile(context, options)
@@ -9,16 +9,7 @@ export const wakuThemeConfig: typeof baseThemeConfig = {
src: 'theme/image/logo.svg',
height: 26,
},
items: [
{
to: 'blog',
label: 'Blog',
},
{
type: 'localeDropdown',
position: 'right',
},
],
items: [],
},
metadata: [
{ name: 'keywords', content: 'waku, web3' },
@@ -1,3 +1,9 @@
export type ThemeConfig = {}
import { NavbarItem } from '@docusaurus/theme-common'
export type ThemeConfig = {
navbar?: {
items?: NavbarItem[]
}
}
export type { PluginOptions as DefaultThemeOptions } from '@acid-info/logos-docusaurus-theme/src'
@@ -0,0 +1,15 @@
import * as _ from 'lodash'
export const defaultsDeep = (objects: any[], mergeArrays: boolean = false) => {
if (mergeArrays) return _.defaultsDeep(...(objects as [any, any]))
let output = {}
objects.reverse().forEach((item) => {
_.mergeWith(output, item, (objectValue, sourceValue) => {
return Array.isArray(sourceValue) ? sourceValue : undefined
})
})
return output
}