Skip to content

Commit 302fd92

Browse files
committed
navbar
1 parent c7cd41b commit 302fd92

File tree

2 files changed

+65
-6
lines changed

2 files changed

+65
-6
lines changed
Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,48 @@
1-
export default () => <div>NavBar</div>;
1+
import NavBar from '@node-core/ui-components/Containers/NavBar';
2+
import NodejsLogo from '@node-core/ui-components/Common/NodejsLogo';
3+
4+
const MDXNavBar = () => {
5+
return (
6+
<NavBar
7+
pathname="/docs/latest/api/"
8+
Logo={NodejsLogo}
9+
sidebarItemTogglerAriaLabel="Toggle navigation menu"
10+
navItems={[
11+
{
12+
link: '/learn',
13+
text: 'Learn',
14+
},
15+
{
16+
link: '/about',
17+
text: 'About',
18+
},
19+
{
20+
link: '/download',
21+
text: 'Download',
22+
},
23+
{
24+
link: '/blog',
25+
text: 'Blog',
26+
},
27+
{
28+
link: '/docs/latest/api/',
29+
text: 'Docs',
30+
},
31+
{
32+
link: 'https://github.com/nodejs/node/blob/main/CONTRIBUTING.md',
33+
text: 'Contribute',
34+
target: '_blank',
35+
},
36+
{
37+
link: 'https://training.linuxfoundation.org/openjs/',
38+
text: 'Certification',
39+
target: '_blank',
40+
},
41+
]}
42+
>
43+
<p>some child</p>
44+
</NavBar>
45+
);
46+
};
47+
48+
export default MDXNavBar;

src/generators/web/utils/bundleCode.mjs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ const uiComponentsResolver = {
1212
name: 'ui-components-resolver',
1313
/**
1414
* This plugin intercepts imports starting with '@node-core/ui-components' or '#ui/' and resolves them
15-
* to the corresponding index.tsx file in the node_modules directory. If the index.tsx file
16-
* doesn't exist, the resolution falls back to the default behavior.
15+
* to the corresponding index.tsx file first, then .tsx file if index doesn't exist.
1716
* @param {import('esbuild').PluginBuild} build
1817
*/
1918
setup(build) {
@@ -29,12 +28,24 @@ const uiComponentsResolver = {
2928
'@node-core/ui-components/'
3029
);
3130

32-
// Resolve to index.tsx file
31+
// Try index.tsx first
3332
const indexPath = fileURLToPath(
3433
import.meta.resolve(`${normalizedPath}/index.tsx`)
3534
);
35+
if (existsSync(indexPath)) {
36+
return { path: indexPath };
37+
}
38+
39+
// Try .tsx extension
40+
const directPath = fileURLToPath(
41+
import.meta.resolve(`${normalizedPath}.tsx`)
42+
);
43+
if (existsSync(directPath)) {
44+
return { path: directPath };
45+
}
3646

37-
return existsSync(indexPath) ? { path: indexPath } : undefined;
47+
// Fall back to default resolution
48+
return undefined;
3849
});
3950
},
4051
};
@@ -51,7 +62,8 @@ export default async code => {
5162
resolveDir: ESBUILD_RESOLVE_DIR,
5263
},
5364
bundle: true,
54-
minify: true,
65+
minify: false,
66+
sourcemap: 'inline',
5567
format: 'iife',
5668
target: 'es2020',
5769
platform: 'browser',

0 commit comments

Comments
 (0)