-
Notifications
You must be signed in to change notification settings - Fork 324
Expand file tree
/
Copy pathSdkGuideLinks.js
More file actions
63 lines (59 loc) · 2.29 KB
/
Copy pathSdkGuideLinks.js
File metadata and controls
63 lines (59 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import React from 'react';
import Link from '@docusaurus/Link';
import SdkSvg from '../../SdkSvgs/SdkSvg';
import styles from './sdk-guide-links.module.css';
const DEFAULT_SDKS = [
{ name: 'goLangBlock', sdk: 'go', label: 'Go' },
{ name: 'javaBlock', sdk: 'java', label: 'Java' },
{ name: 'phpBlock', sdk: 'php', label: 'PHP' },
{ name: 'pythonBlock', sdk: 'python', label: 'Python' },
{ name: 'rubyBlock', sdk: 'ruby', label: 'Ruby' },
{ name: 'rustBlock', sdk: 'rust', label: 'Rust' },
{ name: 'typeScriptBlock', sdk: 'typescript', label: 'TypeScript' },
{ name: 'dotnetBlock', sdk: 'dotnet', label: '.NET' },
];
/**
* Renders a vertical list of SDK guide links with block icons.
*
* Standard usage — auto-generates links for all SDKs from a shared path:
* <SdkGuideLinks path="client/temporal-client" />
* → /develop/go/client/temporal-client, /develop/java/client/temporal-client, …
*
* Filter to specific SDKs (ignored when `links` is provided):
* <SdkGuideLinks path="client/temporal-client" filter={['go', 'java', 'python']} />
*
* Custom usage — pass explicit links for pages that don't follow the standard pattern.
* Note: `path` and `filter` are ignored when `links` is provided:
* <SdkGuideLinks links={[{ name: 'goLangBlock', href: '/some/path', label: 'Go' }]} />
*/
export const SdkGuideLinks = ({ path, links, filter, title }) => {
if (!links && !path) {
if (process.env.NODE_ENV !== 'production') {
console.warn('[SdkGuideLinks] Either `path` or `links` prop is required.');
}
return null;
}
const items = links
? links
: DEFAULT_SDKS
.filter(({ sdk }) => !filter || filter.includes(sdk))
.map(({ name, sdk, label }) => ({
name,
href: `/develop/${sdk}/${path}`,
label: title ? `${title} - ${label}` : label,
}));
return (
<div className={styles.list}>
{items.map(({ name, href, label }) => (
<Link key={name} to={href} className={styles.link}>
<span className={styles.iconWrapper}>
<span className={styles.iconInner}>
<SdkSvg name={name} />
</span>
</span>
<span>{label}</span>
</Link>
))}
</div>
);
};