@jet-w/astro-blog 0.1.5 → 0.2.0
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/dist/chunk-ATRISB7B.js +206 -0
- package/dist/chunk-HVQKQN6B.js +145 -0
- package/dist/config/index.d.ts +3 -47
- package/dist/config/index.js +18 -2
- package/dist/i18n-5H4W145i.d.ts +202 -0
- package/dist/index.d.ts +186 -7
- package/dist/index.js +238 -3
- package/dist/integration.d.ts +9 -1
- package/dist/integration.js +2 -1
- package/dist/{sidebar-DNdiCKBw.d.ts → sidebar-Da-W_4Lr.d.ts} +1 -1
- package/dist/utils/sidebar.d.ts +1 -1
- package/package.json +4 -3
- package/src/components/layout/Footer.astro +36 -20
- package/src/components/layout/Header.astro +69 -15
- package/src/components/layout/Sidebar.astro +27 -15
- package/src/components/ui/LanguageSwitcher.vue +183 -0
- package/src/layouts/BaseLayout.astro +77 -52
- package/src/layouts/PageLayout.astro +22 -27
- package/src/layouts/SlidesLayout.astro +14 -2
- package/src/pages/rss.xml.ts +18 -6
- package/templates/default/astro.config.mjs +22 -2
- package/templates/default/content/posts/blog_docs/12-i18n.md +355 -0
- package/templates/default/content/posts/blog_docs/README.md +1 -0
- package/templates/default/content/posts/blog_docs_en/README.md +78 -0
- package/templates/default/content/posts/blog_docs_en/config/01-site.md +208 -0
- package/templates/default/content/posts/blog_docs_en/config/02-sidebar.md +240 -0
- package/templates/default/content/posts/blog_docs_en/config/03-i18n.md +285 -0
- package/templates/default/content/posts/blog_docs_en/config/README.md +85 -0
- package/templates/default/content/posts/blog_docs_en/get-started/01-intro.md +81 -0
- package/templates/default/content/posts/blog_docs_en/get-started/02-install.md +137 -0
- package/templates/default/content/posts/blog_docs_en/get-started/03-create-post.md +176 -0
- package/templates/default/content/posts/blog_docs_en/get-started/04-structure.md +173 -0
- package/templates/default/content/posts/blog_docs_en/get-started/05-deploy.md +197 -0
- package/templates/default/content/posts/blog_docs_en/get-started/README.md +52 -0
- package/templates/default/content/posts/blog_docs_en/guide/README.md +59 -0
- package/templates/default/content/posts/blog_docs_en/guide/features/01-mermaid.md +194 -0
- package/templates/default/content/posts/blog_docs_en/guide/features/02-latex.md +233 -0
- package/templates/default/content/posts/blog_docs_en/guide/features/03-video.md +184 -0
- package/templates/default/content/posts/blog_docs_en/guide/features/04-icons.md +227 -0
- package/templates/default/content/posts/blog_docs_en/guide/features/README.md +51 -0
- package/templates/default/content/posts/blog_docs_en/guide/markdown/02-containers.md +226 -0
- package/templates/default/content/posts/blog_docs_en/guide/markdown/03-code-blocks.md +206 -0
- package/templates/default/content/posts/blog_docs_en/guide/markdown/README.md +194 -0
- package/templates/default/package-lock.json +9667 -0
- package/templates/default/package.json +1 -1
- package/templates/default/src/config/footer.ts +14 -11
- package/templates/default/src/config/locales/en/footer.ts +17 -0
- package/templates/default/src/config/locales/en/index.ts +16 -0
- package/templates/default/src/config/locales/en/menu.ts +12 -0
- package/templates/default/src/config/locales/en/sidebar.ts +18 -0
- package/templates/default/src/config/locales/en/site.ts +7 -0
- package/templates/default/src/config/locales/index.ts +7 -0
- package/templates/default/src/config/locales/zh-CN/footer.ts +17 -0
- package/templates/default/src/config/locales/zh-CN/index.ts +16 -0
- package/templates/default/src/config/locales/zh-CN/menu.ts +12 -0
- package/templates/default/src/config/locales/zh-CN/sidebar.ts +18 -0
- package/templates/default/src/config/locales/zh-CN/site.ts +7 -0
- package/templates/default/src/config/sidebar.ts +10 -12
- package/templates/default/src/env.d.ts +7 -0
- package/dist/chunk-MQXPSOYB.js +0 -124
- /package/dist/{chunk-GYLSY3OJ.js → chunk-AZHCNNAC.js} +0 -0
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Sidebar Configuration
|
|
3
|
+
description: Configure navigation trees and document organization
|
|
4
|
+
pubDate: 2025-01-01
|
|
5
|
+
author: Astro Blog
|
|
6
|
+
categories:
|
|
7
|
+
- Documentation
|
|
8
|
+
tags:
|
|
9
|
+
- Configuration
|
|
10
|
+
- Sidebar
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Sidebar Configuration
|
|
14
|
+
|
|
15
|
+
The sidebar provides navigation and document organization for your blog.
|
|
16
|
+
|
|
17
|
+
## Basic Configuration
|
|
18
|
+
|
|
19
|
+
Edit `src/config/sidebar.ts`:
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
export const sidebarConfig = {
|
|
23
|
+
enabled: true,
|
|
24
|
+
showSearch: true,
|
|
25
|
+
showRecentPosts: true,
|
|
26
|
+
recentPostsCount: 5,
|
|
27
|
+
showPopularTags: true,
|
|
28
|
+
popularTagsCount: 8,
|
|
29
|
+
showArchives: true,
|
|
30
|
+
archivesCount: 6,
|
|
31
|
+
groups: [],
|
|
32
|
+
};
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Configuration Options
|
|
36
|
+
|
|
37
|
+
| Option | Type | Default | Description |
|
|
38
|
+
|--------|------|---------|-------------|
|
|
39
|
+
| `enabled` | boolean | `true` | Show/hide sidebar |
|
|
40
|
+
| `showSearch` | boolean | `true` | Show search box |
|
|
41
|
+
| `showRecentPosts` | boolean | `true` | Show recent posts |
|
|
42
|
+
| `recentPostsCount` | number | `5` | Number of recent posts |
|
|
43
|
+
| `showPopularTags` | boolean | `true` | Show tag cloud |
|
|
44
|
+
| `popularTagsCount` | number | `8` | Number of tags |
|
|
45
|
+
| `showArchives` | boolean | `true` | Show archives |
|
|
46
|
+
| `archivesCount` | number | `6` | Number of archive months |
|
|
47
|
+
| `groups` | array | `[]` | Document tree groups |
|
|
48
|
+
|
|
49
|
+
## Document Tree Groups
|
|
50
|
+
|
|
51
|
+
Groups create organized navigation for specific sections.
|
|
52
|
+
|
|
53
|
+
### Auto-Scan Groups
|
|
54
|
+
|
|
55
|
+
Automatically generate navigation from a folder:
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
// src/config/locales/en/sidebar.ts
|
|
59
|
+
export const sidebar = {
|
|
60
|
+
groups: [
|
|
61
|
+
{
|
|
62
|
+
type: 'scan',
|
|
63
|
+
title: 'Documentation',
|
|
64
|
+
icon: 'ri:book-open-line',
|
|
65
|
+
scanPath: 'blog_docs_en',
|
|
66
|
+
collapsed: false,
|
|
67
|
+
showForPaths: ['/posts/blog_docs_en/**'],
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
};
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
| Option | Description |
|
|
74
|
+
|--------|-------------|
|
|
75
|
+
| `type` | `'scan'` for auto-scan |
|
|
76
|
+
| `title` | Group heading |
|
|
77
|
+
| `icon` | Remix icon name |
|
|
78
|
+
| `scanPath` | Folder to scan in `content/posts/` |
|
|
79
|
+
| `collapsed` | Start collapsed |
|
|
80
|
+
| `showForPaths` | Only show on matching URLs |
|
|
81
|
+
|
|
82
|
+
### Manual Groups
|
|
83
|
+
|
|
84
|
+
Define navigation manually:
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
{
|
|
88
|
+
type: 'manual',
|
|
89
|
+
title: 'Resources',
|
|
90
|
+
icon: 'ri:links-line',
|
|
91
|
+
items: [
|
|
92
|
+
{ title: 'API Reference', slug: 'api-reference' },
|
|
93
|
+
{ title: 'Examples', link: 'https://examples.com' },
|
|
94
|
+
],
|
|
95
|
+
showForPaths: ['/posts/api/**'],
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Path Matching
|
|
100
|
+
|
|
101
|
+
Control when groups appear with `showForPaths`:
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
showForPaths: [
|
|
105
|
+
'/posts/docs/**', // All docs pages
|
|
106
|
+
'/posts/tutorials/*', // Direct children only
|
|
107
|
+
'/about', // Exact match
|
|
108
|
+
]
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Pattern Syntax
|
|
112
|
+
|
|
113
|
+
| Pattern | Matches |
|
|
114
|
+
|---------|---------|
|
|
115
|
+
| `/posts/docs` | Exact path |
|
|
116
|
+
| `/posts/docs/*` | Direct children |
|
|
117
|
+
| `/posts/docs/**` | All descendants |
|
|
118
|
+
|
|
119
|
+
## Per-Language Sidebar
|
|
120
|
+
|
|
121
|
+
Configure different sidebars for each language:
|
|
122
|
+
|
|
123
|
+
```typescript
|
|
124
|
+
// src/config/locales/en/sidebar.ts
|
|
125
|
+
export const sidebar = {
|
|
126
|
+
groups: [
|
|
127
|
+
{
|
|
128
|
+
type: 'scan',
|
|
129
|
+
title: 'Documentation', // English
|
|
130
|
+
scanPath: 'blog_docs_en',
|
|
131
|
+
showForPaths: ['/posts/blog_docs_en/**'],
|
|
132
|
+
},
|
|
133
|
+
],
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
// src/config/locales/zh-CN/sidebar.ts
|
|
137
|
+
export const sidebar = {
|
|
138
|
+
groups: [
|
|
139
|
+
{
|
|
140
|
+
type: 'scan',
|
|
141
|
+
title: '文档', // Chinese
|
|
142
|
+
scanPath: 'blog_docs',
|
|
143
|
+
showForPaths: ['/zh-CN/posts/blog_docs/**'],
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
};
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Complete Example
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
// src/config/locales/en/sidebar.ts
|
|
153
|
+
export const sidebar = {
|
|
154
|
+
groups: [
|
|
155
|
+
// Documentation section
|
|
156
|
+
{
|
|
157
|
+
type: 'scan',
|
|
158
|
+
title: 'Documentation',
|
|
159
|
+
icon: 'ri:book-open-line',
|
|
160
|
+
scanPath: 'blog_docs_en',
|
|
161
|
+
collapsed: false,
|
|
162
|
+
showForPaths: ['/posts/blog_docs_en/**'],
|
|
163
|
+
},
|
|
164
|
+
// Tutorials section
|
|
165
|
+
{
|
|
166
|
+
type: 'scan',
|
|
167
|
+
title: 'Tutorials',
|
|
168
|
+
icon: 'ri:graduation-cap-line',
|
|
169
|
+
scanPath: 'tutorials',
|
|
170
|
+
collapsed: true,
|
|
171
|
+
showForPaths: ['/posts/tutorials/**'],
|
|
172
|
+
},
|
|
173
|
+
// External resources
|
|
174
|
+
{
|
|
175
|
+
type: 'manual',
|
|
176
|
+
title: 'Resources',
|
|
177
|
+
icon: 'ri:links-line',
|
|
178
|
+
items: [
|
|
179
|
+
{ title: 'Astro Docs', link: 'https://docs.astro.build' },
|
|
180
|
+
{ title: 'Tailwind CSS', link: 'https://tailwindcss.com' },
|
|
181
|
+
],
|
|
182
|
+
},
|
|
183
|
+
],
|
|
184
|
+
};
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## Sidebar Widgets
|
|
188
|
+
|
|
189
|
+
The sidebar also shows:
|
|
190
|
+
|
|
191
|
+
### Recent Posts
|
|
192
|
+
|
|
193
|
+
Shows latest published posts:
|
|
194
|
+
|
|
195
|
+
```typescript
|
|
196
|
+
showRecentPosts: true,
|
|
197
|
+
recentPostsCount: 5,
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Popular Tags
|
|
201
|
+
|
|
202
|
+
Shows most-used tags:
|
|
203
|
+
|
|
204
|
+
```typescript
|
|
205
|
+
showPopularTags: true,
|
|
206
|
+
popularTagsCount: 8,
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Archives
|
|
210
|
+
|
|
211
|
+
Shows posts by month:
|
|
212
|
+
|
|
213
|
+
```typescript
|
|
214
|
+
showArchives: true,
|
|
215
|
+
archivesCount: 6,
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## Hiding the Sidebar
|
|
219
|
+
|
|
220
|
+
Disable sidebar for specific pages in frontmatter:
|
|
221
|
+
|
|
222
|
+
```yaml
|
|
223
|
+
---
|
|
224
|
+
title: Full Width Page
|
|
225
|
+
showSidebar: false
|
|
226
|
+
---
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
Or globally:
|
|
230
|
+
|
|
231
|
+
```typescript
|
|
232
|
+
export const sidebarConfig = {
|
|
233
|
+
enabled: false,
|
|
234
|
+
// ...
|
|
235
|
+
};
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
Next: [Multi-language Support](./03-i18n)
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Multi-language Support
|
|
3
|
+
description: Add multiple language support to your blog
|
|
4
|
+
pubDate: 2025-01-01
|
|
5
|
+
author: Astro Blog
|
|
6
|
+
categories:
|
|
7
|
+
- Documentation
|
|
8
|
+
tags:
|
|
9
|
+
- Configuration
|
|
10
|
+
- i18n
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Multi-language Support
|
|
14
|
+
|
|
15
|
+
Add support for multiple languages to reach a global audience.
|
|
16
|
+
|
|
17
|
+
## Overview
|
|
18
|
+
|
|
19
|
+
The i18n system provides:
|
|
20
|
+
|
|
21
|
+
- **Multiple languages** - Support any number of languages
|
|
22
|
+
- **URL prefixes** - `/en/posts`, `/zh-CN/posts`
|
|
23
|
+
- **Per-language config** - Different menus, titles, etc.
|
|
24
|
+
- **Language switcher** - Built-in UI component
|
|
25
|
+
- **SEO** - Proper hreflang tags
|
|
26
|
+
|
|
27
|
+
## Basic Setup
|
|
28
|
+
|
|
29
|
+
### 1. Configure Languages
|
|
30
|
+
|
|
31
|
+
In `astro.config.mjs`:
|
|
32
|
+
|
|
33
|
+
```javascript
|
|
34
|
+
import { astroBlog, defineI18nConfig } from '@jet-w/astro-blog';
|
|
35
|
+
import { enConfig } from './src/config/locales/en';
|
|
36
|
+
import { zhCNConfig } from './src/config/locales/zh-CN';
|
|
37
|
+
|
|
38
|
+
const i18nConfig = defineI18nConfig({
|
|
39
|
+
defaultLocale: 'en',
|
|
40
|
+
locales: [
|
|
41
|
+
{ code: 'en', name: 'English', htmlLang: 'en', dateLocale: 'en-US' },
|
|
42
|
+
{ code: 'zh-CN', name: '中文', htmlLang: 'zh-CN', dateLocale: 'zh-CN' },
|
|
43
|
+
],
|
|
44
|
+
routing: {
|
|
45
|
+
prefixDefaultLocale: false,
|
|
46
|
+
},
|
|
47
|
+
localeConfigs: {
|
|
48
|
+
'en': enConfig,
|
|
49
|
+
'zh-CN': zhCNConfig,
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
export default defineConfig({
|
|
54
|
+
integrations: [astroBlog({ i18n: i18nConfig })],
|
|
55
|
+
});
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### 2. Create Locale Configs
|
|
59
|
+
|
|
60
|
+
Create folders for each language:
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
src/config/locales/
|
|
64
|
+
├── en/
|
|
65
|
+
│ ├── index.ts
|
|
66
|
+
│ ├── site.ts
|
|
67
|
+
│ ├── menu.ts
|
|
68
|
+
│ ├── footer.ts
|
|
69
|
+
│ └── sidebar.ts
|
|
70
|
+
└── zh-CN/
|
|
71
|
+
├── index.ts
|
|
72
|
+
├── site.ts
|
|
73
|
+
├── menu.ts
|
|
74
|
+
├── footer.ts
|
|
75
|
+
└── sidebar.ts
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### 3. Configure Each Language
|
|
79
|
+
|
|
80
|
+
**English (`en/index.ts`):**
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
import { site } from './site';
|
|
84
|
+
import { menu } from './menu';
|
|
85
|
+
import { footer } from './footer';
|
|
86
|
+
import { sidebar } from './sidebar';
|
|
87
|
+
|
|
88
|
+
export const enConfig = {
|
|
89
|
+
site,
|
|
90
|
+
menu,
|
|
91
|
+
footer,
|
|
92
|
+
sidebar,
|
|
93
|
+
};
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**English site (`en/site.ts`):**
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
export const site = {
|
|
100
|
+
title: 'My Blog',
|
|
101
|
+
description: 'A blog about technology',
|
|
102
|
+
};
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
**English menu (`en/menu.ts`):**
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
export const menu = [
|
|
109
|
+
{ name: 'Home', href: '/', icon: 'home' },
|
|
110
|
+
{ name: 'Posts', href: '/posts', icon: 'posts' },
|
|
111
|
+
{ name: 'About', href: '/about', icon: 'about' },
|
|
112
|
+
];
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## URL Structure
|
|
116
|
+
|
|
117
|
+
With `prefixDefaultLocale: false`:
|
|
118
|
+
|
|
119
|
+
| Language | URL |
|
|
120
|
+
|----------|-----|
|
|
121
|
+
| English (default) | `/posts` |
|
|
122
|
+
| Chinese | `/zh-CN/posts` |
|
|
123
|
+
|
|
124
|
+
With `prefixDefaultLocale: true`:
|
|
125
|
+
|
|
126
|
+
| Language | URL |
|
|
127
|
+
|----------|-----|
|
|
128
|
+
| English | `/en/posts` |
|
|
129
|
+
| Chinese | `/zh-CN/posts` |
|
|
130
|
+
|
|
131
|
+
## Content Organization
|
|
132
|
+
|
|
133
|
+
### Option 1: Separate Folders
|
|
134
|
+
|
|
135
|
+
Create separate content folders per language:
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
content/posts/
|
|
139
|
+
├── blog_docs_en/ # English docs
|
|
140
|
+
│ └── ...
|
|
141
|
+
└── blog_docs/ # Chinese docs
|
|
142
|
+
└── ...
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Option 2: Same Content
|
|
146
|
+
|
|
147
|
+
Use the same content with language-aware frontmatter:
|
|
148
|
+
|
|
149
|
+
```yaml
|
|
150
|
+
---
|
|
151
|
+
title: Hello World
|
|
152
|
+
lang: en
|
|
153
|
+
---
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Language Switcher
|
|
157
|
+
|
|
158
|
+
The language switcher appears in the header automatically when multiple languages are configured.
|
|
159
|
+
|
|
160
|
+
It shows:
|
|
161
|
+
- Current language flag/name
|
|
162
|
+
- Dropdown with all languages
|
|
163
|
+
- Links to the same page in other languages
|
|
164
|
+
|
|
165
|
+
## Locale Configuration Options
|
|
166
|
+
|
|
167
|
+
### Locale Definition
|
|
168
|
+
|
|
169
|
+
```typescript
|
|
170
|
+
{
|
|
171
|
+
code: 'en', // URL prefix
|
|
172
|
+
name: 'English', // Display name
|
|
173
|
+
htmlLang: 'en', // HTML lang attribute
|
|
174
|
+
dateLocale: 'en-US', // Date formatting
|
|
175
|
+
direction: 'ltr', // Text direction (ltr/rtl)
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Per-Locale Config
|
|
180
|
+
|
|
181
|
+
Each locale can override:
|
|
182
|
+
|
|
183
|
+
| Config | Purpose |
|
|
184
|
+
|--------|---------|
|
|
185
|
+
| `site` | Title, description, author |
|
|
186
|
+
| `menu` | Navigation links |
|
|
187
|
+
| `footer` | Footer links and text |
|
|
188
|
+
| `sidebar` | Document tree groups |
|
|
189
|
+
| `ui` | UI translation strings |
|
|
190
|
+
|
|
191
|
+
## UI Translations
|
|
192
|
+
|
|
193
|
+
Built-in translations for common UI text:
|
|
194
|
+
|
|
195
|
+
```typescript
|
|
196
|
+
// Already included for en and zh-CN
|
|
197
|
+
const translations = {
|
|
198
|
+
home: 'Home',
|
|
199
|
+
posts: 'Posts',
|
|
200
|
+
tags: 'Tags',
|
|
201
|
+
readMore: 'Read more',
|
|
202
|
+
// ... 50+ strings
|
|
203
|
+
};
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Override specific strings:
|
|
207
|
+
|
|
208
|
+
```typescript
|
|
209
|
+
// In your locale config
|
|
210
|
+
export const enConfig = {
|
|
211
|
+
// ...
|
|
212
|
+
ui: {
|
|
213
|
+
readMore: 'Continue reading',
|
|
214
|
+
// Only override what you need
|
|
215
|
+
},
|
|
216
|
+
};
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## Adding a New Language
|
|
220
|
+
|
|
221
|
+
1. Add to `locales` array:
|
|
222
|
+
|
|
223
|
+
```typescript
|
|
224
|
+
locales: [
|
|
225
|
+
{ code: 'en', name: 'English', htmlLang: 'en', dateLocale: 'en-US' },
|
|
226
|
+
{ code: 'zh-CN', name: '中文', htmlLang: 'zh-CN', dateLocale: 'zh-CN' },
|
|
227
|
+
{ code: 'ja', name: '日本語', htmlLang: 'ja', dateLocale: 'ja-JP' }, // New
|
|
228
|
+
],
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
2. Create config folder:
|
|
232
|
+
|
|
233
|
+
```
|
|
234
|
+
src/config/locales/ja/
|
|
235
|
+
├── index.ts
|
|
236
|
+
├── site.ts
|
|
237
|
+
├── menu.ts
|
|
238
|
+
├── footer.ts
|
|
239
|
+
└── sidebar.ts
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
3. Add to `localeConfigs`:
|
|
243
|
+
|
|
244
|
+
```typescript
|
|
245
|
+
import { jaConfig } from './src/config/locales/ja';
|
|
246
|
+
|
|
247
|
+
localeConfigs: {
|
|
248
|
+
'en': enConfig,
|
|
249
|
+
'zh-CN': zhCNConfig,
|
|
250
|
+
'ja': jaConfig, // New
|
|
251
|
+
},
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
## RTL Languages
|
|
255
|
+
|
|
256
|
+
For right-to-left languages (Arabic, Hebrew):
|
|
257
|
+
|
|
258
|
+
```typescript
|
|
259
|
+
{
|
|
260
|
+
code: 'ar',
|
|
261
|
+
name: 'العربية',
|
|
262
|
+
htmlLang: 'ar',
|
|
263
|
+
dateLocale: 'ar-SA',
|
|
264
|
+
direction: 'rtl', // Enable RTL
|
|
265
|
+
}
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
## Best Practices
|
|
269
|
+
|
|
270
|
+
::: tip i18n Tips
|
|
271
|
+
1. **Start with two languages** - Don't add more until needed
|
|
272
|
+
2. **Keep content in sync** - Update all translations together
|
|
273
|
+
3. **Use consistent URLs** - Match URL structure across languages
|
|
274
|
+
4. **Test thoroughly** - Check all pages in all languages
|
|
275
|
+
:::
|
|
276
|
+
|
|
277
|
+
::: warning Path Consistency
|
|
278
|
+
When changing `defaultLocale`, update all menu and footer links to match the new URL structure.
|
|
279
|
+
:::
|
|
280
|
+
|
|
281
|
+
---
|
|
282
|
+
|
|
283
|
+
Congratulations! You've completed the configuration guide.
|
|
284
|
+
|
|
285
|
+
Return to the [Documentation Home](../) for more topics.
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Configuration
|
|
3
|
+
description: Customize your blog with site settings, sidebar, and i18n
|
|
4
|
+
pubDate: 2025-01-01
|
|
5
|
+
author: Astro Blog
|
|
6
|
+
categories:
|
|
7
|
+
- Documentation
|
|
8
|
+
tags:
|
|
9
|
+
- Configuration
|
|
10
|
+
- Settings
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Configuration
|
|
14
|
+
|
|
15
|
+
Customize every aspect of your blog through configuration files.
|
|
16
|
+
|
|
17
|
+
## Configuration Files
|
|
18
|
+
|
|
19
|
+
All configuration lives in `src/config/`:
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
src/config/
|
|
23
|
+
├── locales/ # Language-specific configs
|
|
24
|
+
│ ├── en/ # English
|
|
25
|
+
│ └── zh-CN/ # Chinese
|
|
26
|
+
├── site.ts # Site metadata
|
|
27
|
+
├── menu.ts # Navigation menu
|
|
28
|
+
├── sidebar.ts # Sidebar settings
|
|
29
|
+
├── footer.ts # Footer content
|
|
30
|
+
└── social.ts # Social links
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Configuration Guides
|
|
34
|
+
|
|
35
|
+
| Guide | Description |
|
|
36
|
+
|-------|-------------|
|
|
37
|
+
| [Site Settings](./01-site) | Title, description, author info |
|
|
38
|
+
| [Sidebar](./02-sidebar) | Navigation and document trees |
|
|
39
|
+
| [Multi-language](./03-i18n) | Add multiple language support |
|
|
40
|
+
|
|
41
|
+
## Quick Overview
|
|
42
|
+
|
|
43
|
+
### Site Configuration
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
// src/config/site.ts
|
|
47
|
+
export const siteConfig = {
|
|
48
|
+
title: 'My Blog',
|
|
49
|
+
description: 'A tech blog',
|
|
50
|
+
author: 'Your Name',
|
|
51
|
+
avatar: '/images/avatar.jpg',
|
|
52
|
+
};
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Navigation Menu
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
// src/config/locales/en/menu.ts
|
|
59
|
+
export const menu = [
|
|
60
|
+
{ name: 'Home', href: '/', icon: 'home' },
|
|
61
|
+
{ name: 'Posts', href: '/posts', icon: 'posts' },
|
|
62
|
+
{ name: 'About', href: '/about', icon: 'about' },
|
|
63
|
+
];
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Multi-language
|
|
67
|
+
|
|
68
|
+
```javascript
|
|
69
|
+
// astro.config.mjs
|
|
70
|
+
const i18nConfig = defineI18nConfig({
|
|
71
|
+
defaultLocale: 'en',
|
|
72
|
+
locales: [
|
|
73
|
+
{ code: 'en', name: 'English' },
|
|
74
|
+
{ code: 'zh-CN', name: '中文' },
|
|
75
|
+
],
|
|
76
|
+
localeConfigs: {
|
|
77
|
+
'en': enConfig,
|
|
78
|
+
'zh-CN': zhCNConfig,
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
Start with [Site Settings](./01-site)!
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Introduction
|
|
3
|
+
description: What is Astro Blog and why should you use it?
|
|
4
|
+
pubDate: 2025-01-01
|
|
5
|
+
author: Astro Blog
|
|
6
|
+
categories:
|
|
7
|
+
- Documentation
|
|
8
|
+
tags:
|
|
9
|
+
- Getting Started
|
|
10
|
+
- Introduction
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Introduction
|
|
14
|
+
|
|
15
|
+
Astro Blog is a **modern blog system** built for developers and content creators who want a fast, beautiful, and feature-rich blogging experience.
|
|
16
|
+
|
|
17
|
+
## What is Astro Blog?
|
|
18
|
+
|
|
19
|
+
Astro Blog is built on top of [Astro](https://astro.build), a modern static site generator. It combines:
|
|
20
|
+
|
|
21
|
+
- **Astro** - For blazing fast static site generation
|
|
22
|
+
- **Vue 3** - For interactive components
|
|
23
|
+
- **Tailwind CSS** - For beautiful, responsive styling
|
|
24
|
+
|
|
25
|
+
::: tip Static Site Generation
|
|
26
|
+
Your blog is pre-built as static HTML files, meaning:
|
|
27
|
+
- **Instant page loads** - No server processing needed
|
|
28
|
+
- **Better SEO** - Search engines love static content
|
|
29
|
+
- **Easy hosting** - Deploy anywhere (Vercel, Netlify, GitHub Pages)
|
|
30
|
+
:::
|
|
31
|
+
|
|
32
|
+
## Key Features
|
|
33
|
+
|
|
34
|
+
### Writing Features
|
|
35
|
+
|
|
36
|
+
| Feature | Description |
|
|
37
|
+
|---------|-------------|
|
|
38
|
+
| Markdown/MDX | Write in Markdown with component support |
|
|
39
|
+
| Code Highlighting | Beautiful syntax highlighting for 100+ languages |
|
|
40
|
+
| Math Formulas | LaTeX math with KaTeX |
|
|
41
|
+
| Diagrams | Flowcharts and diagrams with Mermaid |
|
|
42
|
+
| Containers | Callouts, tips, warnings, and more |
|
|
43
|
+
| Videos | Embed YouTube, Bilibili, or self-hosted videos |
|
|
44
|
+
|
|
45
|
+
### System Features
|
|
46
|
+
|
|
47
|
+
| Feature | Description |
|
|
48
|
+
|---------|-------------|
|
|
49
|
+
| Dark Mode | Toggle between light and dark themes |
|
|
50
|
+
| Responsive | Perfect on desktop, tablet, and mobile |
|
|
51
|
+
| Search | Full-text search across all posts |
|
|
52
|
+
| RSS Feed | Auto-generated RSS for subscribers |
|
|
53
|
+
| SEO | Optimized meta tags and sitemap |
|
|
54
|
+
| i18n | Multi-language support |
|
|
55
|
+
|
|
56
|
+
## When to Use Astro Blog?
|
|
57
|
+
|
|
58
|
+
Astro Blog is perfect for:
|
|
59
|
+
|
|
60
|
+
::: info Good Use Cases
|
|
61
|
+
- **Tech blogs** - Share tutorials and technical knowledge
|
|
62
|
+
- **Personal blogs** - Document your journey and thoughts
|
|
63
|
+
- **Documentation** - Create product or project docs
|
|
64
|
+
- **Portfolios** - Showcase your work with blog posts
|
|
65
|
+
:::
|
|
66
|
+
|
|
67
|
+
## Tech Stack
|
|
68
|
+
|
|
69
|
+
::: details View Full Stack
|
|
70
|
+
- **Framework**: [Astro](https://astro.build) v5.x
|
|
71
|
+
- **UI Components**: [Vue 3](https://vuejs.org)
|
|
72
|
+
- **Styling**: [Tailwind CSS](https://tailwindcss.com) v4.x
|
|
73
|
+
- **Code Highlighting**: [Shiki](https://shiki.style)
|
|
74
|
+
- **Math**: [KaTeX](https://katex.org)
|
|
75
|
+
- **Diagrams**: [Mermaid](https://mermaid.js.org)
|
|
76
|
+
- **Icons**: Font Awesome, Material Icons, Remix Icon, Bootstrap Icons
|
|
77
|
+
:::
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
Ready to set up your blog? Continue to [Installation](./02-install).
|