| 1 | import type { PublishedReleaseFact } from "./facts"; |
| 2 | import { releasedFeatureNames } from "./capabilities"; |
| 3 | import { REPO_URL } from "./i18n/links"; |
| 4 | import { desktopDownload } from "./desktop-release"; |
| 5 | import { getHome } from "./i18n/dictionaries"; |
| 6 | import { SITE_NAME, SITE_URL } from "./page-meta"; |
| 7 | import { ORGANIZATION_ID } from "./site-schema"; |
| 8 | |
| 9 | /** |
| 10 | * Structured product data for the release-backed install page. |
| 11 | * |
| 12 | * Source candidates deliberately do not enter this function: the download URL |
| 13 | * resolves published artifacts, so softwareVersion must describe that release |
| 14 | * or be absent when no published release receipt is available. |
| 15 | */ |
| 16 | export function buildSoftwareApplicationJsonLd( |
| 17 | publishedRelease: (Pick<PublishedReleaseFact, "version"> & Partial<Pick<PublishedReleaseFact, "publishedAt" | "url">>) | null, |
| 18 | locale = "en", |
| 19 | ) { |
| 20 | const installUrl = `${SITE_URL}/${locale}/install`; |
| 21 | return { |
| 22 | "@context": "https://schema.org", |
| 23 | "@type": "SoftwareApplication", |
| 24 | "@id": `${SITE_URL}/#software`, |
| 25 | name: SITE_NAME, |
| 26 | url: SITE_URL, |
| 27 | description: getHome(locale).metaDescription, |
| 28 | applicationCategory: "DeveloperApplication", |
| 29 | operatingSystem: "macOS, Linux, Windows", |
| 30 | ...(publishedRelease?.version ? { softwareVersion: publishedRelease.version } : {}), |
| 31 | ...(publishedRelease?.version ? { featureList: releasedFeatureNames(publishedRelease.version) } : {}), |
| 32 | ...(publishedRelease?.version && publishedRelease.url ? { releaseNotes: publishedRelease.url } : {}), |
| 33 | ...(publishedRelease?.version && publishedRelease.publishedAt ? { dateModified: publishedRelease.publishedAt } : {}), |
| 34 | installUrl, |
| 35 | sameAs: [REPO_URL, "https://www.npmjs.com/package/codewhale", "https://crates.io/crates/codewhale-cli"], |
| 36 | license: `${REPO_URL}/blob/main/LICENSE`, |
| 37 | codeRepository: REPO_URL, |
| 38 | downloadUrl: desktopDownload()?.url ?? installUrl, |
| 39 | author: { "@id": ORGANIZATION_ID }, |
| 40 | }; |
| 41 | } |
| 42 |