Skip to content

Commit 60125f6

Browse files
author
白云苍狗
committed
📃 docs: 文档更新
1 parent eb46c5a commit 60125f6

File tree

4 files changed

+158
-11
lines changed

4 files changed

+158
-11
lines changed

demo/[tags].paths.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import config from './.vitepress/config';
33

44
export default {
55
async paths() {
6-
return dynamicPages(config, 'tags');
6+
const paths = await dynamicPages(config, 'tags');
7+
console.log(paths);
8+
return paths;
79
},
810
};

docs/.vitepress/assets/log.json

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,56 @@
22
{
33
"large_version": "v0.0.x",
44
"children": [
5+
{
6+
"version": "0.0.17",
7+
"date": "2024-09-27",
8+
"logs": [
9+
{
10+
"type": "feat",
11+
"text": "分页生成静态文件"
12+
},
13+
{
14+
"type": "style",
15+
"text": "样式优化"
16+
},
17+
{
18+
"type": "perf",
19+
"text": "将 fjGallery 插件初始化放到相册详情组件内"
20+
}
21+
]
22+
},
23+
{
24+
"version": "0.0.16",
25+
"date": "2024-09-11",
26+
"logs": [
27+
{
28+
"type": "style",
29+
"text": "样式优化"
30+
},
31+
{
32+
"type": "refactor",
33+
"text": "原文地址取值调整"
34+
}
35+
]
36+
},
37+
{
38+
"version": "0.0.15",
39+
"date": "2024-09-05",
40+
"logs": [
41+
{
42+
"type": "fix",
43+
"text": "分页时 route.path 无变动"
44+
},
45+
{
46+
"type": "fix",
47+
"text": "页面无法提取出目录时报错"
48+
},
49+
{
50+
"type": "fix",
51+
"text": "子路径下图标头像兼容"
52+
}
53+
]
54+
},
555
{
656
"version": "0.0.14",
757
"date": "2024-08-29",

docs/guide/config.md

Lines changed: 102 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -513,17 +513,69 @@ export default defineConfig({
513513
```ts [config.ts]
514514
export default defineConfig({
515515
themeConfig: {
516-
indexGenerator: { // [!code ++]
516+
indexGenerator: {
517517
perPage: 8, // [!code ++]
518-
// ... // [!code ++]
519-
} // [!code ++]
518+
}
520519
}
521520
});
522521
```
523522

524523
<<< @/../packages/vitepress-theme-async/types/theme.d.ts#IndexGeneratorConfig
525524
:::
526525

526+
默认情况下,生成的分页是伪分页,通过 URL 参数前端实现的分页,并不会按照分页生成对应 .html 文件。
527+
528+
如果需要按分页生成静态文件需要开启 `static` 配置,然后将 `index.md` 改名为 `[index].md`,并添加 `[index].paths.ts` 文件,调用主题 `dynamicPages` 方法动态添加分页路由。
529+
530+
::: code-group
531+
532+
```ts [config.ts]
533+
export default defineConfig({
534+
themeConfig: {
535+
indexGenerator: {
536+
static: true, // [!code ++]
537+
}
538+
}
539+
});
540+
```
541+
542+
```txt [博客目录]
543+
.
544+
├─ .vitepress
545+
├─ posts
546+
│ └─ ...
547+
├─ index.md // [!code --]
548+
├─ [index].md // [!code ++]
549+
├─ [index].paths.ts // [!code ++]
550+
├─ ...
551+
```
552+
553+
```ts [[index].paths.ts]
554+
import { dynamicPages } from 'vitepress-theme-async/plugin/page';
555+
import config from './.vitepress/config';
556+
557+
export default {
558+
async paths() {
559+
return dynamicPages(config, 'index');
560+
},
561+
};
562+
563+
```
564+
565+
```txt [对比]
566+
# 静态模式访问路径
567+
https://xxx // 首页
568+
https://xxx/page/2 // 第二页
569+
https://xxx/page/3 // 第三页
570+
571+
# 普通模式访问路径
572+
https://xxx // 首页
573+
https://xxx?page=2 // 第二页
574+
https://xxx?page=3 // 第三页
575+
```
576+
577+
:::
578+
527579
#### 归档分页
528580

529581
归档分配置后,同时也会对`分类页``标签页`生效。
@@ -535,17 +587,61 @@ export default defineConfig({
535587
```ts [config.ts]
536588
export default defineConfig({
537589
themeConfig: {
538-
archiveGenerator: { // [!code ++]
590+
archiveGenerator: {
539591
style: 'less', // [!code ++]
540-
// ... // [!code ++]
541-
} // [!code ++]
592+
}
542593
}
543594
});
544595
```
545596

546597
<<< @/../packages/vitepress-theme-async/types/theme.d.ts#ArchiveGeneratorConfig
547598
:::
548599

600+
归档分类页与首页一样,默认情况下,生成的分页是伪分页,通过 URL 参数前端实现的分页,并不会按照分页生成对应 .html 文件。
601+
602+
如果需要按分页生成静态文件需要开启 static 配置,然后将 `archives|categories|tags.md` 改名为 `[archives|categories|tags].md`,并添加 `[archives|categories|tags].paths.ts` 文件,调用主题 dynamicPages 方法动态添加分页路由。
603+
604+
::: code-group
605+
606+
```ts [config.ts]
607+
export default defineConfig({
608+
themeConfig: {
609+
archiveGenerator: {
610+
static: true, // [!code ++]
611+
}
612+
}
613+
});
614+
```
615+
616+
```txt [博客目录]
617+
.
618+
├─ .vitepress
619+
├─ posts
620+
│ └─ ...
621+
├─ archives.md // [!code --]
622+
├─ [archives].md // [!code ++]
623+
├─ [archives].paths.ts // [!code ++]
624+
├─ categories.md // [!code --]
625+
├─ [categories].md // [!code ++]
626+
├─ [categories].paths.ts // [!code ++]
627+
├─ tags.md // [!code --]
628+
├─ [tags].md // [!code ++]
629+
├─ [tags].paths.ts // [!code ++]
630+
├─ ...
631+
```
632+
633+
:::
634+
635+
如果开启了分页生成静态文件,文件的路由会根据 `page` 配置生成路由,以 `tags` 为例
636+
637+
| 配置路径 | 第一页路径 | 其他页路径 | 子级第一页 | 子级其他页路径 |
638+
| :---------- | :--------------- | :---------------- | :-------------- | :--------------------- |
639+
| / | /index.html | /page/2.html | /子级.html | /子级/page/2.html |
640+
| /index | /index.html | /page/2.html | /子级.html | /子级/page/2.html |
641+
| /tags | /tags.html | /tags/page/2.html | /tags/子级.html | /tags/子级/page/2.html |
642+
| /tags/ | /tags/index.html | /tags/page/2.html | /tags/子级.html | /tags/子级/page/2.html |
643+
| /tags/index | /tags/index.html | /tags/page/2.html | /tags/子级.html | /tags/子级/page/2.html |
644+
549645
### 分类卡片
550646

551647
首页中显示的分类卡片。

docs/guide/page.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ date: 2019-11-20 10:16:09
6767
```ts [config.ts]
6868
export default defineConfig({
6969
themeConfig: {
70-
page: {// [!code ++]
70+
page: {
7171
archives: '/archives',// [!code ++]
7272
categories: '/categories',// [!code ++]
7373
tags: '/tags',// [!code ++]
74-
}// [!code ++]
75-
},// [!code ++]
74+
}
75+
},
7676
});
7777
```
7878

@@ -251,7 +251,6 @@ single_column: true
251251

252252
`TrmGallery` 相册详情组件,可以通过 `srcs` 传入图片列表。`TrmGallery` 为主题内置 [全局组件](https://vitepress-theme-async.imalun.com/guide/config#%E5%85%A8%E5%B1%80%E7%BB%84%E4%BB%B6),默认未开启。
253253

254-
255254
```md
256255
---
257256
title: 壁纸

0 commit comments

Comments
 (0)