Skip to content

Commit 13370a9

Browse files
committed
fixup! Add fe_lang, be_lang, and fe_or_be_lang props to If component
1 parent af93d2a commit 13370a9

3 files changed

Lines changed: 15 additions & 17 deletions

File tree

src/components/Layout/mdx/If.tsx

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,30 @@ interface IfProps {
77
lang?: LanguageKey;
88
clientLang?: LanguageKey;
99
agentLang?: LanguageKey;
10-
clientOrAgentLang?: LanguageKey;
1110
loggedIn?: boolean;
1211
className?: string;
1312
children: React.ReactNode;
1413
as?: React.ElementType;
1514
}
1615

17-
const If: React.FC<IfProps> = ({ lang, clientLang, agentLang, clientOrAgentLang, loggedIn, children }) => {
16+
const If: React.FC<IfProps> = ({ lang, clientLang, agentLang, loggedIn, children }) => {
1817
const { activePage } = useLayoutContext();
19-
const { language, clientLanguage, agentLanguage } = activePage;
18+
const { language, isDualLanguage, clientLanguage, agentLanguage } = activePage;
2019
const userContext = useContext(UserContext);
2120

2221
let shouldShow = true;
2322

2423
// Check language condition if lang prop is provided
25-
if (lang !== undefined && language) {
24+
if (lang !== undefined) {
2625
const splitLang = lang.split(',');
27-
shouldShow = shouldShow && splitLang.includes(language);
26+
if (isDualLanguage) {
27+
// On dual-language pages, check if either client or agent matches
28+
const clientMatches = clientLanguage && splitLang.includes(clientLanguage);
29+
const agentMatches = agentLanguage && splitLang.includes(agentLanguage);
30+
shouldShow = shouldShow && !!(clientMatches || agentMatches);
31+
} else if (language) {
32+
shouldShow = shouldShow && splitLang.includes(language);
33+
}
2834
}
2935

3036
// Check client language condition if clientLang prop is provided
@@ -39,14 +45,6 @@ const If: React.FC<IfProps> = ({ lang, clientLang, agentLang, clientOrAgentLang,
3945
shouldShow = shouldShow && splitLang.includes(agentLanguage);
4046
}
4147

42-
// Check if either client or agent matches (OR logic) - useful for shared requirements
43-
if (clientOrAgentLang !== undefined) {
44-
const splitLang = clientOrAgentLang.split(',');
45-
const clientMatches = clientLanguage && splitLang.includes(clientLanguage);
46-
const agentMatches = agentLanguage && splitLang.includes(agentLanguage);
47-
shouldShow = shouldShow && (clientMatches || agentMatches);
48-
}
49-
5048
// Check logged in condition if loggedIn prop is provided
5149
if (loggedIn !== undefined && userContext.sessionState !== undefined) {
5250
const isSignedIn = userContext.sessionState.signedIn ?? false;

src/pages/docs/guides/ai-transport/anthropic/anthropic-message-per-response.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ You also need:
3939

4040
Useful links:
4141
- [Anthropic API documentation](https://docs.anthropic.com/en/api)
42-
<If clientOrAgentLang="javascript">
42+
<If lang="javascript">
4343
- [Ably JavaScript SDK getting started](/docs/getting-started/javascript)
4444
</If>
4545
<If clientLang="swift">
@@ -48,7 +48,7 @@ Useful links:
4848
<If agentLang="python">
4949
- [Ably Python SDK getting started](/docs/getting-started/python)
5050
</If>
51-
<If clientOrAgentLang="java">
51+
<If lang="java">
5252
- [Ably Java SDK getting started](/docs/getting-started/java)
5353
</If>
5454

src/pages/docs/guides/ai-transport/anthropic/anthropic-message-per-token.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ You also need:
3939

4040
Useful links:
4141
- [Anthropic API documentation](https://docs.anthropic.com/en/api)
42-
<If clientOrAgentLang="javascript">
42+
<If lang="javascript">
4343
- [Ably JavaScript SDK getting started](/docs/getting-started/javascript)
4444
</If>
4545
<If clientLang="swift">
@@ -48,7 +48,7 @@ Useful links:
4848
<If agentLang="python">
4949
- [Ably Python SDK getting started](/docs/getting-started/python)
5050
</If>
51-
<If clientOrAgentLang="java">
51+
<If lang="java">
5252
- [Ably Java SDK getting started](/docs/getting-started/java)
5353
</If>
5454

0 commit comments

Comments
 (0)