Skip to content
Merged
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ out
*.generated.*
/.cache
/pages/api
/pages/loaders
/pages/plugins
2 changes: 1 addition & 1 deletion components/Footer/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import GitHubIcon from '@node-core/ui-components/Icons/Social/GitHub';
import LinkedInIcon from '@node-core/ui-components/Icons/Social/LinkedIn';
import DiscordIcon from '@node-core/ui-components/Icons/Social/Discord';
import XIcon from '@node-core/ui-components/Icons/Social/X';
import { footer } from '#theme/site' with { type: 'json' };
import { footer } from '#theme/site';

import Logo from '#theme/Logo';
import styles from './index.module.css';
Expand Down
2 changes: 1 addition & 1 deletion components/NavBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import GitHubIcon from '@node-core/ui-components/Icons/Social/GitHub';

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

/**
Expand Down
29 changes: 19 additions & 10 deletions components/SideBar.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import SideBar from '@node-core/ui-components/Containers/Sidebar';
import { sidebar } from '#theme/local/site' with { type: 'json' };
import { sidebar } from '#theme/local/site';

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

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

const groupsFor = path => {
const segment = path.split('/').filter(Boolean)[0];
const matched = sidebar.filter(g => g.groupName.toLowerCase() === segment);
return matched.length > 0 ? matched : sidebar;
};

/**
* Sidebar component for MDX documentation with page navigation.
*/
export default ({ metadata }) => (
<SideBar
pathname={pathnameFor(metadata.path)}
groups={sidebar}
onSelect={redirect}
as={PrefetchLink}
title="Navigation"
/>
);
export default ({ metadata }) => {
const path = pathnameFor(metadata.path);
return (
<SideBar
pathname={path}
groups={groupsFor(path)}
onSelect={redirect}
as={PrefetchLink}
title="Navigation"
/>
);
};
Loading