Next.js
The reference Next.js app that exercises collections, trees, items, and relations.
On this page
The canonical qino example is a Next.js App Router site. It lives in the repository at examples/next-js.
What it covers
- Collections:
posts(.md),authors(.json), andcategories(.json). - Relations:
authorandcategoryon posts;featured-posts[*]on the home item. - Markdown stats:
markdown.statson posts, with a reading time derived from_stats.wordCountby a localgetReadingTimeshelper. - Tree: a
.mdxdocs tree with nested sections,_order.jsonordering, and prev/next navigation. - Item:
pages/home.mdwith resolved featured posts. - CLI:
qino buildas theprebuildscript, withqino/_generated/gitignored. - Agent-ready content:
pageson posts and docs, served as page Markdown at each page's Markdown URL and to requests whoseAcceptheader lists Markdown first.llms.txtand the homepage'sindex.mdare built fromsrc/content/llms.md, andindex.mdalso answers Markdown requests for/. Unknown paths get the Markdown 404. See Next.js.
Layout
examples/next-js/
qino/
index.ts
collections/{posts,authors,categories}.ts
trees/docs.ts
items/home.ts
src/content/
posts/*.md
authors/*.json
categories/*.json
docs/**
pages/home.md
llms.md the llms.txt template
src/app/
page.tsx home item
posts/page.tsx collection listing
posts/[slug]/page.tsx getAllSlugs + getEntry
posts/tags/[tag]/page.tsx posts filtered by category
posts/authors/[author]/page.tsx posts filtered by author
docs/[...slug]/page.tsx getTree, getEntry, getPreviousNode, getNextNode
md/route.ts the homepage's Markdown, from public/index.md
md/missing/route.ts the Markdown 404
md/posts/route.ts the posts index page's Markdown
md/posts/[slug]/route.ts a post's page Markdown
md/docs/route.ts the docs index page's Markdown
md/docs/[...slug]/route.ts a docs page's Markdown
next.config.ts beforeFiles and fallback rewrites to the md/ routes
Key snippets
Static params from a collection:
export async function generateStaticParams() {
const slugs = await postCollection.getAllSlugs();
return slugs.map((slug) => ({ slug }));
}
A docs page reading structure, content, and neighbors in one go:
const [nodes, entry, previousNode, nextNode] = await Promise.all([
docsTree.getTree(),
docsTree.getEntry(fullSlug),
docsTree.getPreviousNode(fullSlug),
docsTree.getNextNode(fullSlug),
]);
Rendering
qino returns raw Markdown. The example renders .md posts with react-markdown and .mdx docs with next-mdx-remote, both with remark-gfm, rehype-slug, rehype-autolink-headings, and rehype-highlight.
The example on Github lives in a monorepo and imports @qino/cms from the workspace, which exposes raw TypeScript, so Next.js must transpile it. Apps installing @qino/cms from npm get compiled JavaScript and don't need to add it to transpilePackages in nextConfig.
Run it
pnpm install
pnpm --filter next-js dev