mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 15:39:13 +00:00
## Problem faqs on /partners, /compute, and /pricing use JS, making them invisible to search / LLM crawlers. ## Solution Moves them to detail > summary elements in a shared component. ## Preview links - [/partners](https://zone-www-dot-lh2wp7c6i-supabase.vercel.app/partners) - [/compute](https://zone-www-dot-lh2wp7c6i-supabase.vercel.app/compute) - [/pricing](https://zone-www-dot-lh2wp7c6i-supabase.vercel.app/pricing) ## JSON-LD validation - [/partners](https://validator.schema.org/#url=https%3A%2F%2Fzone-www-dot-lh2wp7c6i-supabase.vercel.app%2Fpartners) - [/compute](https://validator.schema.org/#url=https%3A%2F%2Fzone-www-dot-lh2wp7c6i-supabase.vercel.app%2Fcompute) - [/pricing](https://validator.schema.org/#url=https%3A%2F%2Fzone-www-dot-lh2wp7c6i-supabase.vercel.app%2Fpricing)
278 lines
6.8 KiB
TypeScript
278 lines
6.8 KiB
TypeScript
import { DEFAULT_META_DESCRIPTION, SITE_NAME } from './constants'
|
|
|
|
const CANONICAL_ORIGIN = 'https://supabase.com'
|
|
const ORG_ID = `${CANONICAL_ORIGIN}/#organization`
|
|
const SITE_ID = `${CANONICAL_ORIGIN}/#website`
|
|
|
|
const ORG_SAMEAS = [
|
|
'https://github.com/supabase',
|
|
'https://twitter.com/supabase',
|
|
'https://www.linkedin.com/company/supabase',
|
|
'https://youtube.com/c/supabase',
|
|
'https://discord.supabase.com/',
|
|
'https://www.tiktok.com/@supabase.com',
|
|
'https://www.instagram.com/supabasecom',
|
|
]
|
|
|
|
const ORG_LOGO_URL = `${CANONICAL_ORIGIN}/brand-assets/supabase-logo-green-black-transparent.png`
|
|
|
|
type JsonLdSchema = Record<string, unknown> | Record<string, unknown>[]
|
|
|
|
export function serializeJsonLd(schema: JsonLdSchema): string {
|
|
return JSON.stringify(schema)
|
|
.replace(/</g, '\\u003c')
|
|
.replace(/>/g, '\\u003e')
|
|
.replace(/&/g, '\\u0026')
|
|
}
|
|
|
|
interface OrganizationSchemaInput {
|
|
description?: string
|
|
}
|
|
|
|
export function organizationSchema(input: OrganizationSchemaInput = {}) {
|
|
return {
|
|
'@context': 'https://schema.org',
|
|
'@type': 'Organization',
|
|
'@id': ORG_ID,
|
|
name: SITE_NAME,
|
|
url: CANONICAL_ORIGIN,
|
|
logo: {
|
|
'@type': 'ImageObject',
|
|
url: ORG_LOGO_URL,
|
|
},
|
|
description: input.description ?? DEFAULT_META_DESCRIPTION,
|
|
legalName: 'Supabase Pte. Ltd.',
|
|
contactPoint: {
|
|
'@type': 'ContactPoint',
|
|
contactType: 'customer support',
|
|
url: `${CANONICAL_ORIGIN}/support`,
|
|
},
|
|
address: {
|
|
'@type': 'PostalAddress',
|
|
streetAddress: '65 Chulia Street #38-02/03, OCBC Centre',
|
|
addressLocality: 'Singapore',
|
|
postalCode: '049513',
|
|
addressCountry: 'SG',
|
|
},
|
|
sameAs: ORG_SAMEAS,
|
|
}
|
|
}
|
|
|
|
interface WebSiteSchemaInput {
|
|
description?: string
|
|
}
|
|
|
|
export function websiteSchema(input: WebSiteSchemaInput = {}) {
|
|
return {
|
|
'@context': 'https://schema.org',
|
|
'@type': 'WebSite',
|
|
'@id': SITE_ID,
|
|
url: CANONICAL_ORIGIN,
|
|
name: SITE_NAME,
|
|
description: input.description ?? DEFAULT_META_DESCRIPTION,
|
|
publisher: { '@id': ORG_ID },
|
|
}
|
|
}
|
|
|
|
interface SoftwareApplicationSchemaInput {
|
|
name: string
|
|
description: string
|
|
url: string
|
|
image: string
|
|
applicationCategory?: string
|
|
}
|
|
|
|
export function softwareApplicationSchema(input: SoftwareApplicationSchemaInput) {
|
|
return {
|
|
'@context': 'https://schema.org',
|
|
'@type': 'SoftwareApplication',
|
|
name: input.name,
|
|
description: input.description,
|
|
url: input.url,
|
|
image: input.image,
|
|
applicationCategory: input.applicationCategory ?? 'DeveloperApplication',
|
|
operatingSystem: 'Cross-platform',
|
|
publisher: { '@id': ORG_ID },
|
|
}
|
|
}
|
|
|
|
interface ServiceSchemaInput {
|
|
name: string
|
|
description: string
|
|
url: string
|
|
serviceType: string
|
|
offerings: Array<{ name: string; url: string }>
|
|
}
|
|
|
|
export function serviceSchema(input: ServiceSchemaInput) {
|
|
return {
|
|
'@context': 'https://schema.org',
|
|
'@type': 'Service',
|
|
name: input.name,
|
|
description: input.description,
|
|
url: input.url,
|
|
serviceType: input.serviceType,
|
|
provider: { '@id': ORG_ID },
|
|
hasOfferCatalog: {
|
|
'@type': 'OfferCatalog',
|
|
name: `${input.name} products`,
|
|
itemListElement: input.offerings.map((offering) => ({
|
|
'@type': 'Offer',
|
|
itemOffered: {
|
|
'@type': 'Service',
|
|
name: offering.name,
|
|
url: offering.url,
|
|
},
|
|
})),
|
|
},
|
|
}
|
|
}
|
|
|
|
export interface BreadcrumbItem {
|
|
name: string
|
|
url: string
|
|
}
|
|
|
|
export function breadcrumbListSchema(items: BreadcrumbItem[]) {
|
|
return {
|
|
'@context': 'https://schema.org',
|
|
'@type': 'BreadcrumbList',
|
|
itemListElement: items.map((item, index) => ({
|
|
'@type': 'ListItem',
|
|
position: index + 1,
|
|
name: item.name,
|
|
item: item.url,
|
|
})),
|
|
}
|
|
}
|
|
|
|
const MARKDOWN_LINK = /\[([^\]]+)\]\(([^)\s"]+)\)/g
|
|
|
|
/**
|
|
* Converts markdown links to `<a>` tags (relative URLs become absolute), since
|
|
* schema.org answer text is plain text with a small HTML subset, not markdown.
|
|
*/
|
|
export function markdownLinksToHtml(text: string): string {
|
|
return text.replace(MARKDOWN_LINK, (_, label: string, href: string) => {
|
|
const url = href.startsWith('/') ? `${CANONICAL_ORIGIN}${href}` : href
|
|
return `<a href="${url}">${label}</a>`
|
|
})
|
|
}
|
|
|
|
export function faqPageSchema(items: Array<{ question: string; answer: string }>) {
|
|
return {
|
|
'@context': 'https://schema.org',
|
|
'@type': 'FAQPage',
|
|
mainEntity: items.map((item) => ({
|
|
'@type': 'Question',
|
|
name: item.question,
|
|
acceptedAnswer: {
|
|
'@type': 'Answer',
|
|
text: markdownLinksToHtml(item.answer),
|
|
},
|
|
})),
|
|
}
|
|
}
|
|
|
|
interface BlogPostingSchemaInput {
|
|
url: string
|
|
headline: string
|
|
description?: string
|
|
image: string
|
|
datePublished: string
|
|
dateModified: string
|
|
authors: Array<{ name: string; url?: string }>
|
|
}
|
|
|
|
export function blogPostingSchema(input: BlogPostingSchemaInput) {
|
|
return {
|
|
'@context': 'https://schema.org',
|
|
'@type': 'BlogPosting',
|
|
mainEntityOfPage: {
|
|
'@type': 'WebPage',
|
|
'@id': input.url,
|
|
},
|
|
headline: input.headline,
|
|
description: input.description,
|
|
image: input.image,
|
|
datePublished: input.datePublished,
|
|
dateModified: input.dateModified,
|
|
author: input.authors.map((a) => ({
|
|
'@type': 'Person',
|
|
name: a.name,
|
|
...(a.url ? { url: a.url } : {}),
|
|
})),
|
|
publisher: {
|
|
'@type': 'Organization',
|
|
'@id': ORG_ID,
|
|
name: SITE_NAME,
|
|
logo: {
|
|
'@type': 'ImageObject',
|
|
url: ORG_LOGO_URL,
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
interface TechArticleSchemaInput {
|
|
url: string
|
|
headline: string
|
|
description?: string
|
|
datePublished: string
|
|
}
|
|
|
|
export function techArticleSchema(input: TechArticleSchemaInput) {
|
|
return {
|
|
'@context': 'https://schema.org',
|
|
'@type': 'TechArticle',
|
|
'@id': `${input.url}#page`,
|
|
mainEntityOfPage: {
|
|
'@type': 'WebPage',
|
|
'@id': input.url,
|
|
},
|
|
url: input.url,
|
|
headline: input.headline,
|
|
description: input.description,
|
|
inLanguage: 'en',
|
|
datePublished: input.datePublished,
|
|
publisher: {
|
|
'@type': 'Organization',
|
|
'@id': ORG_ID,
|
|
name: SITE_NAME,
|
|
logo: {
|
|
'@type': 'ImageObject',
|
|
url: ORG_LOGO_URL,
|
|
},
|
|
},
|
|
isPartOf: { '@id': SITE_ID },
|
|
}
|
|
}
|
|
|
|
interface CollectionPageSchemaInput {
|
|
url: string
|
|
name: string
|
|
description?: string
|
|
items: Array<{ url: string; name: string }>
|
|
}
|
|
|
|
export function collectionPageSchema(input: CollectionPageSchemaInput) {
|
|
return {
|
|
'@context': 'https://schema.org',
|
|
'@type': 'CollectionPage',
|
|
'@id': `${input.url}#page`,
|
|
url: input.url,
|
|
name: input.name,
|
|
description: input.description,
|
|
isPartOf: { '@id': SITE_ID },
|
|
mainEntity: {
|
|
'@type': 'ItemList',
|
|
itemListElement: input.items.map((item, index) => ({
|
|
'@type': 'ListItem',
|
|
position: index + 1,
|
|
url: item.url,
|
|
name: item.name,
|
|
})),
|
|
},
|
|
}
|
|
}
|