Building a content pipeline that fails early

How this site validates MDX metadata, references, and publication state before a page is deployed.

By 2 min read
  • next.js
  • mdx
  • typescript

A portfolio can look complete while its publishing model is still fragile. The useful question for this build was narrower: what should fail before an invalid article reaches production?

Start with the filesystem

Each MDX filename is the canonical slug. That removes a second slug field that could disagree with the route. The manifest scans two bounded directories, sorts the filenames, parses frontmatter, and calculates reading time from the body.

The filesystem work stays in a server-only module. Pages receive typed entries; browser code never receives file access.

Validate publication as a state change

Drafts can be incomplete. Published entries cannot. The shared schema therefore permits an absent date while draft is true and adds a validation issue when a published entry has no publishedAt value.

Interactive metadata check

What changes when an entry is published?

draft
true
publishedAt
not required

Valid: a draft can remain undated and stays out of the production manifest.

The control is deliberately small. The surrounding article is server-rendered and remains readable without JavaScript; only the metadata example needs client state.

Check relationships in both directions

Writing may name the project it explains. A project may list related writing. The manifest builds both slug sets and rejects references that do not exist. It repeats that check after production draft filtering so a public page cannot point to a draft that disappeared from the deployed manifest.

Bound the route set

The dynamic routes generate static parameters from the validated manifest. Unknown slugs are not generated, and the route also checks its lookup before importing an MDX module. This keeps the URL behavior aligned with the content model rather than treating any arbitrary string as importable content.

What this proves

This build note proves the smallest complete path: authored MDX, validated metadata, a generated index, a static detail route, route-specific metadata, an unknown-slug 404, and one isolated interactive component.

It does not prove the quality of a future robotics article. That still depends on real implementation work, useful evidence, and careful editing.