A statically generated blog example using Next.js, Markdown, TypeScript, internationalization, and a pre-commit hook for dynamic sitemap generation.
This is the existing blog-starter plus TypeScript, internationalization, and Husky.
- Static Generation: Utilizes Next.js's Static Generation feature with Markdown files as the data source.
- Internationalization (i18n): Supports multiple languages for content localization.
- Husky Integration: Incorporates Husky for pre-commit hook automation (sitemap generation).
Blog posts are stored in the /_posts
directory as Markdown files with front matter support.
Each Markdown file represents a blog post. It's crucial to maintain the following folder structure:
The name of each Markdown file becomes the post's path, for example: title-of-the-post.md
.
/_posts/(lang)/(category)/(title-of-the-post).md
---
title: "Title of the Post"
excerpt: "Excerpt of the Post"
coverImage: "/assets/blog/title-of-the-post/cover.jpg"
date: "2024-02-27"
author:
name: Author
picture: "/assets/blog/title-of-the-post/author.jpeg"
ogImage: "/assets/blog/title-of-the-post/cover.jpg"
category: "news"
---
...include the markdown post content after the front matter.
Upon adding/editing/deleting a Markdown file and attempting to commit changes, Husky triggers an sh script (/backend/pre-commit-sh) that generates a new sitemap in the /public folder and automatically adds it to the commit.
pnpm i
then
pnpm run dev
or
pnpm run build && pnpm run start