NewsArticle builder
Creates a NewsArticle using the strict Article input schema. The NewsArticle builder injects @type, validates synchronously, and
rejects unknown properties.
Import
Section titled “Import”// Astro — shown first when Astro is selectedimport { NewsArticle } from '@unschema-graph/astro';
// Svelte 5import { NewsArticle } from '@unschema-graph/svelte';
// Core / Node.jsimport { NewsArticle } from '@unschema-graph/core';import { ArticleSchema } from '@unschema-graph/core';The ArticleSchema Zod schema is also exported for composition and advanced validation.
TypeScript types
Section titled “TypeScript types”import { ArticleSchema, type SchemaInput, type SchemaOutput,} from '@unschema-graph/core';
type NewsArticleInput = SchemaInput<typeof ArticleSchema>;type NewsArticleOutput = SchemaOutput<typeof ArticleSchema, 'NewsArticle'>;Input properties
Section titled “Input properties”| Property | Input type | Required | Default / constraints |
|---|---|---|---|
@id |
string | No | non-empty |
headline |
string | Yes | non-empty |
image |
string | ImageObject | Array<string | ImageObject> | Yes | non-empty |
datePublished |
string | number | Date | Yes | non-empty |
dateModified |
string | number | Date | No | non-empty |
author |
string | Person | Organization | EntityReference | Array<string | Person | Organization | EntityReference> | Yes | non-empty |
publisher |
string | Organization | EntityReference | No | non-empty |
description |
string | No | — |
articleBody |
string | No | — |
articleSection |
string | Array |
No | — |
keywords |
string | Array |
No | — |
inLanguage |
string | No | — |
mainEntityOfPage |
string | object | No | — |
wordCount |
number | No | integer; greater than 0; maximum: 9007199254740991 |
speakable |
string | Array |
No | — |
The aliases above remain the exact authority for nested object types. The builder also accepts a
validation configuration as its second argument and always returns @type: 'NewsArticle'.
Minimal example
Section titled “Minimal example”import { NewsArticle } from '@unschema-graph/core';
const entity = NewsArticle({ "headline": "Structured data with Astro", "image": "/images/structured-data.jpg", "datePublished": "2026-09-29", "author": "Ada Lovelace"});Output
Section titled “Output”{ "@type": "NewsArticle", "headline": "Structured data with Astro", "image": "/images/structured-data.jpg", "datePublished": "2026-09-29", "author": { "@type": "Person", "name": "Ada Lovelace" }}Relationships and recipes
Section titled “Relationships and recipes”- Related builders:
Article,BlogPosting,Recipe,HowTo - Used by: no dedicated recipe
- External sources: Schema.org NewsArticle · Google Search Central
Common errors
Section titled “Common errors”- Passing an unknown property to the strict builder.
- Using source data that is missing a required property.
- Assuming valid Schema.org guarantees a search appearance.
Validation
Section titled “Validation”Use NewsArticle.safeParse(input) for external data. If Schema.org supports a property that
is not modeled yet, validate the entity first and then use withAdditionalProperties(). Never
pass invented properties to the strict builder.