Add a Typed MDX Blog to Your Next.js Portfolio (Contentlayer)
•2 min read

Welcome to the blog! This is a seed post to verify listing, reading time, tags, and comments.
Why Contentlayer?
Contentlayer is a content SDK that transforms your content into type-safe JSON data. It works seamlessly with Next.js and provides:
- Type safety - Full TypeScript support with auto-generated types
- MDX support - Write content in MDX with custom components
- Computed fields - Automatically calculate reading time, slugs, etc.
- Hot reload - See changes instantly during development
Getting Started
First, install the necessary dependencies:
pnpm add contentlayer next-contentlayer reading-timeThen configure your content schema in contentlayer.config.ts:
export const Post = defineDocumentType(() => ({
name: "Post",
filePathPattern: `posts/**/*.mdx`,
contentType: "mdx",
fields: {
title: { type: "string", required: true },
date: { type: "date", required: true },
description: { type: "string", required: true },
},
}));Features Included
This blog setup includes:
- Auto reading time - Calculated automatically from content
- Tags with filter pages - Navigate to
/blog/tag/[tag]to filter - Giscus comments - GitHub Discussions-powered comments
- Full SEO - Metadata, canonical URLs, sitemap, robots.txt, JSON-LD
- Local search scaffold - Simple search ready for enhancement
Next Steps
- Add more posts in
content/posts/ - Customize the MDX components
- Set up Giscus for comments
- Deploy and verify SEO
Happy blogging! 🚀