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

Function replaceLinkWithContext

apps/site/hooks/useSiteNavigation.ts:26–37  ·  view source on GitHub ↗
(
  link: string,
  context?: RichTranslationValues
)

Source from the content-addressed store, hash-verified

24// Provides Context replacement for variables within the Link. This is also something that is not going
25// to happen in the future with `nodejs/nodejs.dev` codebase
26const replaceLinkWithContext = (
27 link: string,
28 context?: RichTranslationValues
29) =>
30 Object.entries(context || {}).reduce(
31 (finalLink, [find, replace]) =>
32 finalLink.replace(
33 `{${find}}`,
34 typeof replace === 'string' ? replace : ''
35 ),
36 link
37 );
38
39const useSiteNavigation = () => {
40 const t = useTranslations();

Callers 1

mapNavigationEntriesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected