@playstack/content
Framework- and loader-independent content transforms, schema fields, and array resolution helpers.
Pro. Covered by the Playstack Pro License. Registry access is required; check preview availability before installing. See package access.
@playstack/content contains pure, deterministic content transforms, shared schema fields, and array-resolution helpers that work with Content Collections or any other loader.
Install
After confirming preview access, install the package at your application's shared Playstack version:
npm install --save-exact @playstack/content@0.1.0-beta.1Check the peer requirements below before choosing a runtime or provider.
Install and compose a schema
import { contentBase } from '@playstack/content/zod'
import { excerpt, normalizeDate, readingTime, slugify } from '@playstack/content'
import { z } from 'zod'
const postSchema = z.object({
...contentBase,
content: z.string(),
tags: z.array(z.string()).default([]),
})
const post = postSchema.parse(input)
const slug = post.slug ?? slugify(post.title)
const date = normalizeDate(post.date)
const summary = excerpt(post.content, { words: 40 })
const duration = readingTime(post.content, { wordsPerMinute: 220 })contentBase defines title, description, flexible input date, published flag, and optional slug. Applications extend it rather than inheriting a loader-specific document type.
Transform options
| Function | Options | Result |
|---|---|---|
slugify | separator: '-' | '_' | Unicode-normalized, stable lowercase slug. |
readingTime | wordsPerMinute, excludeCodeBlocks | Word count, fractional minutes, and display text. |
extractToc | minDepth, maxDepth | Nested heading items. |
excerpt | words, marker | Word-bounded plain-text excerpt. |
normalizeDate | None | Valid normalized ISO timestamp. |
Resolve injected collections
import {
resolveAdjacent,
resolveDoc,
resolveDocs,
resolvePaths,
resolveRelated,
} from '@playstack/content'
const post = resolveDoc(allPosts, { slug: 'build-once' })
const published = resolveDocs(allPosts, {
filter: (entry) => entry.published,
sort: (a, b) => b.date.localeCompare(a.date),
limit: 20,
})
const paths = resolvePaths(allPosts, { param: 'slug' })
const adjacent = resolveAdjacent(allPosts, { slug: 'build-once' })
const related = resolveRelated(allPosts, { slug: 'build-once', by: 'tags', limit: 3 })Resolution accepts document arrays and optional nested fields.slug/fields.date mappings. Filtering, sorting, limits, related-field selection, and route param names stay explicit application inputs.
Boundary
The package performs no filesystem or network access and depends on no framework, rendering library, or content loader. It does not compile Markdown, render MDX, watch files, or own pagination UI. Consumers inject already-loaded values, making the helpers usable at build time, runtime, and in tests.
API entry points and requirements
Reference snapshot: @playstack/content@0.1.0-beta.1. Import only the entry point your runtime needs. Paths below are relative to the installed package; use Go to Definition in your editor to inspect exact parameters, return types and overloads. Do not import the declaration-file paths directly.
| Public entry point | Declaration file |
|---|---|
@playstack/content | ./dist/index.d.ts |
@playstack/content/zod | ./dist/zod.d.ts |
@playstack/content/package.json | No TypeScript declaration (asset or metadata export). |
Node.js engine requirement: >=20. This is not a claim that every entry point works in browsers or Workers.
Peer dependencies
Keep existing framework versions that satisfy these ranges. Install optional peers only when using the corresponding adapter. The package manager resolves ordinary dependencies separately.
| Peer | Compatible range | When needed |
|---|---|---|
zod | ^4.4.3 | Optional; only for the entry points that use it. |
For a complete first program, start with Getting started. For API lookup and partial-example conventions, see Reading the reference. Provider failures, lifecycle requirements and application responsibilities remain described in the guide above; types alone do not establish production safety.