Skip to content

About

Next.js blog starter for testing templ-sites

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Repository files navigation

A statically generated blog example using Next.js, Markdown, and TypeScript

This is the existing blog-starter plus TypeScript.

This example showcases Next.js's Static Generation feature using Markdown files as the data source.

The blog posts are stored in /_posts as Markdown files with front matter support. Adding a new Markdown file in there will create a new blog post.

To create the blog posts we use remark and remark-html to convert the Markdown files into an HTML string, and then send it down as a prop to the page. The metadata of every post is handled by gray-matter and also sent in props to the page.

Demo

https://next-blog-starter.vercel.app/

Deploy your own

Deploy with Vercel

Related examples

How to use

Execute create-next-app with npm, Yarn, or pnpm to bootstrap the example:

npx create-next-app --example blog-starter blog-starter-app
yarn create next-app --example blog-starter blog-starter-app
pnpm create next-app --example blog-starter blog-starter-app

Your blog should be up and running on http://localhost:3000! If it doesn't work, post on GitHub discussions.

Deploy it to the cloud with Vercel (Documentation).

Environment Variables

This blog supports the following environment variables:

Variable Type Description
NEXT_PUBLIC_BLOG_TITLE Build-time The main title displayed in the header. Defaults to "Blog".
FOOTER_MESSAGE Runtime Optional message displayed at the top of the footer.

Note on Runtime Variables in Next.js

For runtime env vars to work in Next.js server components, the component must opt out of static rendering. The Footer uses noStore() from next/cache to ensure FOOTER_MESSAGE is read at request time, not build time.

Without this, statically generated pages bake in env var values at build time.

Notes

blog-starter uses Tailwind CSS (v3.0).

Emanuel was here.

About

Next.js blog starter for testing templ-sites

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages