Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/generators/web/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,20 @@ 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',
useAbsoluteURLs: false,
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 `<head>` contents. `meta` and `links` are
// arrays of attribute bags (boolean `true` renders a valueless attribute,
Expand Down Expand Up @@ -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: {},
},
}),
});
4 changes: 2 additions & 2 deletions src/generators/web/ui/components/NavBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
Expand All @@ -21,7 +21,7 @@ export default ({ metadata }) => {
sidebarItemTogglerAriaLabel="Toggle navigation menu"
navItems={[]}
>
<SearchBox pathname={metadata.path} />
{showSearchBox && <SearchBox pathname={metadata.path} />}
<ThemeToggle
onChange={setThemePreference}
currentTheme={themePreference}
Expand Down
17 changes: 10 additions & 7 deletions src/utils/configuration/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,16 @@ import { deepMerge, lazy } from '../misc.mjs';
/**
* Get's the default configuration
*/
export const getDefaultConfig = lazy(() =>
export const getDefaultConfig = lazy(config =>
Comment thread
avivkeller marked this conversation as resolved.
Object.keys(allGenerators).reduce(
(acc, k) => {
acc[k] = allGenerators[k].defaultConfiguration ?? {};
acc[k] =
'defaultConfiguration' in allGenerators[k]
? typeof allGenerators[k].defaultConfiguration === 'function'
? allGenerators[k].defaultConfiguration(config)
: allGenerators[k].defaultConfiguration
: {};

return acc;
},
/** @type {import('./types').Configuration} */ ({
Expand Down Expand Up @@ -135,11 +141,8 @@ export const createRunConfiguration = async options => {
config.target &&= enforceArray(config.target);

// Merge with defaults
const merged = deepMerge(
config,
createConfigFromCLIOptions(options),
getDefaultConfig()
);
const intermediate = deepMerge(config, createConfigFromCLIOptions(options));
const merged = deepMerge(intermediate, getDefaultConfig(intermediate));

// These need to be coerced
merged.threads = Math.max(merged.threads, 1);
Expand Down
Loading