|
| 1 | +import { SEO } from "./seo" |
| 2 | +import { EXTERNAL_LINKS } from "./constants" |
| 3 | + |
| 4 | +/** |
| 5 | + * Type definitions for Schema.org structured data |
| 6 | + */ |
| 7 | +interface ImageObject { |
| 8 | + "@type": "ImageObject" |
| 9 | + url: string |
| 10 | + width: number |
| 11 | + height: number |
| 12 | +} |
| 13 | + |
| 14 | +interface Organization { |
| 15 | + "@type": "Organization" |
| 16 | + "@id": string |
| 17 | + name: string |
| 18 | + url: string |
| 19 | + logo: ImageObject |
| 20 | + alternateName: string[] |
| 21 | + sameAs: string[] |
| 22 | +} |
| 23 | + |
| 24 | +interface WebSite { |
| 25 | + "@type": "WebSite" |
| 26 | + "@id": string |
| 27 | + url: string |
| 28 | + name: string |
| 29 | + alternateName: string[] |
| 30 | + publisher: { "@id": string } |
| 31 | +} |
| 32 | + |
| 33 | +interface SoftwareApplication { |
| 34 | + "@type": "SoftwareApplication" |
| 35 | + "@id": string |
| 36 | + name: string |
| 37 | + applicationCategory: string |
| 38 | + operatingSystem: string |
| 39 | + url: string |
| 40 | + downloadUrl: string |
| 41 | + offers: { |
| 42 | + "@type": "Offer" |
| 43 | + price: string |
| 44 | + priceCurrency: string |
| 45 | + } |
| 46 | + isAccessibleForFree: boolean |
| 47 | + publisher: { "@id": string } |
| 48 | +} |
| 49 | + |
| 50 | +interface StructuredDataGraph { |
| 51 | + "@context": "https://schema.org" |
| 52 | + "@graph": [Organization, WebSite, SoftwareApplication] |
| 53 | +} |
| 54 | + |
| 55 | +/** |
| 56 | + * Generates the complete JSON-LD structured data for SEO |
| 57 | + * |
| 58 | + * This includes: |
| 59 | + * - Organization schema (brand identity, logo, social profiles) |
| 60 | + * - WebSite schema (site name for Google Search) |
| 61 | + * - SoftwareApplication schema (VS Code extension metadata) |
| 62 | + * |
| 63 | + * @returns Complete structured data object ready for JSON-LD injection |
| 64 | + */ |
| 65 | +export function getStructuredData(): StructuredDataGraph { |
| 66 | + // Organization ID - used to link all entities |
| 67 | + const orgId = `${SEO.url}#org` |
| 68 | + |
| 69 | + const organization: Organization = { |
| 70 | + "@type": "Organization", |
| 71 | + "@id": orgId, |
| 72 | + name: SEO.name, |
| 73 | + url: SEO.url, |
| 74 | + logo: { |
| 75 | + "@type": "ImageObject", |
| 76 | + url: `${SEO.url}/android-chrome-512x512.png`, |
| 77 | + width: 512, |
| 78 | + height: 512, |
| 79 | + }, |
| 80 | + alternateName: ["RooCode"], |
| 81 | + sameAs: [ |
| 82 | + EXTERNAL_LINKS.GITHUB, |
| 83 | + EXTERNAL_LINKS.MARKETPLACE, |
| 84 | + EXTERNAL_LINKS.X, |
| 85 | + EXTERNAL_LINKS.LINKEDIN, |
| 86 | + EXTERNAL_LINKS.REDDIT, |
| 87 | + EXTERNAL_LINKS.DISCORD, |
| 88 | + EXTERNAL_LINKS.YOUTUBE, |
| 89 | + ], |
| 90 | + } |
| 91 | + |
| 92 | + const website: WebSite = { |
| 93 | + "@type": "WebSite", |
| 94 | + "@id": `${SEO.url}#website`, |
| 95 | + url: SEO.url, |
| 96 | + name: SEO.name, |
| 97 | + alternateName: ["RooCode"], |
| 98 | + publisher: { "@id": orgId }, |
| 99 | + } |
| 100 | + |
| 101 | + const softwareApplication: SoftwareApplication = { |
| 102 | + "@type": "SoftwareApplication", |
| 103 | + "@id": `${SEO.url}#vscode-extension`, |
| 104 | + name: "Roo Code (VS Code extension)", |
| 105 | + applicationCategory: "DeveloperApplication", |
| 106 | + operatingSystem: "Windows, macOS, Linux", |
| 107 | + url: SEO.url, |
| 108 | + downloadUrl: EXTERNAL_LINKS.MARKETPLACE, |
| 109 | + offers: { |
| 110 | + "@type": "Offer", |
| 111 | + price: "0", |
| 112 | + priceCurrency: "USD", |
| 113 | + }, |
| 114 | + isAccessibleForFree: true, |
| 115 | + publisher: { "@id": orgId }, |
| 116 | + } |
| 117 | + |
| 118 | + return { |
| 119 | + "@context": "https://schema.org", |
| 120 | + "@graph": [organization, website, softwareApplication], |
| 121 | + } |
| 122 | +} |
| 123 | + |
| 124 | +/** |
| 125 | + * Type export for use in components |
| 126 | + */ |
| 127 | +export type { StructuredDataGraph } |
0 commit comments