@jet-w/astro-blog 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -1
- package/src/config/footer.ts +58 -0
- package/src/config/i18n.ts +485 -0
- package/src/config/index.ts +42 -0
- package/src/config/menu.ts +32 -0
- package/src/config/sidebar.ts +142 -0
- package/src/config/site.ts +61 -0
- package/src/config/social.ts +29 -0
- package/src/plugins/remark-containers.mjs +235 -79
- package/src/types/index.ts +80 -0
- package/src/utils/i18n.ts +418 -0
- package/src/utils/sidebar.ts +503 -0
- package/src/utils/useI18n.ts +155 -0
- package/templates/default/content/posts/blog_docs_en/01.get-started/03-create-post.md +124 -8
- package/templates/default/content/posts/blog_docs_zh/01.get-started/03-create-post.md +124 -9
- package/templates/default/package-lock.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: Create
|
|
3
|
-
description:
|
|
2
|
+
title: Create Blog & First Post
|
|
3
|
+
description: Use CLI to create a blog project and write your first article
|
|
4
4
|
pubDate: 2025-01-01
|
|
5
5
|
author: jet-w
|
|
6
6
|
categories:
|
|
@@ -8,13 +8,114 @@ categories:
|
|
|
8
8
|
tags:
|
|
9
9
|
- Getting Started
|
|
10
10
|
- Writing
|
|
11
|
+
- CLI
|
|
11
12
|
---
|
|
12
13
|
|
|
13
|
-
# Create
|
|
14
|
+
# Create Blog & First Post
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
This guide will walk you through creating a blog project using the CLI tool and writing your first post.
|
|
16
17
|
|
|
17
|
-
##
|
|
18
|
+
## Create a Blog Project with CLI
|
|
19
|
+
|
|
20
|
+
### Quick Start
|
|
21
|
+
|
|
22
|
+
Use `@jet-w/astro-blog-cli` to quickly create a new blog project:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npx @jet-w/astro-blog-cli my-blog
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Interactive Mode
|
|
29
|
+
|
|
30
|
+
Run without options to enter interactive mode, which guides you through the configuration:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npx @jet-w/astro-blog-cli
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
You will be prompted for:
|
|
37
|
+
- Project name
|
|
38
|
+
- Blog title (English & Chinese)
|
|
39
|
+
- Blog description (English & Chinese)
|
|
40
|
+
- Author name
|
|
41
|
+
- Author email
|
|
42
|
+
- Site URL
|
|
43
|
+
- Template selection
|
|
44
|
+
|
|
45
|
+
### Non-Interactive Mode
|
|
46
|
+
|
|
47
|
+
Use `-y` flag to skip prompts and use defaults or provided options:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# Quick create with defaults
|
|
51
|
+
npx @jet-w/astro-blog-cli my-blog -y
|
|
52
|
+
|
|
53
|
+
# With custom options
|
|
54
|
+
npx @jet-w/astro-blog-cli my-blog -y \
|
|
55
|
+
--title "My Awesome Blog" \
|
|
56
|
+
--title-zh "我的博客" \
|
|
57
|
+
--description "A blog about tech" \
|
|
58
|
+
--description-zh "一个关于技术的博客" \
|
|
59
|
+
--author "John Doe" \
|
|
60
|
+
--email "john@example.com" \
|
|
61
|
+
--site "https://myblog.com"
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### CLI Command Options
|
|
65
|
+
|
|
66
|
+
| Option | Description | Default |
|
|
67
|
+
|--------|-------------|---------|
|
|
68
|
+
| `-t, --template <template>` | Template to use | `default` |
|
|
69
|
+
| `--title <title>` | Blog title (English) | `My Astro Blog` |
|
|
70
|
+
| `--title-zh <titleZh>` | Blog title (Chinese) | `我的Astro博客` |
|
|
71
|
+
| `--description <description>` | Blog description (English) | - |
|
|
72
|
+
| `--description-zh <descriptionZh>` | Blog description (Chinese) | - |
|
|
73
|
+
| `--author <author>` | Author name | `Author` |
|
|
74
|
+
| `--email <email>` | Author email | `email@example.com` |
|
|
75
|
+
| `--site <site>` | Site URL | `https://example.com` |
|
|
76
|
+
| `--lang <lang>` | CLI language (`en`/`zh`) | Auto-detect |
|
|
77
|
+
| `-y, --yes` | Skip prompts, use defaults | - |
|
|
78
|
+
| `-f, --force` | Overwrite existing directory | - |
|
|
79
|
+
|
|
80
|
+
### Start Development Server
|
|
81
|
+
|
|
82
|
+
After project creation:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
cd my-blog
|
|
86
|
+
npm install
|
|
87
|
+
npm run dev
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Your blog will be running at `http://localhost:4321`.
|
|
91
|
+
|
|
92
|
+
### Project Structure
|
|
93
|
+
|
|
94
|
+
The created project includes:
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
my-blog/
|
|
98
|
+
├── astro.config.mjs # Astro configuration
|
|
99
|
+
├── package.json
|
|
100
|
+
├── src/
|
|
101
|
+
│ ├── config/
|
|
102
|
+
│ │ ├── site.ts # Main site configuration
|
|
103
|
+
│ │ └── locales/ # i18n configurations
|
|
104
|
+
│ │ ├── en/ # English locale
|
|
105
|
+
│ │ └── zh-CN/ # Chinese locale
|
|
106
|
+
│ └── content.config.ts # Content collections schema
|
|
107
|
+
├── content/
|
|
108
|
+
│ ├── posts/ # Blog posts (Markdown/MDX)
|
|
109
|
+
│ ├── pages/ # Static pages
|
|
110
|
+
│ └── slides/ # Presentation slides
|
|
111
|
+
└── public/ # Static assets
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Create Your First Post
|
|
115
|
+
|
|
116
|
+
Now let's write your first blog post!
|
|
117
|
+
|
|
118
|
+
### Where Posts Live
|
|
18
119
|
|
|
19
120
|
All blog posts go in the `content/posts/` directory:
|
|
20
121
|
|
|
@@ -27,7 +128,7 @@ content/
|
|
|
27
128
|
└── tutorial.md
|
|
28
129
|
```
|
|
29
130
|
|
|
30
|
-
|
|
131
|
+
### Create a New Post
|
|
31
132
|
|
|
32
133
|
Create a file called `hello-world.md` in `content/posts/`:
|
|
33
134
|
|
|
@@ -68,7 +169,7 @@ Stay tuned for more posts about:
|
|
|
68
169
|
Thanks for reading!
|
|
69
170
|
```
|
|
70
171
|
|
|
71
|
-
|
|
172
|
+
### View Your Post
|
|
72
173
|
|
|
73
174
|
Save the file and visit:
|
|
74
175
|
|
|
@@ -98,6 +199,7 @@ star: false # true = featured post
|
|
|
98
199
|
```
|
|
99
200
|
|
|
100
201
|
::: tip Required vs Optional
|
|
202
|
+
|
|
101
203
|
Only `title` is required. All other fields are optional but recommended for better organization and SEO.
|
|
102
204
|
:::
|
|
103
205
|
|
|
@@ -171,6 +273,20 @@ Then use:
|
|
|
171
273
|

|
|
172
274
|
```
|
|
173
275
|
|
|
276
|
+
## Blog Features Overview
|
|
277
|
+
|
|
278
|
+
Blogs created with this theme support the following features:
|
|
279
|
+
|
|
280
|
+
- **Multi-language support (i18n)**: Switch between English and Chinese
|
|
281
|
+
- **Markdown & MDX**: Powerful content authoring capabilities
|
|
282
|
+
- **Code syntax highlighting**: Built-in syntax highlighting support
|
|
283
|
+
- **Mermaid diagrams**: Flowcharts, sequence diagrams, and more
|
|
284
|
+
- **LaTeX math equations**: Math formula rendering support
|
|
285
|
+
- **Custom containers**: tip, warning, danger, and other callout blocks
|
|
286
|
+
- **RSS feed**: Auto-generated RSS feed
|
|
287
|
+
- **Tailwind CSS**: Modern styling support
|
|
288
|
+
- **Vue.js components**: Use Vue components in MDX
|
|
289
|
+
|
|
174
290
|
---
|
|
175
291
|
|
|
176
|
-
Congratulations on your first post! Next, let's understand the [project structure](./04-structure).
|
|
292
|
+
Congratulations on creating your blog and publishing your first post! Next, let's understand the [project structure](./04-structure).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
|
-
title:
|
|
3
|
-
description:
|
|
2
|
+
title: 创建博客与文章
|
|
3
|
+
description: 使用 CLI 创建博客项目并编写你的第一篇文章
|
|
4
4
|
pubDate: 2025-01-01
|
|
5
5
|
author: jet-w
|
|
6
6
|
categories:
|
|
@@ -8,13 +8,114 @@ categories:
|
|
|
8
8
|
tags:
|
|
9
9
|
- 入门
|
|
10
10
|
- 写作
|
|
11
|
+
- CLI
|
|
11
12
|
---
|
|
12
13
|
|
|
13
|
-
#
|
|
14
|
+
# 创建博客与文章
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
本文将指导你使用 CLI 工具快速创建博客项目,并编写发布你的第一篇文章。
|
|
16
17
|
|
|
17
|
-
##
|
|
18
|
+
## 使用 CLI 创建博客项目
|
|
19
|
+
|
|
20
|
+
### 快速开始
|
|
21
|
+
|
|
22
|
+
使用 `@jet-w/astro-blog-cli` 可以快速创建一个新的博客项目:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npx @jet-w/astro-blog-cli my-blog
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### 交互模式
|
|
29
|
+
|
|
30
|
+
不带参数运行命令进入交互模式,系统会逐步引导你配置:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npx @jet-w/astro-blog-cli
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
你将被提示输入:
|
|
37
|
+
- 项目名称
|
|
38
|
+
- 博客标题(中英文)
|
|
39
|
+
- 博客描述(中英文)
|
|
40
|
+
- 作者名称
|
|
41
|
+
- 作者邮箱
|
|
42
|
+
- 网站 URL
|
|
43
|
+
- 模板选择
|
|
44
|
+
|
|
45
|
+
### 非交互模式
|
|
46
|
+
|
|
47
|
+
使用 `-y` 参数跳过提示,直接使用默认值或指定的选项:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# 使用默认配置快速创建
|
|
51
|
+
npx @jet-w/astro-blog-cli my-blog -y
|
|
52
|
+
|
|
53
|
+
# 指定自定义选项
|
|
54
|
+
npx @jet-w/astro-blog-cli my-blog -y \
|
|
55
|
+
--title "我的技术博客" \
|
|
56
|
+
--title-zh "我的技术博客" \
|
|
57
|
+
--description "A blog about tech" \
|
|
58
|
+
--description-zh "一个关于技术的博客" \
|
|
59
|
+
--author "张三" \
|
|
60
|
+
--email "zhangsan@example.com" \
|
|
61
|
+
--site "https://myblog.com"
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### CLI 命令选项
|
|
65
|
+
|
|
66
|
+
| 选项 | 描述 | 默认值 |
|
|
67
|
+
|------|------|--------|
|
|
68
|
+
| `-t, --template <template>` | 使用的模板 | `default` |
|
|
69
|
+
| `--title <title>` | 博客标题(英文) | `My Astro Blog` |
|
|
70
|
+
| `--title-zh <titleZh>` | 博客标题(中文) | `我的Astro博客` |
|
|
71
|
+
| `--description <description>` | 博客描述(英文) | - |
|
|
72
|
+
| `--description-zh <descriptionZh>` | 博客描述(中文) | - |
|
|
73
|
+
| `--author <author>` | 作者名称 | `Author` |
|
|
74
|
+
| `--email <email>` | 作者邮箱 | `email@example.com` |
|
|
75
|
+
| `--site <site>` | 网站 URL | `https://example.com` |
|
|
76
|
+
| `--lang <lang>` | CLI 语言(`en`/`zh`) | 自动检测 |
|
|
77
|
+
| `-y, --yes` | 跳过提示,使用默认值 | - |
|
|
78
|
+
| `-f, --force` | 覆盖已存在的目录 | - |
|
|
79
|
+
|
|
80
|
+
### 启动开发服务器
|
|
81
|
+
|
|
82
|
+
项目创建完成后:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
cd my-blog
|
|
86
|
+
npm install
|
|
87
|
+
npm run dev
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
博客将在 `http://localhost:4321` 运行。
|
|
91
|
+
|
|
92
|
+
### 项目结构
|
|
93
|
+
|
|
94
|
+
创建的项目包含以下结构:
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
my-blog/
|
|
98
|
+
├── astro.config.mjs # Astro 配置文件
|
|
99
|
+
├── package.json
|
|
100
|
+
├── src/
|
|
101
|
+
│ ├── config/
|
|
102
|
+
│ │ ├── site.ts # 网站主配置
|
|
103
|
+
│ │ └── locales/ # i18n 配置
|
|
104
|
+
│ │ ├── en/ # 英文语言包
|
|
105
|
+
│ │ └── zh-CN/ # 中文语言包
|
|
106
|
+
│ └── content.config.ts # 内容集合配置
|
|
107
|
+
├── content/
|
|
108
|
+
│ ├── posts/ # 博客文章(Markdown/MDX)
|
|
109
|
+
│ ├── pages/ # 静态页面
|
|
110
|
+
│ └── slides/ # 演示幻灯片
|
|
111
|
+
└── public/ # 静态资源
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## 创建第一篇文章
|
|
115
|
+
|
|
116
|
+
现在让我们来写你的第一篇博客文章!
|
|
117
|
+
|
|
118
|
+
### 文章存放位置
|
|
18
119
|
|
|
19
120
|
所有博客文章都放在 `content/posts/` 目录:
|
|
20
121
|
|
|
@@ -27,7 +128,7 @@ content/
|
|
|
27
128
|
└── tutorial.md
|
|
28
129
|
```
|
|
29
130
|
|
|
30
|
-
|
|
131
|
+
### 创建新文章
|
|
31
132
|
|
|
32
133
|
在 `content/posts/` 中创建一个名为 `hello-world.md` 的文件:
|
|
33
134
|
|
|
@@ -68,7 +169,7 @@ categories:
|
|
|
68
169
|
感谢阅读!
|
|
69
170
|
```
|
|
70
171
|
|
|
71
|
-
|
|
172
|
+
### 查看你的文章
|
|
72
173
|
|
|
73
174
|
保存文件后访问:
|
|
74
175
|
|
|
@@ -101,7 +202,7 @@ star: false # true = 精选文章
|
|
|
101
202
|
只有 `title` 是必填的。其他字段都是可选的,但建议填写以便更好地组织和优化 SEO。
|
|
102
203
|
:::
|
|
103
204
|
|
|
104
|
-
##
|
|
205
|
+
## 使用子目录组织文章
|
|
105
206
|
|
|
106
207
|
使用子目录来组织相关文章:
|
|
107
208
|
|
|
@@ -171,6 +272,20 @@ public/
|
|
|
171
272
|

|
|
172
273
|
```
|
|
173
274
|
|
|
275
|
+
## 博客特性一览
|
|
276
|
+
|
|
277
|
+
使用本主题创建的博客支持以下特性:
|
|
278
|
+
|
|
279
|
+
- **多语言支持(i18n)**:中英文双语切换
|
|
280
|
+
- **Markdown & MDX**:强大的内容编写能力
|
|
281
|
+
- **代码高亮**:内置语法高亮支持
|
|
282
|
+
- **Mermaid 图表**:流程图、时序图等
|
|
283
|
+
- **LaTeX 数学公式**:支持数学公式渲染
|
|
284
|
+
- **自定义容器**:tip、warning、danger 等提示块
|
|
285
|
+
- **RSS 订阅**:自动生成 RSS feed
|
|
286
|
+
- **Tailwind CSS**:现代化的样式支持
|
|
287
|
+
- **Vue.js 组件**:可在 MDX 中使用 Vue 组件
|
|
288
|
+
|
|
174
289
|
---
|
|
175
290
|
|
|
176
|
-
|
|
291
|
+
恭喜你创建了博客并发布了第一篇文章!接下来,让我们了解 [项目结构](./04-structure)。
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"@astrojs/rss": "^4.0.14",
|
|
13
13
|
"@astrojs/tailwind": "^5.1.3",
|
|
14
14
|
"@astrojs/vue": "^5.0.6",
|
|
15
|
-
"@jet-w/astro-blog": "
|
|
15
|
+
"@jet-w/astro-blog": "^0.2.1",
|
|
16
16
|
"@tailwindcss/typography": "^0.5.15",
|
|
17
17
|
"astro": "^5.14.1",
|
|
18
18
|
"echarts": "^6.0.0",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"../..": {
|
|
31
31
|
"name": "@jet-w/astro-blog",
|
|
32
|
-
"version": "0.
|
|
32
|
+
"version": "0.2.3",
|
|
33
33
|
"license": "MIT",
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@tailwindcss/typography": "^0.5.15",
|