From 288d7d923c15bc8b448a5b3f5906f6e799312f68 Mon Sep 17 00:00:00 2001 From: avivkeller Date: Mon, 13 Jul 2026 06:59:40 -0700 Subject: [PATCH 1/4] 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/4] 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} */ ({ From d4610f445bb60b5dd31a8118de2bec0f8abfe059 Mon Sep 17 00:00:00 2001 From: Aviv Keller Date: Tue, 14 Jul 2026 13:04:09 -0700 Subject: [PATCH 3/4] fixup! --- src/utils/configuration/index.mjs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/utils/configuration/index.mjs b/src/utils/configuration/index.mjs index 01fec003..74486bb2 100644 --- a/src/utils/configuration/index.mjs +++ b/src/utils/configuration/index.mjs @@ -141,11 +141,8 @@ export const createRunConfiguration = async options => { config.target &&= enforceArray(config.target); // Merge with defaults - const merged = deepMerge( - config, - createConfigFromCLIOptions(options), - getDefaultConfig(config) - ); + const intermediate = deepMerge(config, createConfigFromCLIOptions(options)); + const merged = deepMerge(intermediate, getDefaultConfig(intermediate)); // These need to be coerced merged.threads = Math.max(merged.threads, 1); From 953b64846fa451e697e751e0b66f1d44d8aeb63f Mon Sep 17 00:00:00 2001 From: Aviv Keller Date: Tue, 14 Jul 2026 14:31:06 -0700 Subject: [PATCH 4/4] Create dynamic-configuration.md --- .changeset/dynamic-configuration.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/dynamic-configuration.md diff --git a/.changeset/dynamic-configuration.md b/.changeset/dynamic-configuration.md new file mode 100644 index 00000000..1c2de119 --- /dev/null +++ b/.changeset/dynamic-configuration.md @@ -0,0 +1,5 @@ +--- +'@node-core/doc-kit': patch +--- + +Allow for the specification of dynamically generated configuration values