@@ -513,17 +513,69 @@ export default defineConfig({
513513``` ts [config.ts]
514514export 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]
536588export 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首页中显示的分类卡片。
0 commit comments