Next.js
The reference Next.js app that exercises collections, trees, items, relations, and views.
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:
authorandcategories[*]on posts;featured-posts[*]on the home item. - Views: a
defaultview that resolves relations one level deep, and awithReadingTimeview that spreads the default and augments withgetMarkdownStats. - 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.
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
src/app/
page.tsx home item
posts/page.tsx collection listing
posts/[slug]/page.tsx getAllSlugs + getEntry
docs/[...slug]/page.tsx getTree, getEntry, getPreviousNode, getNextNode
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.
Next.js configuration
const nextConfig = {
transpilePackages: ["@qino/cms"],
};
export default nextConfig;
Run it
pnpm install
pnpm --filter next-js dev