BlogPosting builder
Le builder BlogPosting crée une entité BlogPosting, injecte son @type,
valide les données de manière synchrone et rejette les propriétés inconnues.
// Astro — shown first when Astro is selectedimport { BlogPosting } from '@unschema-graph/astro';
// Svelte 5import { BlogPosting } from '@unschema-graph/svelte';
// Core / Node.jsimport { BlogPosting } from '@unschema-graph/core';import { ArticleSchema } from '@unschema-graph/core';Le schéma Zod ArticleSchema est également exporté pour la composition et la validation avancées.
Types TypeScript
Section intitulée « Types TypeScript »import { ArticleSchema, type SchemaInput, type SchemaOutput,} from '@unschema-graph/core';
type BlogPostingInput = SchemaInput<typeof ArticleSchema>;type BlogPostingOutput = SchemaOutput<typeof ArticleSchema, 'BlogPosting'>;Propriétés d’entrée
Section intitulée « Propriétés d’entrée »| Propriété | Type d’entrée | Obligatoire | Valeur par défaut / contraintes |
|---|---|---|---|
@id |
string | Non | non-empty |
headline |
string | Oui | non-empty |
image |
string | ImageObject | Array<string | ImageObject> | Oui | non-empty |
datePublished |
string | number | Date | Oui | non-empty |
dateModified |
string | number | Date | Non | non-empty |
author |
string | Person | Organization | EntityReference | Array<string | Person | Organization | EntityReference> | Oui | non-empty |
publisher |
string | Organization | EntityReference | Non | non-empty |
description |
string | Non | — |
articleBody |
string | Non | — |
articleSection |
string | Array |
Non | — |
keywords |
string | Array |
Non | — |
inLanguage |
string | Non | — |
mainEntityOfPage |
string | object | Non | — |
wordCount |
number | Non | integer; greater than 0; maximum: 9007199254740991 |
speakable |
string | Array |
Non | — |
Les alias ci-dessus restent la référence exacte, notamment pour les objets imbriqués. Le builder
accepte aussi une configuration de validation en second argument et possède une sortie dont le
@type vaut toujours BlogPosting.
Exemple minimal
Section intitulée « Exemple minimal »import { BlogPosting } from '@unschema-graph/core';
const entity = BlogPosting({ "headline": "Structured data with Astro", "image": "/images/structured-data.jpg", "datePublished": "2026-09-29", "author": "Ada Lovelace"});{ "@type": "BlogPosting", "headline": "Structured data with Astro", "image": "/images/structured-data.jpg", "datePublished": "2026-09-29", "author": { "@type": "Person", "name": "Ada Lovelace" }}Relations et recettes
Section intitulée « Relations et recettes »- Builders liés :
Article,NewsArticle,Recipe,HowTo - Utilisé par : Blog et média
- Sources externes : Schema.org BlogPosting · Google Search Central
Erreurs fréquentes
Section intitulée « Erreurs fréquentes »- Passer une propriété inconnue au builder strict.
- Utiliser une donnée source privée d’une propriété obligatoire.
- Supposer qu’un Schema.org valide garantit un affichage dans la recherche.
Validation
Section intitulée « Validation »Utilisez BlogPosting.safeParse(input) pour les données externes. Pour une extension
Schema.org non encore modélisée, validez d’abord l’entité puis utilisez
withAdditionalProperties(). N’ajoutez jamais une propriété inventée au builder.