Skip to content

Commit 433e4cc

Browse files
authored
feat: automate fetching and sanitization of webpack ecosystem readmes (#122)
1 parent 41118a4 commit 433e4cc

10 files changed

Lines changed: 612 additions & 968 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ out
33
*.generated.*
44
/.cache
55
/pages/api
6+
/pages/loaders
7+
/pages/plugins

components/Footer/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import GitHubIcon from '@node-core/ui-components/Icons/Social/GitHub';
22
import LinkedInIcon from '@node-core/ui-components/Icons/Social/LinkedIn';
33
import DiscordIcon from '@node-core/ui-components/Icons/Social/Discord';
44
import XIcon from '@node-core/ui-components/Icons/Social/X';
5-
import { footer } from '#theme/site' with { type: 'json' };
5+
import { footer } from '#theme/site';
66

77
import Logo from '#theme/Logo';
88
import styles from './index.module.css';

components/NavBar.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import GitHubIcon from '@node-core/ui-components/Icons/Social/GitHub';
55

66
import SearchBox from '@node-core/doc-kit/src/generators/web/ui/components/SearchBox';
77
import { useTheme } from '@node-core/doc-kit/src/generators/web/ui/hooks/useTheme.mjs';
8-
import { navbar } from '#theme/site' with { type: 'json' };
8+
import { navbar } from '#theme/site';
99
import Logo from '#theme/Logo';
1010

1111
/**

components/SideBar.jsx

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import SideBar from '@node-core/ui-components/Containers/Sidebar';
2-
import { sidebar } from '#theme/local/site' with { type: 'json' };
2+
import { sidebar } from '#theme/local/site';
33

44
/** @param {string} url */
55
const redirect = url => (window.location.href = url);
@@ -8,15 +8,24 @@ const PrefetchLink = props => <a {...props} rel="prefetch" />;
88

99
const pathnameFor = path => path.replace(/\/index$/, '') || '/';
1010

11+
const groupsFor = path => {
12+
const segment = path.split('/').filter(Boolean)[0];
13+
const matched = sidebar.filter(g => g.groupName.toLowerCase() === segment);
14+
return matched.length > 0 ? matched : sidebar;
15+
};
16+
1117
/**
1218
* Sidebar component for MDX documentation with page navigation.
1319
*/
14-
export default ({ metadata }) => (
15-
<SideBar
16-
pathname={pathnameFor(metadata.path)}
17-
groups={sidebar}
18-
onSelect={redirect}
19-
as={PrefetchLink}
20-
title="Navigation"
21-
/>
22-
);
20+
export default ({ metadata }) => {
21+
const path = pathnameFor(metadata.path);
22+
return (
23+
<SideBar
24+
pathname={path}
25+
groups={groupsFor(path)}
26+
onSelect={redirect}
27+
as={PrefetchLink}
28+
title="Navigation"
29+
/>
30+
);
31+
};

0 commit comments

Comments
 (0)