@jet-w/astro-blog 0.1.6 → 0.2.1
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-6D3XRDNY.js +145 -0
- package/dist/chunk-A2E2VSAQ.js +246 -0
- package/dist/{chunk-GYLSY3OJ.js → chunk-TJTPX2WP.js} +1 -1
- package/dist/config/index.d.ts +3 -47
- package/dist/config/index.js +18 -2
- package/dist/i18n-PgMCFBw0.d.ts +222 -0
- package/dist/index.d.ts +204 -7
- package/dist/index.js +255 -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 +1 -1
- package/src/components/blog/FloatingToc.vue +11 -3
- package/src/components/blog/Hero.astro +17 -2
- package/src/components/blog/NavigationTabs.vue +46 -15
- package/src/components/blog/PostCard.astro +28 -10
- package/src/components/blog/RelatedPosts.astro +23 -7
- package/src/components/blog/TableOfContents.astro +10 -4
- package/src/components/blog/TagCloud.astro +4 -3
- package/src/components/home/FeaturedPostsSection.astro +22 -6
- package/src/components/home/QuickNavSection.astro +33 -4
- package/src/components/home/RecentPostsSection.astro +22 -6
- package/src/components/home/StatsSection.astro +24 -6
- package/src/components/layout/Footer.astro +36 -20
- package/src/components/layout/Header.astro +75 -17
- package/src/components/layout/Sidebar.astro +40 -25
- package/src/components/ui/LanguageSwitcher.vue +183 -0
- package/src/components/ui/SearchBox.vue +13 -5
- package/src/components/ui/SearchInterface.vue +49 -25
- package/src/layouts/BaseLayout.astro +77 -52
- package/src/layouts/PageLayout.astro +22 -27
- package/src/layouts/SlidesLayout.astro +14 -2
- package/src/pages/archives/[year]/[month].astro +36 -17
- package/src/pages/archives/index.astro +36 -20
- package/src/pages/categories/[category].astro +33 -16
- package/src/pages/categories/index.astro +37 -14
- package/src/pages/posts/[...slug].astro +125 -18
- package/src/pages/posts/index.astro +59 -37
- package/src/pages/posts/page/[page].astro +65 -27
- package/src/pages/rss.xml.ts +18 -6
- package/src/pages/search.astro +50 -14
- package/src/pages/slides/index.astro +25 -6
- package/src/pages/tags/[tag].astro +32 -15
- package/src/pages/tags/index.astro +39 -16
- package/src/plugins/remark-containers.mjs +351 -322
- package/src/plugins/remark-protect-code.mjs +69 -0
- package/src/styles/global.css +35 -1
- package/templates/default/.claude/ralph-loop.local.md +48 -0
- package/templates/default/astro.config.mjs +33 -4
- package/templates/default/content/posts/blog_docs_en/01.get-started/01-intro.md +81 -0
- package/templates/default/content/posts/blog_docs_en/01.get-started/02-install.md +137 -0
- package/templates/default/content/posts/blog_docs_en/01.get-started/03-create-post.md +176 -0
- package/templates/default/content/posts/blog_docs_en/01.get-started/04-structure.md +173 -0
- package/templates/default/content/posts/blog_docs_en/01.get-started/05-deploy.md +208 -0
- package/templates/default/content/posts/blog_docs_en/01.get-started/README.md +52 -0
- package/templates/default/content/posts/blog_docs_en/02.guide/02-containers.md +245 -0
- package/templates/default/content/posts/blog_docs_en/02.guide/03-code-blocks.md +207 -0
- package/templates/default/content/posts/blog_docs_en/02.guide/03-mermaid.md +194 -0
- package/templates/default/content/posts/blog_docs_en/02.guide/04-icons.md +229 -0
- package/templates/default/content/posts/blog_docs_en/02.guide/06-latex.md +233 -0
- package/templates/default/content/posts/blog_docs_en/02.guide/07-video.md +184 -0
- package/templates/default/content/posts/blog_docs_en/02.guide/08-slides.md +359 -0
- package/templates/default/content/posts/blog_docs_en/02.guide/README.md +213 -0
- package/templates/default/content/posts/blog_docs_en/03.config/01-site.md +208 -0
- package/templates/default/content/posts/blog_docs_en/03.config/02-sidebar.md +240 -0
- package/templates/default/content/posts/blog_docs_en/03.config/03-i18n.md +349 -0
- package/templates/default/content/posts/blog_docs_en/03.config/README.md +85 -0
- package/templates/default/content/posts/blog_docs_en/README.md +79 -0
- package/templates/default/content/posts/blog_docs_zh/01.get-started/01-intro.md +81 -0
- package/templates/default/content/posts/blog_docs_zh/01.get-started/02-install.md +137 -0
- package/templates/default/content/posts/blog_docs_zh/01.get-started/03-create-post.md +176 -0
- package/templates/default/content/posts/blog_docs_zh/01.get-started/04-structure.md +173 -0
- package/templates/default/content/posts/blog_docs_zh/01.get-started/05-deploy.md +208 -0
- package/templates/default/content/posts/blog_docs_zh/01.get-started/README.md +52 -0
- package/templates/default/content/posts/blog_docs_zh/02.guide/02-containers.md +245 -0
- package/templates/default/content/posts/blog_docs_zh/02.guide/03-code-blocks.md +206 -0
- package/templates/default/content/posts/blog_docs_zh/02.guide/03-mermaid.md +194 -0
- package/templates/default/content/posts/blog_docs_zh/02.guide/04-icons.md +229 -0
- package/templates/default/content/posts/blog_docs_zh/02.guide/06-latex.md +233 -0
- package/templates/default/content/posts/blog_docs_zh/02.guide/07-video.md +184 -0
- package/templates/default/content/posts/blog_docs_zh/02.guide/08-slides.md +359 -0
- package/templates/default/content/posts/blog_docs_zh/02.guide/README.md +213 -0
- package/templates/default/content/posts/blog_docs_zh/03.config/01-site.md +208 -0
- package/templates/default/content/posts/blog_docs_zh/03.config/02-sidebar.md +240 -0
- package/templates/default/content/posts/blog_docs_zh/03.config/03-i18n.md +348 -0
- package/templates/default/content/posts/blog_docs_zh/03.config/README.md +85 -0
- package/templates/default/content/posts/blog_docs_zh/README.md +78 -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 +20 -0
- package/templates/default/src/config/locales/en/menu.ts +14 -0
- package/templates/default/src/config/locales/en/sidebar.ts +34 -0
- package/templates/default/src/config/locales/en/site.ts +7 -0
- package/templates/default/src/config/locales/en/ui.ts +29 -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 +20 -0
- package/templates/default/src/config/locales/zh-CN/menu.ts +14 -0
- package/templates/default/src/config/locales/zh-CN/sidebar.ts +34 -0
- package/templates/default/src/config/locales/zh-CN/site.ts +7 -0
- package/templates/default/src/config/locales/zh-CN/ui.ts +29 -0
- package/templates/default/src/config/sidebar.ts +10 -12
- package/templates/default/src/config/site.ts +2 -2
- package/templates/default/src/content.config.ts +15 -3
- package/templates/default/src/env.d.ts +7 -0
- package/dist/chunk-MQXPSOYB.js +0 -124
- package/templates/default/content/posts/blog_docs/01-quick-start.md +0 -162
- package/templates/default/content/posts/blog_docs/02-frontmatter.md +0 -277
- package/templates/default/content/posts/blog_docs/03-markdown-basic.md +0 -350
- package/templates/default/content/posts/blog_docs/04-containers.md +0 -331
- package/templates/default/content/posts/blog_docs/05-code-blocks.md +0 -388
- package/templates/default/content/posts/blog_docs/06-mermaid.md +0 -431
- package/templates/default/content/posts/blog_docs/07-video.md +0 -243
- package/templates/default/content/posts/blog_docs/08-latex.md +0 -382
- package/templates/default/content/posts/blog_docs/09-icons.md +0 -326
- package/templates/default/content/posts/blog_docs/10-sidebar.md +0 -445
- package/templates/default/content/posts/blog_docs/11-config.md +0 -334
- package/templates/default/content/posts/blog_docs/12-slides.mdx +0 -552
- package/templates/default/content/posts/blog_docs/README.md +0 -151
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Multi-language Support
|
|
3
|
+
description: Add multiple language support to your blog
|
|
4
|
+
pubDate: 2025-01-01
|
|
5
|
+
author: jet-w
|
|
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
|
+
│ └── ui.ts # UI translations
|
|
71
|
+
└── zh-CN/
|
|
72
|
+
├── index.ts
|
|
73
|
+
├── site.ts
|
|
74
|
+
├── menu.ts
|
|
75
|
+
├── footer.ts
|
|
76
|
+
├── sidebar.ts
|
|
77
|
+
└── ui.ts # UI translations
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### 3. Configure Each Language
|
|
81
|
+
|
|
82
|
+
**English (`en/index.ts`):**
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
import { site } from './site';
|
|
86
|
+
import { menu } from './menu';
|
|
87
|
+
import { footer } from './footer';
|
|
88
|
+
import { sidebar } from './sidebar';
|
|
89
|
+
import { ui } from './ui';
|
|
90
|
+
|
|
91
|
+
export const enConfig = {
|
|
92
|
+
site,
|
|
93
|
+
menu,
|
|
94
|
+
footer,
|
|
95
|
+
sidebar,
|
|
96
|
+
ui,
|
|
97
|
+
};
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**English site (`en/site.ts`):**
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
export const site = {
|
|
104
|
+
title: 'My Blog',
|
|
105
|
+
description: 'A blog about technology',
|
|
106
|
+
};
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
**English menu (`en/menu.ts`):**
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
export const menu = [
|
|
113
|
+
{ name: 'Home', href: '/', icon: 'home' },
|
|
114
|
+
{ name: 'Posts', href: '/posts', icon: 'posts' },
|
|
115
|
+
{ name: 'About', href: '/about', icon: 'about' },
|
|
116
|
+
];
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## URL Structure
|
|
120
|
+
|
|
121
|
+
With `prefixDefaultLocale: false`:
|
|
122
|
+
|
|
123
|
+
| Language | URL |
|
|
124
|
+
|----------|-----|
|
|
125
|
+
| English (default) | `/posts` |
|
|
126
|
+
| Chinese | `/zh-CN/posts` |
|
|
127
|
+
|
|
128
|
+
With `prefixDefaultLocale: true`:
|
|
129
|
+
|
|
130
|
+
| Language | URL |
|
|
131
|
+
|----------|-----|
|
|
132
|
+
| English | `/en/posts` |
|
|
133
|
+
| Chinese | `/zh-CN/posts` |
|
|
134
|
+
|
|
135
|
+
## Content Organization
|
|
136
|
+
|
|
137
|
+
### Option 1: Separate Folders
|
|
138
|
+
|
|
139
|
+
Create separate content folders per language:
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
content/posts/
|
|
143
|
+
├── blog_docs_en/ # English docs
|
|
144
|
+
│ └── ...
|
|
145
|
+
└── blog_docs/ # Chinese docs
|
|
146
|
+
└── ...
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Option 2: Same Content
|
|
150
|
+
|
|
151
|
+
Use the same content with language-aware frontmatter:
|
|
152
|
+
|
|
153
|
+
```yaml
|
|
154
|
+
---
|
|
155
|
+
title: Hello World
|
|
156
|
+
lang: en
|
|
157
|
+
---
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Language Switcher
|
|
161
|
+
|
|
162
|
+
The language switcher appears in the header automatically when multiple languages are configured.
|
|
163
|
+
|
|
164
|
+
It shows:
|
|
165
|
+
- Current language flag/name
|
|
166
|
+
- Dropdown with all languages
|
|
167
|
+
- Links to the same page in other languages
|
|
168
|
+
|
|
169
|
+
## Locale Configuration Options
|
|
170
|
+
|
|
171
|
+
### Locale Definition
|
|
172
|
+
|
|
173
|
+
```typescript
|
|
174
|
+
{
|
|
175
|
+
code: 'en', // URL prefix
|
|
176
|
+
name: 'English', // Display name
|
|
177
|
+
htmlLang: 'en', // HTML lang attribute
|
|
178
|
+
dateLocale: 'en-US', // Date formatting
|
|
179
|
+
direction: 'ltr', // Text direction (ltr/rtl)
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Per-Locale Config
|
|
184
|
+
|
|
185
|
+
Each locale can override:
|
|
186
|
+
|
|
187
|
+
| Config | Purpose |
|
|
188
|
+
|--------|---------|
|
|
189
|
+
| `site` | Title, description, author |
|
|
190
|
+
| `menu` | Navigation links |
|
|
191
|
+
| `footer` | Footer links and text |
|
|
192
|
+
| `sidebar` | Document tree groups |
|
|
193
|
+
| `ui` | UI translation strings |
|
|
194
|
+
|
|
195
|
+
## UI Translations
|
|
196
|
+
|
|
197
|
+
The blog includes built-in translations for 50+ UI strings in English and Chinese. You can override any string in your locale's `ui.ts` file.
|
|
198
|
+
|
|
199
|
+
### Creating UI Translations
|
|
200
|
+
|
|
201
|
+
**English (`en/ui.ts`):**
|
|
202
|
+
|
|
203
|
+
```typescript
|
|
204
|
+
import type { UITranslations } from '@jet-w/astro-blog';
|
|
205
|
+
|
|
206
|
+
export const ui: Partial<UITranslations> = {
|
|
207
|
+
// Override any UI strings here
|
|
208
|
+
browsePosts: 'Browse Posts',
|
|
209
|
+
aboutMe: 'About Me',
|
|
210
|
+
searchPlaceholder: 'Search articles...',
|
|
211
|
+
readMore: 'Continue reading',
|
|
212
|
+
};
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### Available UI Keys
|
|
216
|
+
|
|
217
|
+
| Category | Keys |
|
|
218
|
+
|----------|------|
|
|
219
|
+
| Navigation | `home`, `blog`, `about`, `search` |
|
|
220
|
+
| Posts | `posts`, `postList`, `noPostsFound`, `readMore`, `readingTime`, `minuteRead` |
|
|
221
|
+
| Tags & Categories | `tags`, `categories`, `allTags`, `allCategories`, `taggedWith`, `inCategory` |
|
|
222
|
+
| Archives | `archives`, `postsInArchive` |
|
|
223
|
+
| Sidebar | `recentPosts`, `popularTags`, `friendLinks`, `documentTree` |
|
|
224
|
+
| Footer | `quickLinks`, `contact` |
|
|
225
|
+
| Search | `searchPlaceholder`, `searchResults`, `noResults`, `searching`, `searchArticles`, `searchTips`, etc. |
|
|
226
|
+
| Hero | `browsePosts`, `aboutMe` |
|
|
227
|
+
| Pagination | `previousPage`, `nextPage`, `page`, `of` |
|
|
228
|
+
| Article | `publishedOn`, `updatedOn`, `author`, `tableOfContents`, `relatedPosts`, `sharePost` |
|
|
229
|
+
| Misc | `backToTop`, `copyCode`, `copied`, `expand`, `collapse`, `viewMode`, `sortBy`, `draft` |
|
|
230
|
+
| Slides | `slides`, `slidesList` |
|
|
231
|
+
| RSS | `rssFeed` |
|
|
232
|
+
|
|
233
|
+
::: tip Tip
|
|
234
|
+
|
|
235
|
+
You only need to override strings you want to customize. The library provides sensible defaults for all strings.
|
|
236
|
+
:::
|
|
237
|
+
|
|
238
|
+
## Adding a New Language
|
|
239
|
+
|
|
240
|
+
1. Add to `locales` array:
|
|
241
|
+
|
|
242
|
+
```typescript
|
|
243
|
+
locales: [
|
|
244
|
+
{ code: 'en', name: 'English', htmlLang: 'en', dateLocale: 'en-US' },
|
|
245
|
+
{ code: 'zh-CN', name: '中文', htmlLang: 'zh-CN', dateLocale: 'zh-CN' },
|
|
246
|
+
{ code: 'ja', name: '日本語', htmlLang: 'ja', dateLocale: 'ja-JP' }, // New
|
|
247
|
+
],
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
2. Create config folder:
|
|
251
|
+
|
|
252
|
+
```
|
|
253
|
+
src/config/locales/ja/
|
|
254
|
+
├── index.ts
|
|
255
|
+
├── site.ts
|
|
256
|
+
├── menu.ts
|
|
257
|
+
├── footer.ts
|
|
258
|
+
├── sidebar.ts
|
|
259
|
+
└── ui.ts # UI translations
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
3. Create `ui.ts` with translations:
|
|
263
|
+
|
|
264
|
+
```typescript
|
|
265
|
+
import type { UITranslations } from '@jet-w/astro-blog';
|
|
266
|
+
|
|
267
|
+
export const ui: Partial<UITranslations> = {
|
|
268
|
+
// Navigation
|
|
269
|
+
home: 'ホーム',
|
|
270
|
+
posts: '記事',
|
|
271
|
+
tags: 'タグ',
|
|
272
|
+
categories: 'カテゴリー',
|
|
273
|
+
search: '検索',
|
|
274
|
+
|
|
275
|
+
// Hero section
|
|
276
|
+
browsePosts: '記事を見る',
|
|
277
|
+
aboutMe: '私について',
|
|
278
|
+
|
|
279
|
+
// Search
|
|
280
|
+
searchPlaceholder: '記事を検索...',
|
|
281
|
+
noResults: '結果が見つかりません',
|
|
282
|
+
|
|
283
|
+
// Add more translations as needed...
|
|
284
|
+
};
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
4. Create `index.ts`:
|
|
288
|
+
|
|
289
|
+
```typescript
|
|
290
|
+
import { site } from './site';
|
|
291
|
+
import { menu } from './menu';
|
|
292
|
+
import { footer } from './footer';
|
|
293
|
+
import { sidebar } from './sidebar';
|
|
294
|
+
import { ui } from './ui';
|
|
295
|
+
|
|
296
|
+
export const jaConfig = {
|
|
297
|
+
site,
|
|
298
|
+
menu,
|
|
299
|
+
footer,
|
|
300
|
+
sidebar,
|
|
301
|
+
ui,
|
|
302
|
+
contentPathPrefix: 'blog_docs_ja',
|
|
303
|
+
};
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
5. Add to `localeConfigs` in `astro.config.mjs`:
|
|
307
|
+
|
|
308
|
+
```typescript
|
|
309
|
+
import { jaConfig } from './src/config/locales/ja';
|
|
310
|
+
|
|
311
|
+
localeConfigs: {
|
|
312
|
+
'en': enConfig,
|
|
313
|
+
'zh-CN': zhCNConfig,
|
|
314
|
+
'ja': jaConfig, // New
|
|
315
|
+
},
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
## RTL Languages
|
|
319
|
+
|
|
320
|
+
For right-to-left languages (Arabic, Hebrew):
|
|
321
|
+
|
|
322
|
+
```typescript
|
|
323
|
+
{
|
|
324
|
+
code: 'ar',
|
|
325
|
+
name: 'العربية',
|
|
326
|
+
htmlLang: 'ar',
|
|
327
|
+
dateLocale: 'ar-SA',
|
|
328
|
+
direction: 'rtl', // Enable RTL
|
|
329
|
+
}
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
## Best Practices
|
|
333
|
+
|
|
334
|
+
::: tip i18n Tips
|
|
335
|
+
1. **Start with two languages** - Don't add more until needed
|
|
336
|
+
2. **Keep content in sync** - Update all translations together
|
|
337
|
+
3. **Use consistent URLs** - Match URL structure across languages
|
|
338
|
+
4. **Test thoroughly** - Check all pages in all languages
|
|
339
|
+
:::
|
|
340
|
+
|
|
341
|
+
::: warning Path Consistency
|
|
342
|
+
When changing `defaultLocale`, update all menu and footer links to match the new URL structure.
|
|
343
|
+
:::
|
|
344
|
+
|
|
345
|
+
---
|
|
346
|
+
|
|
347
|
+
Congratulations! You've completed the configuration guide.
|
|
348
|
+
|
|
349
|
+
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: jet-w
|
|
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,79 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Astro Blog Documentation
|
|
3
|
+
description: A modern blog system built with Astro, Vue, and Tailwind CSS
|
|
4
|
+
pubDate: 2025-01-01
|
|
5
|
+
author: jet-w
|
|
6
|
+
categories:
|
|
7
|
+
- Documentation
|
|
8
|
+
tags:
|
|
9
|
+
- Astro
|
|
10
|
+
- Guide
|
|
11
|
+
star: true
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# Astro Blog
|
|
15
|
+
|
|
16
|
+
A modern, feature-rich blog system built with **Astro**, **Vue 3**, and **Tailwind CSS**.
|
|
17
|
+
|
|
18
|
+
::: tip Why Choose This Blog?
|
|
19
|
+
- **Fast** - Static site generation with near-instant page loads
|
|
20
|
+
- **Modern** - Built with the latest web technologies
|
|
21
|
+
- **Flexible** - Markdown, MDX, and rich component support
|
|
22
|
+
- **Beautiful** - Clean design with dark mode support
|
|
23
|
+
|
|
24
|
+
:::
|
|
25
|
+
|
|
26
|
+
## Get Started
|
|
27
|
+
|
|
28
|
+
New to Astro Blog? Start here:
|
|
29
|
+
|
|
30
|
+
| Chapter | Description |
|
|
31
|
+
|---------|-------------|
|
|
32
|
+
| [Introduction](./get-started/) | What is Astro Blog and why use it |
|
|
33
|
+
| [Installation](./get-started/02-install) | Set up your development environment |
|
|
34
|
+
| [First Post](./get-started/03-create-post) | Create and publish your first article |
|
|
35
|
+
| [Project Structure](./get-started/04-structure) | Understand the file organization |
|
|
36
|
+
| [Deployment](./get-started/05-deploy) | Build and deploy your blog |
|
|
37
|
+
|
|
38
|
+
## Writing Guide
|
|
39
|
+
|
|
40
|
+
Learn how to write beautiful content:
|
|
41
|
+
|
|
42
|
+
| Guide | Description |
|
|
43
|
+
|-------|-------------|
|
|
44
|
+
| [Markdown Basics](./guide/markdown/) | Essential Markdown syntax |
|
|
45
|
+
| [Containers](./guide/markdown/02-containers) | Tips, warnings, and callouts |
|
|
46
|
+
| [Code Blocks](./guide/markdown/03-code-blocks) | Syntax highlighting and more |
|
|
47
|
+
| [Diagrams](./guide/features/01-mermaid) | Flowcharts and diagrams with Mermaid |
|
|
48
|
+
| [Math Formulas](./guide/features/02-latex) | LaTeX math rendering |
|
|
49
|
+
| [Videos](./guide/features/03-video) | Embed YouTube, Bilibili, and more |
|
|
50
|
+
| [Icons](./guide/features/04-icons) | Use icons from multiple libraries |
|
|
51
|
+
|
|
52
|
+
## Configuration
|
|
53
|
+
|
|
54
|
+
Customize your blog:
|
|
55
|
+
|
|
56
|
+
| Config | Description |
|
|
57
|
+
|--------|-------------|
|
|
58
|
+
| [Site Settings](./config/01-site) | Title, description, and metadata |
|
|
59
|
+
| [Sidebar](./config/02-sidebar) | Navigation and document trees |
|
|
60
|
+
| [Multi-language](./config/03-i18n) | Add multiple language support |
|
|
61
|
+
|
|
62
|
+
## Quick Start
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# Install dependencies
|
|
66
|
+
npm install
|
|
67
|
+
|
|
68
|
+
# Start development server
|
|
69
|
+
npm run dev
|
|
70
|
+
|
|
71
|
+
# Build for production
|
|
72
|
+
npm run build
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Then visit `http://localhost:4321` to see your blog!
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
Ready to begin? Start with the [Introduction](./get-started/)!
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 介绍
|
|
3
|
+
description: 什么是 Astro 博客?为什么要使用它?
|
|
4
|
+
pubDate: 2025-01-01
|
|
5
|
+
author: jet-w
|
|
6
|
+
categories:
|
|
7
|
+
- 文档
|
|
8
|
+
tags:
|
|
9
|
+
- 入门
|
|
10
|
+
- 介绍
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# 介绍
|
|
14
|
+
|
|
15
|
+
Astro 博客是一个为开发者和内容创作者打造的**现代博客系统**,提供快速、美观且功能丰富的写作体验。
|
|
16
|
+
|
|
17
|
+
## 什么是 Astro 博客?
|
|
18
|
+
|
|
19
|
+
Astro 博客基于 [Astro](https://astro.build) 构建,这是一个现代静态站点生成器。它结合了:
|
|
20
|
+
|
|
21
|
+
- **Astro** - 闪电般快速的静态站点生成
|
|
22
|
+
- **Vue 3** - 用于交互组件
|
|
23
|
+
- **Tailwind CSS** - 美观、响应式的样式
|
|
24
|
+
|
|
25
|
+
::: tip 静态站点生成
|
|
26
|
+
你的博客被预先构建为静态 HTML 文件,这意味着:
|
|
27
|
+
- **即时页面加载** - 无需服务器处理
|
|
28
|
+
- **更好的 SEO** - 搜索引擎喜欢静态内容
|
|
29
|
+
- **易于托管** - 可部署到任何地方(Vercel、Netlify、GitHub Pages)
|
|
30
|
+
:::
|
|
31
|
+
|
|
32
|
+
## 核心特性
|
|
33
|
+
|
|
34
|
+
### 写作功能
|
|
35
|
+
|
|
36
|
+
| 特性 | 描述 |
|
|
37
|
+
|------|------|
|
|
38
|
+
| Markdown/MDX | 使用 Markdown 写作,支持组件 |
|
|
39
|
+
| 代码高亮 | 100+ 种语言的精美语法高亮 |
|
|
40
|
+
| 数学公式 | 使用 KaTeX 渲染 LaTeX 数学公式 |
|
|
41
|
+
| 图表 | 使用 Mermaid 绘制流程图和图表 |
|
|
42
|
+
| 容器 | 标注、提示、警告等 |
|
|
43
|
+
| 视频 | 嵌入 YouTube、Bilibili 或自托管视频 |
|
|
44
|
+
|
|
45
|
+
### 系统功能
|
|
46
|
+
|
|
47
|
+
| 特性 | 描述 |
|
|
48
|
+
|------|------|
|
|
49
|
+
| 深色模式 | 切换浅色和深色主题 |
|
|
50
|
+
| 响应式 | 完美适配桌面、平板和手机 |
|
|
51
|
+
| 搜索 | 全文搜索所有文章 |
|
|
52
|
+
| RSS 订阅 | 自动生成 RSS 供订阅者使用 |
|
|
53
|
+
| SEO | 优化的 meta 标签和站点地图 |
|
|
54
|
+
| 多语言 | 多语言支持 |
|
|
55
|
+
|
|
56
|
+
## 何时使用 Astro 博客?
|
|
57
|
+
|
|
58
|
+
Astro 博客非常适合:
|
|
59
|
+
|
|
60
|
+
::: info 适用场景
|
|
61
|
+
- **技术博客** - 分享教程和技术知识
|
|
62
|
+
- **个人博客** - 记录你的旅程和想法
|
|
63
|
+
- **文档站点** - 创建产品或项目文档
|
|
64
|
+
- **作品集** - 展示你的作品
|
|
65
|
+
:::
|
|
66
|
+
|
|
67
|
+
## 技术栈
|
|
68
|
+
|
|
69
|
+
::: details 查看完整技术栈
|
|
70
|
+
- **框架**: [Astro](https://astro.build) v5.x
|
|
71
|
+
- **UI 组件**: [Vue 3](https://vuejs.org)
|
|
72
|
+
- **样式**: [Tailwind CSS](https://tailwindcss.com) v4.x
|
|
73
|
+
- **代码高亮**: [Shiki](https://shiki.style)
|
|
74
|
+
- **数学**: [KaTeX](https://katex.org)
|
|
75
|
+
- **图表**: [Mermaid](https://mermaid.js.org)
|
|
76
|
+
- **图标**: Font Awesome、Material Icons、Remix Icon、Bootstrap Icons
|
|
77
|
+
:::
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
准备好设置你的博客了吗?继续阅读 [安装](./02-install)。
|