npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@casoon/astro-structured-data

v2.10.0

Published

An Astro integration to automatically generate structured data (JSON-LD) for articles, FAQs, products, recipes, videos, breadcrumbs, local businesses, events, and more.

Readme

@casoon/astro-structured-data

Structured data for Astro, from the content you already have.

Search engines read schema.org JSON-LD to understand a page and to show it as a rich result: an article with its date and image, a product with price and stock, an event with its date and venue, a job with salary and location. This integration turns your page data into that JSON-LD and the matching meta tags, and stops the build when the data would not be valid.

npm version Astro License: MIT

Website and documentation: casoon.github.io/astro-structured-data · npm

What it does

1. You pass the page data to a component:

<ArticleSchema
  title="Hello, Astro"
  description="Our first post."
  datePublished="2026-10-01"
  authorName="Ada Lovelace"
  imageUrl="/img/hello.jpg"
/>

2. astro build writes JSON-LD (and, with generateMeta, canonical, Open Graph and Twitter tags) into the page's <head>:

<script type="application/ld+json">
{ "@context": "https://schema.org", "@type": "BlogPosting",
  "headline": "Hello, Astro", "datePublished": "2026-10-01",
  "author": { "@type": "Person", "name": "Ada Lovelace" }, … }
</script>

3. Invalid data stops the build instead of being silently ignored:

[astro-structured-data] <ArticleSchema> on /blog/hello-astro/ received invalid props:
✖ Must be an ISO 8601 date (YYYY-MM-DD) or date-time, or a Date
  → at datePublished

Output taken from real builds of the sample project in site/captures/.

Why

  • Rich results need structured data. Prices, ratings, event dates or job details only appear in search results when the page describes them as schema.org data.
  • Hand-written JSON-LD fails silently. A wrong date format or a missing required field produces no error; the markup is simply not used.
  • Your pages already have the data. Pass frontmatter, content collection or CMS fields as props instead of keeping a second copy as JSON.
  • Checked where you can fix it. Wrong data stops the build with the component, the page and the field. No client JavaScript is added.

Install

npm install @casoon/astro-structured-data
pnpm add @casoon/astro-structured-data
yarn add @casoon/astro-structured-data
// astro.config.mjs
import { defineConfig } from 'astro/config';
import structuredData from '@casoon/astro-structured-data';

export default defineConfig({
  site: 'https://example.com', // or pass siteUrl to the integration
  integrations: [
    structuredData({
      generateMeta: true,
      siteName: 'Example Blog',
      locale: 'en_US',
    }),
  ],
});

All options: Integration options.

Quick start

---
// src/layouts/Post.astro
import { ArticleSchema } from '@casoon/astro-structured-data/components';
const { post } = Astro.props;
---
<ArticleSchema
  title={post.data.title}
  description={post.data.description}
  datePublished={post.data.date}
  authorName={post.data.author}
  imageUrl={post.data.cover}
/>

Run astro build: the page gets a BlogPosting JSON-LD block and, with generateMeta, the canonical, Open Graph and Twitter tags. Wrong data stops the build, missing recommended fields are listed. Walkthrough: Quickstart · setups for blogs, shops, local businesses, events and job boards: Setups by kind of site.

Components

Imported from @casoon/astro-structured-data/components. Each page has an example, the JSON-LD it produces, every prop and the rules it checks.

| Component | Purpose | |---|---| | ArticleSchema | Blog posts, news and articles (BlogPosting, Article, NewsArticle) | | FAQSchema | Question and answer pages (FAQPage) | | ProductSchema | Products with offers, ratings, shipping and returns | | LocalBusinessSchema | Address, phone, opening hours and service area of a business, as LocalBusiness or a subtype such as Bakery | | EventSchema | On-site, online and hybrid events | | OrganizationSchema | The organization behind the site | | WebSiteSchema | The site itself, optionally with a site search action | | WebPageSchema | Generic pages, plus robots and hreflang alternates | | ProfilePageSchema | Author and person profiles | | CollectionPageSchema | Category, listing and archive pages | | JobPostingSchema | On-site, remote and hybrid job postings | | SoftwareAppSchema | Apps with price, rating, OS and category | | RecipeSchema | Recipes with ingredients, steps and times | | VideoSchema | Videos (VideoObject) | | BreadcrumbSchema, AutoBreadcrumbSchema | Breadcrumb trails, given or built from the URL path | | Schema, SchemaGraph | Any other schema.org type; the position of the page's @graph block |

Zod schemas for every component, validateRecommended and calculateReadingTime: Zod schemas and content · Package exports.

Features

  • Validation: props are checked against Zod schemas at render time (ISO formats, cross-field rules, schema.org objects, unknown props); invalid data fails the build or, in SSR, the request.
  • Meta tags and sitemap hints: with generateMeta: true, canonical, Open Graph and Twitter tags come from the most page-specific schema; tags your layout sets win. changefreq and priority are passed to post-build sitemap generators.
  • Graph mode: with useGraph: true, all schemas of a page are merged into one @graph block, linked by @id.
  • Dev Toolbar: in astro dev, a panel previews each schema of the page as a rich result and lists missing fields.
  • Build check: after astro build, every JSON-LD block is parsed and missing recommended fields are listed per type.
  • On-demand rendering: works the same with an adapter; how streaming and errors behave there.

Compatibility

| Package version | Astro | Node.js | |---|---|---| | 2.4.x – 2.10.x | 5.x · 6.x · 7.x | ≥ 18 | | 2.1.x – 2.3.x | 5.x · 6.x · 7.x | ≥ 18 | | 2.0.x | 5.x · 6.x · 7.x | ≥ 18 | | 1.5.x | 5.x · 6.x · 7.x | ≥ 18 | | 1.4.x | 5.x · 6.x | ≥ 18 |

The Node.js minimum is the one of your Astro version (its engines field): Astro 5 needs 18.20.8, 20.3 or 22+, Astro 6 needs 22.12+, Astro 7.4 needs 22.23.4+.

Astro 5 and 6 are checked locally with npm run test:compat (see Development); last verified with Astro 5.18.2 and 6.4.8 on Node 22.12 and 24.

Coming from 1.x: see the upgrade guide. All changes are listed in the changelog.

Development

npm test              # unit tests and end-to-end tests (real static build, dev server and Node SSR)
npm run test:compat   # the same suite against Astro 5 and Astro 6
npm run check         # type-check, including the .astro components
npm run build

npm run test:compat -- 6 checks one major only; it needs network access and Node 22.12+. Details: How compatibility is checked.

Author

Built and maintained by Jörn Seidel (CASOON). Background and design decisions are described in an article on Insights (in German): astro-structured-data: JSON-LD für Astro, beim Build geprüft.

License

MIT