A beautiful, modern blog platform built with Next.js 16 and powered by Cosmic CMS. Features dynamic content display, category filtering, author profiles, and markdown rendering.
- π Dynamic blog post display with featured images
- π€ Author profiles with bio and social links
- π·οΈ Category-based filtering and navigation
- π± Fully responsive mobile-first design
- π¨ Modern UI with Tailwind CSS
- π Built with Next.js 16 App Router
- π SEO-optimized with dynamic metadata
- π Markdown content rendering
- πΌοΈ Automatic image optimization with imgix
- β‘ Server-side rendering for optimal performance
Want to create your own version of this project with all the content and structure? Clone this Cosmic bucket and code repository to get started instantly:
This application was built using the following prompts to generate the content structure and code:
Create a content model for a blog with posts, authors, and categories
Based on the content model I created for "Create a content model for a blog with posts, authors, and categories", now build a complete web application using Next.js that showcases this content. Include a modern, responsive design with proper navigation, content display, and user-friendly interface.
The app has been tailored to work with your existing Cosmic content structure and includes all the features requested above.
- Next.js 16 - React framework with App Router
- Cosmic - Headless CMS for content management
- Tailwind CSS - Utility-first CSS framework
- TypeScript - Type-safe development
- React Markdown - Markdown rendering
- Imgix - Image optimization and delivery
- Node.js 18+ or Bun
- A Cosmic account and bucket with blog content
- Clone this repository
- Install dependencies:
bun install- Create a .env.localfile with your Cosmic credentials:
COSMIC_BUCKET_SLUG=your-bucket-slug
COSMIC_READ_KEY=your-read-key- Run the development server:
bun run dev- Open http://localhost:3000 in your browser
import { cosmic } from '@/lib/cosmic'
const { objects: posts } = await cosmic.objects
  .find({ type: 'posts' })
  .props(['id', 'title', 'slug', 'metadata'])
  .depth(1)const { object: post } = await cosmic.objects
  .findOne({
    type: 'posts',
    slug: 'your-post-slug'
  })
  .depth(1)const { objects: posts } = await cosmic.objects
  .find({
    type: 'posts',
    'metadata.categories': categoryId
  })
  .depth(1)const { object: author } = await cosmic.objects
  .findOne({
    type: 'authors',
    slug: 'author-slug'
  })
const { objects: authorPosts } = await cosmic.objects
  .find({
    type: 'posts',
    'metadata.author': author.id
  })
  .depth(1)This application uses Cosmic's headless CMS to manage all content. The content model includes:
- Title and slug
- Markdown content
- Featured image
- Author (object relationship)
- Categories (objects relationship)
- Excerpt
- Name
- Bio
- Avatar image
- Twitter handle
- Website URL
- Title and slug
- Description
All relationships are loaded using the depth(1) parameter for efficient data fetching. Images are automatically optimized using Cosmic's imgix integration.
- Click the button above
- Connect your Git repository
- Add your environment variables:
- COSMIC_BUCKET_SLUG
- COSMIC_READ_KEY
 
- Deploy!
Make sure to set these environment variables in your deployment platform:
COSMIC_BUCKET_SLUG=your-bucket-slug
COSMIC_READ_KEY=your-read-keyβββ app/
β   βββ layout.tsx          # Root layout with navigation
β   βββ page.tsx            # Home page with all posts
β   βββ posts/
β   β   βββ [slug]/
β   β       βββ page.tsx    # Individual post pages
β   βββ authors/
β   β   βββ [slug]/
β   β       βββ page.tsx    # Author profile pages
β   βββ categories/
β       βββ [slug]/
β           βββ page.tsx    # Category filtered posts
βββ components/
β   βββ Header.tsx          # Site header with navigation
β   βββ PostCard.tsx        # Post card component
β   βββ AuthorInfo.tsx      # Author information display
β   βββ CategoryBadge.tsx   # Category badge component
β   βββ CosmicBadge.tsx     # "Built with Cosmic" badge
βββ lib/
β   βββ cosmic.ts           # Cosmic SDK configuration
βββ types.ts                # TypeScript type definitions
