{post.title}
11 | 12 | {post.description &&{post.description}
} 13 |├── .eslintrc.json
├── app
├── globals.css
├── favicon.ico
├── api
│ └── hello
│ │ └── route.ts
├── page.tsx
├── layout.tsx
├── [...slug]
│ └── page.tsx
└── posts
│ └── [...slug]
│ └── page.tsx
├── public
├── blog-post-1.jpg
├── blog-post-2.jpg
├── blog-post-3.jpg
├── blog-post-4.jpg
├── vercel.svg
└── next.svg
├── postcss.config.js
├── .vscode
└── settings.json
├── README.md
├── components
├── analytics.tsx
├── theme-provider.tsx
├── mdx-components.tsx
└── mode-toggle.tsx
├── next.config.js
├── tailwind.config.js
├── .gitignore
├── package.json
├── tsconfig.json
├── contentlayer.config.js
└── content
├── pages
└── about.mdx
└── posts
├── deploying-next-apps.mdx
├── preview-mode-headless-cms.mdx
├── server-client-components.mdx
└── dynamic-routing-static-regeneration.mdx
/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "next/core-web-vitals"
3 | }
4 |
--------------------------------------------------------------------------------
/app/globals.css:
--------------------------------------------------------------------------------
1 | @tailwind base;
2 | @tailwind components;
3 | @tailwind utilities;
4 |
--------------------------------------------------------------------------------
/app/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shadcn/next-contentlayer/HEAD/app/favicon.ico
--------------------------------------------------------------------------------
/public/blog-post-1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shadcn/next-contentlayer/HEAD/public/blog-post-1.jpg
--------------------------------------------------------------------------------
/public/blog-post-2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shadcn/next-contentlayer/HEAD/public/blog-post-2.jpg
--------------------------------------------------------------------------------
/public/blog-post-3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shadcn/next-contentlayer/HEAD/public/blog-post-3.jpg
--------------------------------------------------------------------------------
/public/blog-post-4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shadcn/next-contentlayer/HEAD/public/blog-post-4.jpg
--------------------------------------------------------------------------------
/app/api/hello/route.ts:
--------------------------------------------------------------------------------
1 | export async function GET(request: Request) {
2 | return new Response('Hello, Next.js!')
3 | }
4 |
--------------------------------------------------------------------------------
/postcss.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | plugins: {
3 | tailwindcss: {},
4 | autoprefixer: {},
5 | },
6 | }
7 |
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "typescript.tsdk": "node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib",
3 | "typescript.enablePromptUseWorkspaceTsdk": true
4 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Next.js + Contentlayer
2 |
3 | A template with Next.js 13 app dir, Contentlayer, Tailwind CSS and dark mode.
4 |
5 | https://next-contentlayer.vercel.app
6 |
7 |
8 |
--------------------------------------------------------------------------------
/components/analytics.tsx:
--------------------------------------------------------------------------------
1 | "use client"
2 |
3 | import { Analytics as VercelAnalytics } from "@vercel/analytics/react"
4 |
5 | export function Analytics() {
6 | return
{post.description}
} 13 |{page.description}
} 56 |57 | {post.description} 58 |
59 | )} 60 |24 | For years parents have espoused the health benefits of eating garlic bread 25 | with cheese to their children, with the food earning such an iconic status 26 | in our culture that kids will often dress up as warm, cheesy loaf for 27 | Halloween. 28 |
29 |30 | But a recent study shows that the celebrated appetizer may be linked to a 31 | series of rabies cases springing up around the country. 32 |
33 |` tag unless there are multiple paragraphs in the list item. That means I have to worry about styling that annoying situation too. 137 | 138 | - **For example, here's another nested list.** 139 | 140 | But this time with a second paragraph. 141 | 142 | - These list items won't have `
` tags 143 | - Because they are only one line each 144 | 145 | - **But in this second top-level list item, they will.** 146 | 147 | This is especially annoying because of the spacing on this paragraph. 148 | 149 | - As you can see here, because I've added a second line, this list item now has a `
` tag.
150 |
151 | This is the second line I'm talking about by the way.
152 |
153 | - Finally here's another list item so it's more like a list.
154 |
155 | - A closing list item, but with no nested list, because why not?
156 |
157 | And finally a sentence to close off this section.
158 |
159 | ## There are other elements we need to style
160 |
161 | I almost forgot to mention links, like [this link to the Tailwind CSS website](https://tailwindcss.com). We almost made them blue but that's so yesterday, so we went with dark gray, feels edgier.
162 |
163 | We even included table styles, check it out:
164 |
165 | | Wrestler | Origin | Finisher |
166 | | ----------------------- | ------------ | ------------------ |
167 | | Bret "The Hitman" Hart | Calgary, AB | Sharpshooter |
168 | | Stone Cold Steve Austin | Austin, TX | Stone Cold Stunner |
169 | | Randy Savage | Sarasota, FL | Elbow Drop |
170 | | Vader | Boulder, CO | Vader Bomb |
171 | | Razor Ramon | Chuluota, FL | Razor's Edge |
172 |
173 | We also need to make sure inline code looks good, like if I wanted to talk about `` elements or tell you the good news about `@tailwindcss/typography`.
174 |
175 | ### Sometimes I even use `code` in headings
176 |
177 | Even though it's probably a bad idea, and historically I've had a hard time making it look good. This _"wrap the code blocks in backticks"_ trick works pretty well though really.
178 |
179 | Another thing I've done in the past is put a `code` tag inside of a link, like if I wanted to tell you about the [`tailwindcss/docs`](https://github.com/tailwindcss/docs) repository. I don't love that there is an underline below the backticks but it is absolutely not worth the madness it would require to avoid it.
180 |
181 | #### We haven't used an `h4` yet
182 |
183 | But now we have. Please don't use `h5` or `h6` in your content, Medium only supports two heading levels for a reason, you animals. I honestly considered using a `before` pseudo-element to scream at you if you use an `h5` or `h6`.
184 |
185 | We don't style them at all out of the box because `h4` elements are already so small that they are the same size as the body copy. What are we supposed to do with an `h5`, make it _smaller_ than the body copy? No thanks.
186 |
187 | ### We still need to think about stacked headings though.
188 |
189 | #### Let's make sure we don't screw that up with `h4` elements, either.
190 |
191 | Phew, with any luck we have styled the headings above this text and they look pretty good.
192 |
193 | Let's add a closing paragraph here so things end with a decently sized block of text. I can't explain why I want things to end that way but I have to assume it's because I think things will look weird or unbalanced if there is a heading too close to the end of the document.
194 |
195 | What I've written here is probably long enough, but adding this final sentence can't hurt.
196 |
--------------------------------------------------------------------------------
/content/posts/preview-mode-headless-cms.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | title: Preview Mode for Headless CMS
3 | description: How to implement preview mode in your headless CMS.
4 | date: "2023-04-09"
5 | ---
6 |
7 | Until now, trying to style an article, document, or blog post with Tailwind has been a tedious task that required a keen eye for typography and a lot of complex custom CSS.
8 |
9 | By default, Tailwind removes all of the default browser styling from paragraphs, headings, lists and more. This ends up being really useful for building application UIs because you spend less time undoing user-agent styles, but when you _really are_ just trying to style some content that came from a rich-text editor in a CMS or a markdown file, it can be surprising and unintuitive.
10 |
11 | We get lots of complaints about it actually, with people regularly asking us things like:
12 |
13 | > Why is Tailwind removing the default styles on my `h1` elements? How do I disable this? What do you mean I lose all the other base styles too?
14 | > We hear you, but we're not convinced that simply disabling our base styles is what you really want. You don't want to have to remove annoying margins every time you use a `p` element in a piece of your dashboard UI. And I doubt you really want your blog posts to use the user-agent styles either — you want them to look _awesome_, not awful.
15 |
16 | The `@tailwindcss/typography` plugin is our attempt to give you what you _actually_ want, without any of the downsides of doing something stupid like disabling our base styles.
17 |
18 | It adds a new `prose` class that you can slap on any block of vanilla HTML content and turn it into a beautiful, well-formatted document:
19 |
20 | ```html
21 |
24 | For years parents have espoused the health benefits of eating garlic bread
25 | with cheese to their children, with the food earning such an iconic status
26 | in our culture that kids will often dress up as warm, cheesy loaf for
27 | Halloween.
28 |
30 | But a recent study shows that the celebrated appetizer may be linked to a
31 | series of rabies cases springing up around the country.
32 | ` tag unless there are multiple paragraphs in the list item. That means I have to worry about styling that annoying situation too.
137 |
138 | - **For example, here's another nested list.**
139 |
140 | But this time with a second paragraph.
141 |
142 | - These list items won't have ` ` tags
143 | - Because they are only one line each
144 |
145 | - **But in this second top-level list item, they will.**
146 |
147 | This is especially annoying because of the spacing on this paragraph.
148 |
149 | - As you can see here, because I've added a second line, this list item now has a ` ` tag.
150 |
151 | This is the second line I'm talking about by the way.
152 |
153 | - Finally here's another list item so it's more like a list.
154 |
155 | - A closing list item, but with no nested list, because why not?
156 |
157 | And finally a sentence to close off this section.
158 |
159 | ## There are other elements we need to style
160 |
161 | I almost forgot to mention links, like [this link to the Tailwind CSS website](https://tailwindcss.com). We almost made them blue but that's so yesterday, so we went with dark gray, feels edgier.
162 |
163 | We even included table styles, check it out:
164 |
165 | | Wrestler | Origin | Finisher |
166 | | ----------------------- | ------------ | ------------------ |
167 | | Bret "The Hitman" Hart | Calgary, AB | Sharpshooter |
168 | | Stone Cold Steve Austin | Austin, TX | Stone Cold Stunner |
169 | | Randy Savage | Sarasota, FL | Elbow Drop |
170 | | Vader | Boulder, CO | Vader Bomb |
171 | | Razor Ramon | Chuluota, FL | Razor's Edge |
172 |
173 | We also need to make sure inline code looks good, like if I wanted to talk about `` elements or tell you the good news about `@tailwindcss/typography`.
174 |
175 | ### Sometimes I even use `code` in headings
176 |
177 | Even though it's probably a bad idea, and historically I've had a hard time making it look good. This _"wrap the code blocks in backticks"_ trick works pretty well though really.
178 |
179 | Another thing I've done in the past is put a `code` tag inside of a link, like if I wanted to tell you about the [`tailwindcss/docs`](https://github.com/tailwindcss/docs) repository. I don't love that there is an underline below the backticks but it is absolutely not worth the madness it would require to avoid it.
180 |
181 | #### We haven't used an `h4` yet
182 |
183 | But now we have. Please don't use `h5` or `h6` in your content, Medium only supports two heading levels for a reason, you animals. I honestly considered using a `before` pseudo-element to scream at you if you use an `h5` or `h6`.
184 |
185 | We don't style them at all out of the box because `h4` elements are already so small that they are the same size as the body copy. What are we supposed to do with an `h5`, make it _smaller_ than the body copy? No thanks.
186 |
187 | ### We still need to think about stacked headings though.
188 |
189 | #### Let's make sure we don't screw that up with `h4` elements, either.
190 |
191 | Phew, with any luck we have styled the headings above this text and they look pretty good.
192 |
193 | Let's add a closing paragraph here so things end with a decently sized block of text. I can't explain why I want things to end that way but I have to assume it's because I think things will look weird or unbalanced if there is a heading too close to the end of the document.
194 |
195 | What I've written here is probably long enough, but adding this final sentence can't hurt.
196 |
--------------------------------------------------------------------------------
/content/posts/server-client-components.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | title: Server and Client Components
3 | description: React Server Components allow developers to build applications that span the server and client.
4 | date: "2023-01-08"
5 | ---
6 |
7 | Until now, trying to style an article, document, or blog post with Tailwind has been a tedious task that required a keen eye for typography and a lot of complex custom CSS.
8 |
9 | By default, Tailwind removes all of the default browser styling from paragraphs, headings, lists and more. This ends up being really useful for building application UIs because you spend less time undoing user-agent styles, but when you _really are_ just trying to style some content that came from a rich-text editor in a CMS or a markdown file, it can be surprising and unintuitive.
10 |
11 | We get lots of complaints about it actually, with people regularly asking us things like:
12 |
13 | > Why is Tailwind removing the default styles on my `h1` elements? How do I disable this? What do you mean I lose all the other base styles too?
14 | > We hear you, but we're not convinced that simply disabling our base styles is what you really want. You don't want to have to remove annoying margins every time you use a `p` element in a piece of your dashboard UI. And I doubt you really want your blog posts to use the user-agent styles either — you want them to look _awesome_, not awful.
15 |
16 | The `@tailwindcss/typography` plugin is our attempt to give you what you _actually_ want, without any of the downsides of doing something stupid like disabling our base styles.
17 |
18 | It adds a new `prose` class that you can slap on any block of vanilla HTML content and turn it into a beautiful, well-formatted document:
19 |
20 | ```html
21 |
24 | For years parents have espoused the health benefits of eating garlic bread
25 | with cheese to their children, with the food earning such an iconic status
26 | in our culture that kids will often dress up as warm, cheesy loaf for
27 | Halloween.
28 |
30 | But a recent study shows that the celebrated appetizer may be linked to a
31 | series of rabies cases springing up around the country.
32 | ` tag unless there are multiple paragraphs in the list item. That means I have to worry about styling that annoying situation too.
137 |
138 | - **For example, here's another nested list.**
139 |
140 | But this time with a second paragraph.
141 |
142 | - These list items won't have ` ` tags
143 | - Because they are only one line each
144 |
145 | - **But in this second top-level list item, they will.**
146 |
147 | This is especially annoying because of the spacing on this paragraph.
148 |
149 | - As you can see here, because I've added a second line, this list item now has a ` ` tag.
150 |
151 | This is the second line I'm talking about by the way.
152 |
153 | - Finally here's another list item so it's more like a list.
154 |
155 | - A closing list item, but with no nested list, because why not?
156 |
157 | And finally a sentence to close off this section.
158 |
159 | ## There are other elements we need to style
160 |
161 | I almost forgot to mention links, like [this link to the Tailwind CSS website](https://tailwindcss.com). We almost made them blue but that's so yesterday, so we went with dark gray, feels edgier.
162 |
163 | We even included table styles, check it out:
164 |
165 | | Wrestler | Origin | Finisher |
166 | | ----------------------- | ------------ | ------------------ |
167 | | Bret "The Hitman" Hart | Calgary, AB | Sharpshooter |
168 | | Stone Cold Steve Austin | Austin, TX | Stone Cold Stunner |
169 | | Randy Savage | Sarasota, FL | Elbow Drop |
170 | | Vader | Boulder, CO | Vader Bomb |
171 | | Razor Ramon | Chuluota, FL | Razor's Edge |
172 |
173 | We also need to make sure inline code looks good, like if I wanted to talk about `` elements or tell you the good news about `@tailwindcss/typography`.
174 |
175 | ### Sometimes I even use `code` in headings
176 |
177 | Even though it's probably a bad idea, and historically I've had a hard time making it look good. This _"wrap the code blocks in backticks"_ trick works pretty well though really.
178 |
179 | Another thing I've done in the past is put a `code` tag inside of a link, like if I wanted to tell you about the [`tailwindcss/docs`](https://github.com/tailwindcss/docs) repository. I don't love that there is an underline below the backticks but it is absolutely not worth the madness it would require to avoid it.
180 |
181 | #### We haven't used an `h4` yet
182 |
183 | But now we have. Please don't use `h5` or `h6` in your content, Medium only supports two heading levels for a reason, you animals. I honestly considered using a `before` pseudo-element to scream at you if you use an `h5` or `h6`.
184 |
185 | We don't style them at all out of the box because `h4` elements are already so small that they are the same size as the body copy. What are we supposed to do with an `h5`, make it _smaller_ than the body copy? No thanks.
186 |
187 | ### We still need to think about stacked headings though.
188 |
189 | #### Let's make sure we don't screw that up with `h4` elements, either.
190 |
191 | Phew, with any luck we have styled the headings above this text and they look pretty good.
192 |
193 | Let's add a closing paragraph here so things end with a decently sized block of text. I can't explain why I want things to end that way but I have to assume it's because I think things will look weird or unbalanced if there is a heading too close to the end of the document.
194 |
195 | What I've written here is probably long enough, but adding this final sentence can't hurt.
196 |
--------------------------------------------------------------------------------
/content/posts/dynamic-routing-static-regeneration.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | title: Dynamic Routing and Static Regeneration
3 | description: How to use incremental static regeneration using dynamic routes.
4 | date: "2023-03-04"
5 | ---
6 |
7 | Until now, trying to style an article, document, or blog post with Tailwind has been a tedious task that required a keen eye for typography and a lot of complex custom CSS.
8 |
9 | By default, Tailwind removes all of the default browser styling from paragraphs, headings, lists and more. This ends up being really useful for building application UIs because you spend less time undoing user-agent styles, but when you _really are_ just trying to style some content that came from a rich-text editor in a CMS or a markdown file, it can be surprising and unintuitive.
10 |
11 | We get lots of complaints about it actually, with people regularly asking us things like:
12 |
13 | > Why is Tailwind removing the default styles on my `h1` elements? How do I disable this? What do you mean I lose all the other base styles too?
14 | > We hear you, but we're not convinced that simply disabling our base styles is what you really want. You don't want to have to remove annoying margins every time you use a `p` element in a piece of your dashboard UI. And I doubt you really want your blog posts to use the user-agent styles either — you want them to look _awesome_, not awful.
15 |
16 | The `@tailwindcss/typography` plugin is our attempt to give you what you _actually_ want, without any of the downsides of doing something stupid like disabling our base styles.
17 |
18 | It adds a new `prose` class that you can slap on any block of vanilla HTML content and turn it into a beautiful, well-formatted document:
19 |
20 | ```html
21 |
24 | For years parents have espoused the health benefits of eating garlic bread
25 | with cheese to their children, with the food earning such an iconic status
26 | in our culture that kids will often dress up as warm, cheesy loaf for
27 | Halloween.
28 |
30 | But a recent study shows that the celebrated appetizer may be linked to a
31 | series of rabies cases springing up around the country.
32 | ` tag unless there are multiple paragraphs in the list item. That means I have to worry about styling that annoying situation too.
137 |
138 | - **For example, here's another nested list.**
139 |
140 | But this time with a second paragraph.
141 |
142 | - These list items won't have ` ` tags
143 | - Because they are only one line each
144 |
145 | - **But in this second top-level list item, they will.**
146 |
147 | This is especially annoying because of the spacing on this paragraph.
148 |
149 | - As you can see here, because I've added a second line, this list item now has a ` ` tag.
150 |
151 | This is the second line I'm talking about by the way.
152 |
153 | - Finally here's another list item so it's more like a list.
154 |
155 | - A closing list item, but with no nested list, because why not?
156 |
157 | And finally a sentence to close off this section.
158 |
159 | ## There are other elements we need to style
160 |
161 | I almost forgot to mention links, like [this link to the Tailwind CSS website](https://tailwindcss.com). We almost made them blue but that's so yesterday, so we went with dark gray, feels edgier.
162 |
163 | We even included table styles, check it out:
164 |
165 | | Wrestler | Origin | Finisher |
166 | | ----------------------- | ------------ | ------------------ |
167 | | Bret "The Hitman" Hart | Calgary, AB | Sharpshooter |
168 | | Stone Cold Steve Austin | Austin, TX | Stone Cold Stunner |
169 | | Randy Savage | Sarasota, FL | Elbow Drop |
170 | | Vader | Boulder, CO | Vader Bomb |
171 | | Razor Ramon | Chuluota, FL | Razor's Edge |
172 |
173 | We also need to make sure inline code looks good, like if I wanted to talk about `` elements or tell you the good news about `@tailwindcss/typography`.
174 |
175 | ### Sometimes I even use `code` in headings
176 |
177 | Even though it's probably a bad idea, and historically I've had a hard time making it look good. This _"wrap the code blocks in backticks"_ trick works pretty well though really.
178 |
179 | Another thing I've done in the past is put a `code` tag inside of a link, like if I wanted to tell you about the [`tailwindcss/docs`](https://github.com/tailwindcss/docs) repository. I don't love that there is an underline below the backticks but it is absolutely not worth the madness it would require to avoid it.
180 |
181 | #### We haven't used an `h4` yet
182 |
183 | But now we have. Please don't use `h5` or `h6` in your content, Medium only supports two heading levels for a reason, you animals. I honestly considered using a `before` pseudo-element to scream at you if you use an `h5` or `h6`.
184 |
185 | We don't style them at all out of the box because `h4` elements are already so small that they are the same size as the body copy. What are we supposed to do with an `h5`, make it _smaller_ than the body copy? No thanks.
186 |
187 | ### We still need to think about stacked headings though.
188 |
189 | #### Let's make sure we don't screw that up with `h4` elements, either.
190 |
191 | Phew, with any luck we have styled the headings above this text and they look pretty good.
192 |
193 | Let's add a closing paragraph here so things end with a decently sized block of text. I can't explain why I want things to end that way but I have to assume it's because I think things will look weird or unbalanced if there is a heading too close to the end of the document.
194 |
195 | What I've written here is probably long enough, but adding this final sentence can't hurt.
196 |
197 | ## GitHub Flavored Markdown
198 |
199 | I've also added support for GitHub Flavored Mardown using `remark-gfm`.
200 |
201 | With `remark-gfm`, we get a few extra features in our markdown. Example: autolink literals.
202 |
203 | A link like www.example.com or https://example.com would automatically be converted into an `a` tag.
204 |
205 | This works for email links too: contact@example.com.
206 |
--------------------------------------------------------------------------------
Garlic bread with cheese: What the science tells us
23 | Garlic bread with cheese: What the science tells us
23 | Garlic bread with cheese: What the science tells us
23 |