@iandolan/astro-schema
v0.1.1
Published
Typed JSON-LD builders that emit one connected @graph instead of a pile of disconnected blocks.
Maintainers
Readme
@iandolan/astro-schema
JSON-LD builders that emit one connected @graph rather than a pile of standalone blocks. Replaces Schema Pro and the Rank Math schema module.
Every node gets a stable @id and references others by it, so the Organization in the Article block and the one in the LocalBusiness block are provably the same entity.
import { graph, organization, person, webPage, breadcrumbs, faq } from '@iandolan/astro-schema';
const schema = graph(
organization({ site, name: 'Dog Tail', type: 'ProfessionalService', founder: 'ian' }),
person({ site, slug: 'ian', name: 'Ian Dolan' }),
webPage({ site, path, name: 'Services', breadcrumb: true }),
breadcrumbs({ site, path, crumbs }),
faq({ site, path, questions })
);Builders return undefined when there is nothing to describe, so they can be passed in unconditionally. aggregateRating refuses to build from partial data, which is deliberate. Invented ratings are a policy violation and trivially detectable.
Only emit faq() where the questions and answers are visible on the page. Marking up content a reader cannot see is the most common way FAQ markup earns a manual action.
Part of the Dolan SEO Suite, WordPress SEO plugin functionality rebuilt for static Astro sites. Plain ESM, no build step, no dependencies.
MIT © Ian Dolan
