Markdown and MDX routes have no typed content schema

Open
#662 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
15/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
python, typescript
Domain
backend, content

Research direction

The issue proposes a new src/content/schema.py that does not exist yet, so the first step is deciding how the frontmatter collection key is read and where validation runs at dev start, reload and build. Work through the design with maintainers before coding, since it touches the Vite pipeline and generated types under __nexy__/client/. Done means a missing field or wrong type fails nx build with the file and field named, and docs/rendering/README.md gets a typing page.

Written by the indexing model from the issue text.

Description

area:compiler difficulty:intermediate enhancement priority:3

Problem

A .md or .mdx route can carry any frontmatter. A typo in a date or a missing field is only seen when the template reads it. Astro content collections validate the same data against a schema and give editors typed values.

This is feasible with the current compiler. Pydantic already lives in the project, and the Vite pipeline can publish generated TypeScript types.

Proposal

  • Add src/content/schema.py, with one Pydantic model per collection.
  • Let a page name its collection in frontmatter with collection = "posts".
  • Validate every page at dev start, on reload and at build.
  • Generate a TypeScript declaration file for each collection under __nexy__/client/.
  • Print the file, the field and the expected type when validation fails.

Acceptance

  • A missing required field fails nx build with the file and field in the message.
  • A wrong type fails with the expected type.
  • Generated declarations pass npx tsc --noEmit in a new strict project.
  • Locales declared by a collection are checked against the files present.
  • docs/rendering/README.md gains a page that answers how to type content.
  • Translations are regenerated, not edited by hand.

Out of scope

A CMS, remote content and editing content from the browser.

Dominant language
Python
Stars
11
Forks
6
Avg merge
2h 14m
Merged PRs (30d)
265

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from NexyPy/nexy

All issues in NexyPy/nexy

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.