Skip to content

Commit 646187c

Browse files
m-hulbertclaude
andcommitted
refactor(nav): extract hasProductBar to layout context and simplify hooks
Extract the duplicated product bar visibility check into activePage.hasProductBar, computed once in the layout context. Simplify useShowLanguageSelector double negation to the equivalent some(). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 34577ee commit 646187c

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

src/components/Layout/utils/nav.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export type ActivePage = {
2020
clientLanguages?: LanguageKey[];
2121
agentLanguages?: LanguageKey[];
2222
isDualLanguage?: boolean;
23+
hasProductBar: boolean;
2324
};
2425

2526
/**

src/contexts/layout-context.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const LayoutContext = createContext<{
4040
clientLanguages: [],
4141
agentLanguages: [],
4242
isDualLanguage: false,
43+
hasProductBar: false,
4344
},
4445
});
4546

@@ -117,18 +118,21 @@ export const LayoutProvider: React.FC<PropsWithChildren<{ pageContext: PageConte
117118
const clientLanguage = isDualLanguage ? determineClientLanguage(location.search, clientLanguages) : undefined;
118119
const agentLanguage = isDualLanguage ? determineAgentLanguage(location.search, agentLanguages) : undefined;
119120

121+
const product = activePageData?.product ?? null;
122+
120123
return {
121124
tree: activePageData?.tree ?? [],
122125
page: activePageData?.page ?? { name: '', link: '' },
123126
languages,
124127
language: languages.includes(language) ? language : null,
125-
product: activePageData?.product ?? null,
128+
product,
126129
template: 'mdx' as PageTemplate,
127130
clientLanguage,
128131
agentLanguage,
129132
clientLanguages,
130133
agentLanguages,
131134
isDualLanguage,
135+
hasProductBar: product !== null && product !== 'platform',
132136
};
133137
}, [location.pathname, location.search, pageContext?.languages]);
134138

0 commit comments

Comments
 (0)