✨ My blog built with Next.js, MDX, and TailwindCSS.
- Node LTS
Use create-next-app to get up and running quickly:
npx create-next-app blog --example https://github.com/gregrickaby/nextjs-blog
Create an .env
file in the root of the project.
Add the following:
NEXT_PUBLIC_GOOGLE_SITE_VERIFICATION="YOUR_VERIFICATION_CODE"
NEXT_PUBLIC_GOOGLE_ANALYTICS="UA-1234567-X"
├── components
| ├── atoms
| | └── Title
| | ├── Title.js
| | └── Title.module.css
| ├── molecules
| ├── organisms
| └── templates
├── data
| ├── books
| ├── pages
| ├── photos
| └── posts
├── lib
├── pages
| ├── [slug].js
| ├── _app.js
| ├── _document.js
| ├── blog
| ├── books
| └── index.js
├── public
| ├── blog
| ├── favicon
| ├── fonts
| ├── optimized
├── scripts
| └── generate-rss.js
├── styles
| ├── global.css
| └── prism.css
Components - This folder contains all of the components used on the blog, organized by the Atomic Design principle.
You'll see a folder with the same name as the component. For example, the Title
component is contained in the components/atoms/Title
folder. In addition, the component's styles are located with the component: components/atoms/Title/Title.module.css
Data - This folder contains all of the MDX files which is what powers the content on the blog.
Lib - This folder contains helper functions used throughout the blog.
Pages - This folder contains standard Next.js pages and routes, which are used to render pages on the blog.
Public - This folder contains all of the static assets used on the blog.
Scripts - This folder contains scripts which are used at build time.
Styles - This folder contains global styles used on the blog.
Start local dev server:
npm run dev
Test a build prior to deployment:
npm run build && npm start
Bulk linting:
npm run lint
Bulk formatting:
npm run format
Bypass Lefthook:
git commit -m "my commit message" --no-verify
It's very simple:
- Create an
.mdx
file - Place the
.mdx
file indata/posts
,data/pages
, ordata/books
- Add front matter and content
The Front Matter slug must match the blog post filename. This is because Next.js is querying data based on the post slug.
Tailwind font-*
and dark
styles do not work in CSS Modules. Instead, add the styles in the component using cn()
to merge them.
className={cn(styles.date, 'font-roboto dark:text-gray-100')}