From 288d7d923c15bc8b448a5b3f5906f6e799312f68 Mon Sep 17 00:00:00 2001 From: avivkeller Date: Mon, 13 Jul 2026 06:59:40 -0700 Subject: [PATCH 1/2] feat: allow dynamic configurations --- src/generators/web/index.mjs | 10 ++++++++-- src/generators/web/ui/components/NavBar.jsx | 4 ++-- src/utils/configuration/index.mjs | 11 ++++++++--- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/generators/web/index.mjs b/src/generators/web/index.mjs index 080a88e9..97d6f3c8 100644 --- a/src/generators/web/index.mjs +++ b/src/generators/web/index.mjs @@ -30,7 +30,10 @@ export default createLazyGenerator({ dependsOn: 'jsx-ast', - defaultConfiguration: { + /** + * @param {import('../../utils/configuration/types').Configuration} config + */ + defaultConfiguration: config => ({ templatePath: join(import.meta.dirname, 'template.html'), project: 'Node.js', title: '{project} {version} Documentation', @@ -38,6 +41,9 @@ export default createLazyGenerator({ editURL: `${GITHUB_EDIT_URL}/doc/api{path}.md`, pageURL: '{baseURL}/latest-{version}/api{path}.html', remoteConfigUrl: 'https://nodejs.org/site.json', + // By default, the search box is only shown when we are _also_ building search data + showSearchBox: + Array.isArray(config.target) && config.target.includes('orama-db'), // Project-specific document `` contents. `meta` and `links` are // arrays of attribute bags (boolean `true` renders a valueless attribute, @@ -97,5 +103,5 @@ export default createLazyGenerator({ // Options merged into the Rolldown build (client and server), e.g. extra // `plugins`. See the README for the merge semantics. rolldown: {}, - }, + }), }); diff --git a/src/generators/web/ui/components/NavBar.jsx b/src/generators/web/ui/components/NavBar.jsx index 15fa85dd..c0484e80 100644 --- a/src/generators/web/ui/components/NavBar.jsx +++ b/src/generators/web/ui/components/NavBar.jsx @@ -6,7 +6,7 @@ import GitHubIcon from '@node-core/ui-components/Icons/Social/GitHub'; import SearchBox from './SearchBox'; import { useTheme } from '../hooks/useTheme.mjs'; -import { repository } from '#theme/config'; +import { repository, showSearchBox } from '#theme/config'; import Logo from '#theme/Logo'; /** @@ -21,7 +21,7 @@ export default ({ metadata }) => { sidebarItemTogglerAriaLabel="Toggle navigation menu" navItems={[]} > - + {showSearchBox && } +export const getDefaultConfig = lazy(config => Object.keys(allGenerators).reduce( (acc, k) => { - acc[k] = allGenerators[k].defaultConfiguration ?? {}; + if ('defaultConfiguration' in allGenerators[k]) { + acc[k] = + typeof allGenerators[k].defaultConfiguration === 'function' + ? allGenerators[k].defaultConfiguration(config) + : allGenerators[k].defaultConfiguration; + } return acc; }, /** @type {import('./types').Configuration} */ ({ @@ -138,7 +143,7 @@ export const createRunConfiguration = async options => { const merged = deepMerge( config, createConfigFromCLIOptions(options), - getDefaultConfig() + getDefaultConfig(config) ); // These need to be coerced From 04874438e6ec4d625515d9547b2fa5cbf8e52618 Mon Sep 17 00:00:00 2001 From: avivkeller Date: Mon, 13 Jul 2026 07:05:36 -0700 Subject: [PATCH 2/2] feat: allow dynamic configurations --- src/utils/configuration/index.mjs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/utils/configuration/index.mjs b/src/utils/configuration/index.mjs index d2cb78a1..01fec003 100644 --- a/src/utils/configuration/index.mjs +++ b/src/utils/configuration/index.mjs @@ -18,12 +18,13 @@ import { deepMerge, lazy } from '../misc.mjs'; export const getDefaultConfig = lazy(config => Object.keys(allGenerators).reduce( (acc, k) => { - if ('defaultConfiguration' in allGenerators[k]) { - acc[k] = - typeof allGenerators[k].defaultConfiguration === 'function' + acc[k] = + 'defaultConfiguration' in allGenerators[k] + ? typeof allGenerators[k].defaultConfiguration === 'function' ? allGenerators[k].defaultConfiguration(config) - : allGenerators[k].defaultConfiguration; - } + : allGenerators[k].defaultConfiguration + : {}; + return acc; }, /** @type {import('./types').Configuration} */ ({