File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11<script setup lang="ts">
22import { data as allPosts } from " ../../posts.data" ;
33import { computed } from " vue" ;
4- import { useRoute } from " vitepress" ;
4+ import { useRoute , withBase } from " vitepress" ;
55
66const route = useRoute ();
77
@@ -59,20 +59,20 @@ function formatDate(d: string) {
5959 <ul class =" posts-in-month" >
6060 <li v-for =" post in group.posts" :key =" post.url" class =" post-item" >
6161 <time class =" post-date" >{{ formatDate(post.date) }}</time >
62- <a :href =" post.url" class =" post-title" >{{ post.title }}</a >
62+ <a :href =" withBase( post.url) " class =" post-title" >{{ post.title }}</a >
6363 </li >
6464 </ul >
6565 </div >
6666 </div >
6767
6868 <div class =" archive-nav" >
69- <a href =" /archive/" class =" nav-link" >← 返回归档</a >
70- <a href =" /posts/" class =" nav-link" >查看所有文章 →</a >
69+ <a : href =" withBase(' /archive/') " class =" nav-link" >← 返回归档</a >
70+ <a : href =" withBase(' /posts/') " class =" nav-link" >查看所有文章 →</a >
7171 </div >
7272 </div >
7373 <div v-else class =" no-posts" >
7474 <p >{{ year ? `${year} 年没有文章` : "获取年份失败" }}</p >
75- <a href =" /archive/" >返回归档 →</a >
75+ <a : href =" withBase(' /archive/') " >返回归档 →</a >
7676 </div >
7777</template >
7878
Original file line number Diff line number Diff line change 11<script setup lang="ts">
22import { data as allPosts } from " ../../posts.data" ;
33import { ref , computed , watch } from " vue" ;
4+ import { withBase } from " vitepress" ;
45
56interface Category {
67 id: string ;
@@ -195,7 +196,7 @@ const archiveLinks = (() => {
195196 const maxMonth = y === 2025 ? 12 : 12 ;
196197 const months = Array .from ({ length: maxMonth }, (_ , i ) => ({
197198 label: ` ${i + 1 }月 ` ,
198- path: ` /archive/${y }/${String (i + 1 ).padStart (2 , " 0" )}/ ` ,
199+ path: withBase ( ` /archive/${y }/${String (i + 1 ).padStart (2 , " 0" )}/ ` ) ,
199200 }));
200201 result .push ({ year: String (y ), months });
201202 }
@@ -265,7 +266,7 @@ const archiveLinks = (() => {
265266 <ul class =" article-list" >
266267 <li v-for =" post in pagedPosts" :key =" post.url" class =" article-item" >
267268 <time class =" article-date" >{{ formatDate(post.date) }}</time >
268- <a :href =" post.url" class =" article-title" >{{ post.title }}</a >
269+ <a :href =" withBase( post.url) " class =" article-title" >{{ post.title }}</a >
269270 </li >
270271 <li v-if =" pagedPosts.length === 0" class =" no-results" >
271272 没有找到匹配的文章
You can’t perform that action at this time.
0 commit comments