返回 CodeWhale
page.tsx
根目录 / web / app / [locale] / plugins / page.tsx
1 import Link from "next/link";
2 import { DesktopShot } from "@/components/desktop-shot";
3 import { Icon } from "@/components/icon";
4 import { PageHeader, Section } from "@/components/page-header";
5 import { buildPageMetadata } from "@/lib/page-meta";
6 import { PLUGINS_COPY, PLUGINS_COMING, pluginsComingApplies, PLUGIN_KINDS, FEATURED_CONNECTORS, CATALOG_FEATURED, PLUGIN_SOURCES, PLUGIN_COMMANDS, PLUGIN_COMPATIBILITY } from "@/lib/content/plugins";
7 import { CATALOG_PLUGINS, CONNECTORS, type ConnectorAuth } from "@/lib/content/connectors.generated";
8 import type { LocalizedText } from "@/lib/content/vocabulary";
9 import { getFacts } from "@/lib/facts";
10 import { pickText } from "@/lib/i18n/dictionaries";
11 import { FallbackRegion } from "@/components/fallback-region";
12
13 export const revalidate = 300;
14
15 const MARKETPLACE_REPO = "https://github.com/codewhale-hq/codewhale-plugin-marketplace";
16 const DSH_REPO = "https://github.com/deepseek-ai/deepseek-harness";
17 const DSH_COMPAT_DOC = "https://github.com/codewhale-hq/Codewhale/blob/main/docs/DSH_PLUGIN_COMPAT.md";
18
19 const AUTH_LABEL: Record<ConnectorAuth, LocalizedText> = {
20 oauth: PLUGINS_COPY.authOauth,
21 token: PLUGINS_COPY.authToken,
22 none: PLUGINS_COPY.authNone,
23 };
24
25 const featuredConnectors = FEATURED_CONNECTORS.flatMap((id) => CONNECTORS.find((connector) => connector.id === id) ?? []);
26 const connectorCommands = "codewhale mcp add notion --url https://mcp.notion.com/mcp\ncodewhale mcp login notion";
27 const pluginVersions = new Map(CATALOG_PLUGINS.map((plugin) => [plugin.name, plugin.version]));
28
29 export async function generateMetadata({ params }: { params: Promise<{ locale: string }> }) {
30 const { locale } = await params;
31 return buildPageMetadata({ path: "/plugins", locale,
32 title: pickText(PLUGINS_COPY.metaTitle, locale),
33 description: pickText(PLUGINS_COPY.metaDescription, locale) });
34 }
35
36 export default async function PluginsPage({ params }: { params: Promise<{ locale: string }> }) {
37 const { locale } = await params;
38 const t = (copy: LocalizedText) => pickText(copy, locale);
39 const showComing = pluginsComingApplies((await getFacts()).latestPublishedRelease);
40 const authoringDoc = `/${locale}/docs/plugin-authoring`;
41 const localHref = (href: string) => (href.startsWith("/") ? `/${locale}${href}` : href);
42 const moreConnectors = CONNECTORS.length - featuredConnectors.length;
43 const moreCatalog = CATALOG_PLUGINS.length - CATALOG_FEATURED.length;
44
45 return (
46 <FallbackRegion path="/plugins" locale={locale}>
47 <PageHeader
48 titleId="plugins-overview"
49 title={t(PLUGINS_COPY.title)}
50 lede={t(PLUGINS_COPY.lead)}
51 pose="connect"
52 actions={
53 <>
54 <Link href="#catalog-title" className="btn btn-primary btn-lg">{t(PLUGINS_COPY.marketplaceCta)}</Link>
55 <Link href={authoringDoc} className="btn btn-secondary btn-lg">{t(PLUGINS_COPY.docsCta)}</Link>
56 </>
57 }
58 />
59
60 <div className="page-body">
61 <Section id="kinds-title" title={t(PLUGINS_COPY.kindsTitle)}>
62 <ul className="plugin-kinds" role="list">
63 {PLUGIN_KINDS.map((kind) => (
64 <li key={kind.title.en}>
65 <h3>{t(kind.title)}</h3>
66 <p>{t(kind.detail)}</p>
67 </li>
68 ))}
69 </ul>
70 <div className="stack mt-4">
71 <p>
72 {t(PLUGINS_COPY.originBefore)}
73 <Link href={DSH_REPO} className="link">{t(PLUGINS_COPY.originName)}</Link>
74 {t(PLUGINS_COPY.originAfter)}
75 </p>
76 <p className="section-scope">{t(PLUGINS_COPY.dshStatus)}</p>
77 <Link href={DSH_COMPAT_DOC} className="section-link">
78 {t(PLUGINS_COPY.dshLink)}
79 <Icon name="external" className="icon" />
80 </Link>
81 </div>
82 </Section>
83
84 <Section id="plugins-desktop" title={t(PLUGINS_COPY.desktopTitle)} scope={t(PLUGINS_COPY.desktopLead)}>
85 <figure className="figure">
86 <div className="figure-frame">
87 <DesktopShot id="plugins" alt={t(PLUGINS_COPY.desktopAlt)} />
88 </div>
89 <figcaption className="figure-caption">{t(PLUGINS_COPY.desktopCaption)}</figcaption>
90 </figure>
91 </Section>
92
93 {showComing ? (
94 <Section id="coming-title" title={t(PLUGINS_COPY.comingTitle)} scope={t(PLUGINS_COPY.comingLead)}>
95 <ul className="plugin-kinds plugin-kinds-coming" role="list" data-release-scope="coming">
96 {PLUGINS_COMING.map((item) => (
97 <li key={item.title.en}>
98 <h3>{t(item.title)}</h3>
99 <p>{t(item.detail)}</p>
100 </li>
101 ))}
102 </ul>
103 </Section>
104 ) : null}
105
106 <Section id="connectors-title" title={t(PLUGINS_COPY.connectorsTitle)} scope={t(PLUGINS_COPY.connectorsLead)}>
107 <ul className="connector-grid" role="list">
108 {featuredConnectors.map((connector) => (
109 <li key={connector.id}>
110 <span className="connector-name">{connector.name}</span>
111 <span className={`connector-auth connector-auth-${connector.auth}`}>{t(AUTH_LABEL[connector.auth])}</span>
112 </li>
113 ))}
114 <li className="connector-more">
115 <Link href={`${MARKETPLACE_REPO}/blob/main/connections/catalog.json`} className="link">
116 {`+${moreConnectors} ${t(PLUGINS_COPY.connectorsMore)}`}
117 </Link>
118 </li>
119 </ul>
120 <pre tabIndex={0} className="code-block mt-4">{connectorCommands}</pre>
121 <div className="stack mt-4">
122 <p className="section-scope">{t(PLUGINS_COPY.connectorsNote)}</p>
123 <p className="section-scope">{t(PLUGINS_COPY.connectorsGoogle)}</p>
124 <Link href={`/${locale}/docs/mcp`} className="section-link">
125 {t(PLUGINS_COPY.connectorsLink)}
126 <Icon name="arrow-right" className="icon icon-flip" />
127 </Link>
128 </div>
129 </Section>
130
131 <Section id="catalog-title" title={t(PLUGINS_COPY.catalogTitle)} scope={t(PLUGINS_COPY.catalogLead)}>
132 <ul className="dir-list dir-list-card" role="list">
133 {CATALOG_FEATURED.map((entry) => {
134 const version = pluginVersions.get(entry.name);
135 const flagship = entry.name === "computer-use";
136 const href = flagship ? `/${locale}/computer-use` : `${MARKETPLACE_REPO}/tree/main/plugins/${entry.name}`;
137 return (
138 <li key={entry.name}>
139 <Link href={href} className="dir-row">
140 <span className="dir-mark" aria-hidden="true"><Icon name="plug" /></span>
141 <span className="dir-text">
142 <span className="dir-title">
143 {entry.title}
144 {version ? <span className="plugin-version">{` v${version}`}</span> : null}
145 {entry.status ? <span className="plugin-version">{` · ${t(entry.status)}`}</span> : null}
146 </span>
147 <span className="dir-purpose">{t(entry.detail)}</span>
148 {flagship ? null : <span className="dir-meta">{`/plugin marketplace install codewhale ${entry.name}`}</span>}
149 </span>
150 <span className="dir-action" aria-hidden="true"><Icon name={flagship ? "arrow-right" : "external"} className={flagship ? "icon-flip" : undefined} /></span>
151 </Link>
152 </li>
153 );
154 })}
155 </ul>
156 <Link href={MARKETPLACE_REPO} className="section-link mt-4">
157 {`${t(PLUGINS_COPY.catalogSeeAll)} (+${moreCatalog})`}
158 <Icon name="external" className="icon" />
159 </Link>
160 </Section>
161
162 <Section id="safe-title" title={t(PLUGINS_COPY.safeTitle)} scope={t(PLUGINS_COPY.safeLead)}>
163 <ol className="plugin-flow">
164 {PLUGINS_COPY.safeSteps.map((step, index) => (
165 <li key={step.command}>
166 <span className="plugin-flow-title"><span className="gs-step-index" aria-hidden="true">{index + 1}</span>{t(step.title)}</span>
167 <code className="plugin-flow-command">{step.command}</code>
168 <span>{t(step.detail)}</span>
169 </li>
170 ))}
171 </ol>
172 <p className="section-scope mt-4">{t(PLUGINS_COPY.safeHashes)}</p>
173 <p className="section-scope mt-4">{t(PLUGINS_COPY.sourcesLead)}</p>
174 <pre tabIndex={0} className="code-block mt-2">{PLUGIN_SOURCES}</pre>
175 </Section>
176
177 <section className="page-section" aria-labelledby="reference-title">
178 <details className="group-card disclosure-row">
179 <summary>
180 <span id="reference-title">{t(PLUGINS_COPY.referenceTitle)}</span>
181 <Icon name="chevron-down" className="disclosure-chevron" />
182 </summary>
183 <div className="disclosure-body stack">
184 <h3 className="section-title">{t(PLUGINS_COPY.referenceCommands)}</h3>
185 <pre tabIndex={0} className="code-block">{PLUGIN_COMMANDS.join("\n")}</pre>
186 <h3 className="section-title">{t(PLUGINS_COPY.referenceFormats)}</h3>
187 <dl className="def-rows">
188 {PLUGIN_COMPATIBILITY.map((format) => (
189 <div key={format.href} className="def-row">
190 <dt><Link className="link" href={localHref(format.href)}>{t(format.title)}</Link></dt>
191 <dd>{t(format.detail)}</dd>
192 </div>
193 ))}
194 </dl>
195 </div>
196 </details>
197 </section>
198
199 <Section id="contribute-title" title={t(PLUGINS_COPY.contributeTitle)} scope={t(PLUGINS_COPY.contributeLead)}>
200 <div className="actions">
201 <Link href={authoringDoc} className="btn btn-secondary">{t(PLUGINS_COPY.docsCta)}</Link>
202 <Link href={`${MARKETPLACE_REPO}/issues`} className="section-link">{t(PLUGINS_COPY.contributeLink)}<Icon name="external" className="icon" /></Link>
203 </div>
204 </Section>
205 </div>
206 </FallbackRegion>
207 );
208 }
209
209 lines Plain Text