@zeropress/preview-data-validator
v0.6.12
Published
Shared ZeroPress preview data validation core
Readme
@zeropress/preview-data-validator
Shared validation core for ZeroPress preview data v0.6.
This package is the canonical runtime contract for preview payloads consumed directly by:
- @zeropress/build-core
zeropress-admin-api-v2
Public contract references:
Install
npm install @zeropress/preview-data-validatorExports
import {
PREVIEW_DATA_VERSION,
assertPreviewData,
isPreviewData,
validatePreviewData,
} from '@zeropress/preview-data-validator';Schema export:
import schemaUrl from '@zeropress/preview-data-validator/preview-data.v0.6.schema.json';Published schema files are shipped from the package schemas/ directory.
preview-data v0.6 is data-only:
- root
$schemais optional and may be used as an editor/tooling hint - no
routesblock - no raw
htmlfields on posts or pages - no preformatted
published_at/updated_at - taxonomy membership is expressed as
category_slugsandtag_slugs - per-post comment policy is expressed as
allow_comments - authors are deduplicated in
content.authors[] - posts reference authors via
author_id - post
public_idvalues are positive unique integers - body source is carried as raw
contentwith explicitdocument_type site, posts, and pages may carry optional generator-defined scalar metadata inmeta- posts and pages may carry optional structured JSON content in
datafor repeated theme UI blocks - posts and pages may carry optional
discoverability:default,noindex, ordelist site.permalinksmay define URL/output policy for posts, pages, categories, and tags- pages may carry optional
pathfor nested page URLs - pages may carry optional
updated_at_isofor page update metadata and sitemaplastmod - pages, categories, and tags do not carry internal
idfields site.media_base_urlis required and must be either an empty string or an absolute URI- optional
site.media_delivery_modemay benoneormedia_domain - optional
site.faviconmay carryicon,svg,png, andapple_touch_iconURLs for HTML head output - optional
site.logomay carry theme-facing site identity data as{ src, alt } - optional
site.newslettermay carry theme-facing newsletter CTA/island data; ZeroPress does not implement provider submit behavior - optional
site.expose_generatorcontrols whether generated HTML exposes the ZeroPress generator meta tag - optional
site.searchcontrols whether native static search may be enabled when the active theme supports search - site locale is carried as
site.locale - site timezone is carried as
site.timezone - datetime display preference is carried as
site.datetime_display - fallback datetime formatting uses
site.date_styleandsite.time_styleIntl style presets - comment rendering policy is carried as
site.disallow_comments - fallback
robots.txtindexing policy may be carried as optionalsite.indexing - enabled menus may be exported in optional root
menus menusis keyed by stablemenu_id- menu items use
title,url,type,target, optional scalarmeta, and recursivechildren - menu item
targetis_selfor_blank - menu items do not carry admin-only fields such as
reference_id - enabled widget areas may be exported in optional root
widgets widgetsis keyed by stablewidget_area_id- widget items intentionally fix only the common shell:
type,title, and optionalsettings - widget-type-specific
settingsstructure is not enforced by this validator in v0.6 - named page/post collections may be exported in optional root
collections collectionsis keyed by stable collection ids and contains ordered{ type, slug }item references- managed media metadata may be exported in optional
content.media[] - media registry items use
src, positive integerwidth, positive integerheight, and optionalalt - optional
custom_csscarries site-level stylesheet input as{ content } - optional
custom_htmlcarries trusted site-level HTML injection slots as{ head_end: { content }, body_end: { content } }
Build tooling is responsible for resolving authors and deriving render-ready route data, including HTML conversion for non-HTML source content.
API
validatePreviewData(data)
Returns:
{
ok: true,
errors: [],
warnings: []
}assertPreviewData(data)
Throws when the payload is invalid.
isPreviewData(data)
Returns true when the payload is valid.
License
MIT
