Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/thatdeveloperguy-website / src/engines/seo/structured-data/assemble-page-graph.ts |
| Date | Not specified in source |
| Repository | Janady13/thatdeveloperguy-website |
| Revision | 2bea2ebdff0e34494bff597d4fa9c8422a0c3a94 |
| Branch | main |
| Path or archive member | src/engines/seo/structured-data/assemble-page-graph.ts |
| Original SHA-256 | fdd7fe44f8d46ca11d40c2d76a63bdb9a2f781d285e489b0b043e726815caa1d |
| Git blob SHA | 6065b4dff1f45ac14aaef51a4420955fd1061a5c |
| Reading-copy SHA-256 | fdd7fe44f8d46ca11d40c2d76a63bdb9a2f781d285e489b0b043e726815caa1d |
Recovered source transcript
Download complete source text ↓34 lines · 3.0 KB
import type { CompiledPage } from '../../../contracts/page.ts';
import { truth, ORGANIZATION_ID, PERSON_ID } from '../../../authority/select-public-facts.ts';
import { PRODUCTION_ORIGIN } from '../urls/production-origin.ts';
const WEBSITE_ID = `${PRODUCTION_ORIGIN}/#website`;
/** The canonical host declares Organization and Person once (home); every other page references them by @id. */
export function assemblePageGraph(page: CompiledPage): Record<string, unknown> {
const graph: Array<Record<string, unknown>> = [];
if (page.id === 'home') {
graph.push({
'@type': 'Organization', '@id': ORGANIZATION_ID, name: truth.org.name, legalName: truth.org.legalName, url: `${PRODUCTION_ORIGIN}/`,
telephone: truth.org.telephone, email: truth.org.email, foundingDate: truth.org.foundingDate,
address: { '@type': 'PostalAddress', ...truth.org.address }, sameAs: truth.org.sameAs, founder: { '@id': PERSON_ID },
});
graph.push({ '@type': 'Person', '@id': PERSON_ID, name: truth.person.name, jobTitle: truth.person.jobTitle, url: truth.person.url, worksFor: { '@id': ORGANIZATION_ID } });
graph.push({ '@type': 'WebSite', '@id': WEBSITE_ID, url: `${PRODUCTION_ORIGIN}/`, name: truth.org.name, publisher: { '@id': ORGANIZATION_ID } });
}
const webpage: Record<string, unknown> = { '@type': 'WebPage', '@id': `${page.canonical}#webpage`, url: page.canonical, name: page.title, description: page.description, isPartOf: { '@id': WEBSITE_ID }, about: { '@id': ORGANIZATION_ID }, publisher: { '@id': ORGANIZATION_ID }, inLanguage: 'en-US' };
if (page.publishedAt) webpage.datePublished = page.publishedAt;
if (page.materiallyUpdatedAt ?? page.publishedAt) webpage.dateModified = page.materiallyUpdatedAt ?? page.publishedAt;
if (page.breadcrumbs.length > 1) webpage.breadcrumb = { '@type': 'BreadcrumbList', itemListElement: page.breadcrumbs.map((crumb, i) => ({ '@type': 'ListItem', position: i + 1, name: crumb.name, item: crumb.path === '/' ? `${PRODUCTION_ORIGIN}/` : `${PRODUCTION_ORIGIN}${crumb.path}` })) };
graph.push(webpage);
if (page.template === 'capability' && page.serviceId) {
const service: Record<string, unknown> = { '@type': 'Service', '@id': `${page.canonical}#service`, name: page.heading, description: page.description, serviceType: page.heading, provider: { '@id': ORGANIZATION_ID }, url: page.canonical };
if (page.serviceDetail) service.audience = page.serviceDetail.audience.map(a => ({ '@type': 'Audience', audienceType: a }));
graph.push(service);
webpage.mainEntity = { '@id': service['@id'] };
}
// The visible Q&A, verbatim. Same record, same text; there is no crawler-only version.
if (page.questions.length) graph.push({ '@type': 'FAQPage', '@id': `${page.canonical}#questions`, isPartOf: { '@id': `${page.canonical}#webpage` }, mainEntity: page.questions.map(q => ({ '@type': 'Question', name: q.question, acceptedAnswer: { '@type': 'Answer', text: q.answer } })) });
return { '@context': 'https://schema.org', '@graph': graph };
}