|
1 | 1 | import { notFound } from 'next/navigation' |
2 | 2 | import { getTranslations } from 'next-intl/server' |
| 3 | +import { BackToNavigation } from '@/components/navigation/BackToNavigation' |
| 4 | +import { Breadcrumb } from '@/components/navigation/Breadcrumb' |
| 5 | +import { ProductCommands } from '@/components/product/ProductCommands' |
| 6 | +import { ProductHero } from '@/components/product/ProductHero' |
| 7 | +import { ProductLinks } from '@/components/product/ProductLinks' |
| 8 | +import { ProductPricing } from '@/components/product/ProductPricing' |
| 9 | +import { RelatedProducts } from '@/components/product/RelatedProducts' |
3 | 10 | import type { Locale } from '@/i18n/config' |
4 | | -import { getExtension } from '@/lib/data/fetchers' |
| 11 | +import { PageLayout } from '@/layouts/PageLayout' |
| 12 | +import { getExtension, getRelatedProducts } from '@/lib/data/fetchers' |
5 | 13 | import { extensionsData as extensions } from '@/lib/generated' |
| 14 | +import { getGithubStars } from '@/lib/generated/github-stars' |
6 | 15 | import { translateLicenseText } from '@/lib/license' |
7 | 16 | import { generateSoftwareDetailMetadata } from '@/lib/metadata' |
8 | | -import { ProductDetailTemplate } from '@/templates' |
| 17 | +import { generateSoftwareDetailSchema } from '@/lib/metadata/schemas' |
| 18 | +import { transformCommunityUrls, transformResourceUrls } from '@/lib/product-utils' |
9 | 19 |
|
10 | 20 | export const revalidate = 3600 |
11 | 21 |
|
@@ -66,30 +76,95 @@ export default async function ExtensionPage({ |
66 | 76 | const t = await getTranslations({ locale, namespace: 'pages.extensionDetail' }) |
67 | 77 | const tGlobal = await getTranslations({ locale }) |
68 | 78 |
|
| 79 | + // Transform URLs |
| 80 | + const websiteUrl = extension.websiteUrl || extension.resourceUrls?.download || undefined |
| 81 | + const docsUrl = extension.docsUrl || undefined |
| 82 | + const downloadUrl = extension.resourceUrls?.download || undefined |
| 83 | + |
| 84 | + const resourceUrls = transformResourceUrls(extension.resourceUrls) |
| 85 | + const communityUrls = transformCommunityUrls(extension.communityUrls) |
| 86 | + |
| 87 | + // Generate JSON-LD schema |
| 88 | + const schema = await generateSoftwareDetailSchema({ |
| 89 | + product: { |
| 90 | + name: extension.name, |
| 91 | + description: extension.description, |
| 92 | + vendor: extension.vendor, |
| 93 | + websiteUrl, |
| 94 | + downloadUrl, |
| 95 | + version: extension.latestVersion, |
| 96 | + platforms: extension.supportedIdes?.map(ide => ({ os: ide.ideId })), |
| 97 | + pricing: extension.pricing, |
| 98 | + license: extension.license ? translateLicenseText(extension.license, tGlobal) : undefined, |
| 99 | + }, |
| 100 | + category: 'extensions', |
| 101 | + locale: locale as Locale, |
| 102 | + applicationSubCategory: 'AI Assistant', |
| 103 | + compatibleWith: extension.supportedIdes?.map(ide => ide.ideId).join(', ') || undefined, |
| 104 | + }) |
| 105 | + |
| 106 | + // Fetch related products |
| 107 | + const relatedProducts = await getRelatedProducts( |
| 108 | + extension.relatedProducts || [], |
| 109 | + locale as Locale |
| 110 | + ) |
| 111 | + |
| 112 | + // Build additional info for ProductHero (supported IDEs) |
| 113 | + const additionalInfo = |
| 114 | + extension.supportedIdes && extension.supportedIdes.length > 0 |
| 115 | + ? [ |
| 116 | + { |
| 117 | + label: t('supportedIdes') || 'Supported IDEs', |
| 118 | + value: extension.supportedIdes.map(ide => ide.ideId).join(', '), |
| 119 | + }, |
| 120 | + ] |
| 121 | + : undefined |
| 122 | + |
| 123 | + // Breadcrumb items |
| 124 | + const breadcrumbItems = [ |
| 125 | + { name: tGlobal('shared.common.aiCodingStack'), href: '/ai-coding-stack' }, |
| 126 | + { name: tGlobal('shared.stacks.extensions'), href: '/extensions' }, |
| 127 | + { name: extension.name, href: `extensions/${extension.id}` }, |
| 128 | + ] |
| 129 | + |
69 | 130 | return ( |
70 | | - <ProductDetailTemplate |
71 | | - product={extension} |
72 | | - productType="extension" |
73 | | - locale={locale as Locale} |
74 | | - category="extensions" |
75 | | - translations={{ |
76 | | - categoryLabel: t('categoryLabel'), |
77 | | - allProductsLabel: t('allExtensions'), |
78 | | - breadcrumbs: { |
79 | | - home: tGlobal('shared.common.aiCodingStack'), |
80 | | - category: tGlobal('shared.stacks.extensions'), |
81 | | - }, |
82 | | - productHero: { |
| 131 | + <PageLayout schema={schema}> |
| 132 | + <Breadcrumb items={breadcrumbItems} /> |
| 133 | + |
| 134 | + <ProductHero |
| 135 | + name={extension.name} |
| 136 | + description={extension.description} |
| 137 | + vendor={extension.vendor} |
| 138 | + category="IDE" |
| 139 | + categoryLabel={t('categoryLabel')} |
| 140 | + verified={extension.verified ?? false} |
| 141 | + latestVersion={extension.latestVersion} |
| 142 | + license={extension.license} |
| 143 | + githubStars={getGithubStars('extensions', extension.id)} |
| 144 | + additionalInfo={additionalInfo} |
| 145 | + websiteUrl={websiteUrl} |
| 146 | + docsUrl={docsUrl} |
| 147 | + downloadUrl={downloadUrl} |
| 148 | + labels={{ |
83 | 149 | vendor: t('vendor'), |
84 | 150 | version: t('version'), |
85 | 151 | license: t('license'), |
86 | 152 | stars: t('stars'), |
87 | | - supportedIdes: t('supportedIdes'), |
88 | 153 | visitWebsite: t('visitWebsite'), |
89 | 154 | documentation: t('documentation'), |
90 | 155 | download: t('download'), |
91 | | - }, |
92 | | - }} |
93 | | - /> |
| 156 | + }} |
| 157 | + /> |
| 158 | + |
| 159 | + {relatedProducts.length > 0 && <RelatedProducts products={relatedProducts} />} |
| 160 | + |
| 161 | + <ProductPricing pricing={extension.pricing} pricingUrl={resourceUrls.pricing} /> |
| 162 | + |
| 163 | + <ProductLinks resourceUrls={resourceUrls} communityUrls={communityUrls} /> |
| 164 | + |
| 165 | + <ProductCommands install={extension.installCommand} launch={extension.launchCommand} /> |
| 166 | + |
| 167 | + <BackToNavigation href="/extensions" title={t('allExtensions')} /> |
| 168 | + </PageLayout> |
94 | 169 | ) |
95 | 170 | } |
0 commit comments