MCPcopy Create free account
hub / github.com/nodejs/nodejs.org / mapNavigationEntries

Function mapNavigationEntries

apps/site/hooks/useSiteNavigation.ts:42–60  ·  view source on GitHub ↗
(entries: Navigation, context: Context = {})

Source from the content-addressed store, hash-verified

40 const t = useTranslations();
41
42 const mapNavigationEntries = (entries: Navigation, context: Context = {}) => {
43 const getFormattedMessage = (label: IntlMessageKeys, key: string) =>
44 t.rich(label, context[key] || {}) as FormattedMessage;
45
46 return Object.entries(entries).map(
47 ([key, { label, link, items, target }]): [
48 string,
49 MappedNavigationEntry,
50 ] => [
51 key,
52 {
53 target,
54 label: label ? getFormattedMessage(label, key) : '',
55 link: link ? replaceLinkWithContext(link, context[key]) : '',
56 items: items ? mapNavigationEntries(items, context) : [],
57 },
58 ]
59 );
60 };
61
62 const getSideNavigation = (
63 keys: Array<NavigationKeys>,

Callers 2

getSideNavigationFunction · 0.85
useSiteNavigationFunction · 0.85

Calls 2

getFormattedMessageFunction · 0.85
replaceLinkWithContextFunction · 0.85

Tested by

no test coverage detected