Skip to content

Commit 144d294

Browse files
committed
📖 DOC: Updated documentation
1 parent 519a868 commit 144d294

File tree

1 file changed

+90
-2
lines changed

1 file changed

+90
-2
lines changed

readme.md

Lines changed: 90 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
- **TypeScript Blog**: Set up a blog with TypeScript in seconds
2121
- **Tailwind CSS**: Supports Tailwind CSS out of the box for TypeScript ATM
2222
- **Unopinionated**: No opinionated styling or UI. You can build your own UI on top of it
23+
- **Category**: Create different post category with category individual pages. Read more [here](#create-categories)
2324
- **Post**: Create a new blog post by creating a new markdown file in the `posts` directory
2425
- **Route**: Automatically create routes for your blog posts based on the markdown file name
2526
- **SEO**: Use your blog post frontmatter to add SEO tags to your blog post
@@ -28,6 +29,10 @@
2829

2930
<br>
3031

32+
[*Live demo of the blog*](https://create-nextjs-blog.vercel.app/blog)
33+
34+
<br>
35+
3136
<img src="./assets/suitcase.png" width="10%" />
3237

3338
## Installation
@@ -72,12 +77,93 @@ cnb --withTailwind
7277
cnb --javascript
7378
```
7479

75-
>Once the blog is set up, run the Next.js app and navigate to [`http://localhost:3000/blog`](http://localhost:3000/blog) to see your blog. To check demo
80+
>Once the blog is set up, run the Next.js app and navigate to [`http://localhost:3000/blog`](http://localhost:3000/blog) to see your blog. I highly recommend using [Vercel](https://vercel.com) to deploy your blog.
81+
82+
## Demo
83+
84+
![demo](assets/demo.gif)
7685

7786
<br>
7887

7988
<img src="./assets/workflow.png" width="10%" />
8089

90+
## Create a new blog post
91+
92+
1. Create a new markdown file in the `posts` directory. For example, if you want to create a new blog post named `my-first-blog-post`, create a new file named `my-first-blog-post.md`.
93+
2. Add the frontmatter to the markdown file. The frontmatter is the metadata of your blog post. It contains the title, description, tags (SEO keywords), category, publish date, modified date, cover image of your blog post. Here is an example of the frontmatter.
94+
95+
```mdx
96+
---
97+
title: Hello World
98+
description: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor'
99+
tag:
100+
- example
101+
- demo
102+
category:
103+
- test
104+
publishedDate: 2022-12-28T16:27:05.876Z
105+
lastModifiedDate: 2022-12-28T16:27:05.876Z
106+
cover: ''
107+
---
108+
```
109+
110+
3. Add the content of your blog post to the markdown file. You can use React components in your markdown file. Click [here](#inject-markdown-components) if you want to learn how to inject React components in your blog. The following is an example of a markdown blog post that uses a React component.
111+
112+
```md
113+
## Paragraph
114+
115+
Lorem ipsum dolor sit amet, *consectetur* adipiscing elit, sed do eiusmod tempor **incididunt** ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea ***commodo*** consequat.
116+
117+
<Note>
118+
This is a sample note
119+
</Note>
120+
```
121+
122+
4. If you want to locally look at the blog post in your browser, run the following command once in your terminal.
123+
124+
```sh
125+
npm run generate-data
126+
```
127+
128+
5. Now navigate to [`http://localhost:3000/blog/my-first-blog-post`](http://localhost:3000/blog/my-first-blog-post) to see your blog post.
129+
6. Once you are done, push the markdown file to your GitHub repository. Your blog post will be automatically deployed to your blog site.
130+
131+
>You only need to run the command in step #4 once. You don't have to run it again after updating the file.
132+
133+
## Create categories
134+
135+
***Add a new category***
136+
137+
To add a new category, go to the `data/categories.json` file and create an object with your category. For example, if you want to add a `life` category, add an object with a single `name` key inside they JSON array.
138+
139+
```json
140+
[
141+
{
142+
"name": "life"
143+
}
144+
]
145+
```
146+
147+
***Use category in your blog file***
148+
149+
To use this newly created `life` category in your blog file, just add it as a value to the category in your markdown file frontmatter. For example, if you want to add a `life` category to your blog post, here is how you can do it.
150+
151+
```mdx
152+
---
153+
title: 'My first blog post'
154+
description: 'This is my first blog post'
155+
category:
156+
- life
157+
---
158+
```
159+
160+
***Category page***
161+
162+
- Your blog site has a category page. To access this page, navigate to [`http://localhost:3000/blog/category`](http://localhost:3000/blog/category) to see all the different blog categories you have.
163+
- To access a specific category page, navigate to [`http://localhost:3000/blog/category/guide`](http://localhost:3000/blog/category/guide) to see all the blog posts with the `guide` category.
164+
- You can also click on the category name in the blog post card at [`http://localhost:3000/blog`](http://localhost:3000/blog) to navigate to the category page.
165+
- Here is the live [demo](https://create-nextjs-blog.vercel.app/blog/category) of the category page. Click on any category, all the posts in that category will be displayed. If you want to see all the posts, navigate to [`https://create-nextjs-blog.vercel.app/blog`](https://create-nextjs-blog.vercel.app/blog).
166+
81167
## Inject Markdown Components
82168

83169
***Create a component***
@@ -127,7 +213,9 @@ export default MarkdownComponents;
127213
<Note>You can use this component in your markdown files.</Note>
128214
```
129215

130-
[***Here is an example of how you can use this component in your markdown files.***](https://github.com/msaaddev/create-nextjs-blog/tree/main/examples/markdown-blog-javascript/components/markdown)
216+
***Live demo***
217+
218+
You can see a live demo of this component [here](https://create-nextjs-blog.vercel.app/blog/hello-world). You can find its source code [here](https://github.com/msaaddev/create-nextjs-blog/tree/main/examples/markdown-blog-javascript/components/markdown).
131219

132220
## Contributing Guidelines
133221

0 commit comments

Comments
 (0)