Commit a84c0f1

HPCesia <me@hpcesia.com>
2025-01-21 15:11:54
fix: routing
1 parent 52f65d0
Changed files (6)
src/components/CategoryBar.astro
@@ -23,7 +23,7 @@ const { categories, currentCategory } = Astro.props;
         href={`/archives/categories/${category}/1/`}
         class:list={[currentCategory === category ? 'theme-card-bg-hl' : '']}
       >
-        {category}
+        {i18n(category)}
       </a>
     ))
   }
src/pages/archives/categories/[category]/[page].astro
@@ -2,7 +2,6 @@
 import { getCategories, getSortedPosts } from '@utils/content-utils';
 import PostPage from '@components/PostPage.astro';
 import { siteConfig } from '@/config';
-import { i18n } from '@i18n/translation';
 import I18nKey from '@i18n/I18nKey';
 import GridLayout from '@layouts/GridLayout.astro';
 import CategoryBar from '@components/CategoryBar.astro';
@@ -11,7 +10,7 @@ import ProfileCard from '@components/widgets/ProfileCard.astro';
 export async function getStaticPaths() {
   const posts = await getSortedPosts();
   const categories = [
-    ...new Set(posts.map((post) => post.data.category || i18n(I18nKey.uncategorized))),
+    ...new Set(posts.map((post) => post.data.category || I18nKey.uncategorized)),
   ];
   return categories
     .map((category) => {
@@ -19,7 +18,7 @@ export async function getStaticPaths() {
       const pageNum = Math.ceil(categoryPosts.length / siteConfig.postsPerPage);
       category = category.replaceAll(/[\\/]/g, '-');
       return Array.from({ length: pageNum }, (_, i) => ({
-        params: { category: encodeURIComponent(category), page: (i + 1).toString() },
+        params: { category: category, page: (i + 1).toString() },
         props: {
           posts: categoryPosts.slice(
             i * siteConfig.postsPerPage,
@@ -44,7 +43,7 @@ const categories = await getCategories();
     currentPage={currentPage}
     baseUrl={`/archives/categories/${category}`}
   />
-  <Fragment slot="aside">
+  <Fragment slot="aside-fixed">
     <ProfileCard />
   </Fragment>
 </GridLayout>
src/pages/archives/tags/[tag]/[page].astro
@@ -14,7 +14,7 @@ export async function getStaticPaths() {
       const pageNum = Math.ceil(tagPosts.length / siteConfig.postsPerPage);
       tag = tag.replaceAll(/[\\/]/g, '-');
       return Array.from({ length: pageNum }, (_, i) => ({
-        params: { tag: encodeURIComponent(tag), page: (i + 1).toString() },
+        params: { tag: tag, page: (i + 1).toString() },
         props: {
           posts: tagPosts.slice(i * siteConfig.postsPerPage, (i + 1) * siteConfig.postsPerPage),
           currentPage: i + 1,
@@ -30,7 +30,7 @@ const { tag } = Astro.params;
 
 <GridLayout>
   <PostPage posts={posts} currentPage={currentPage} baseUrl={`/archives/tags/${tag}`} />
-  <Fragment slot="aside">
+  <Fragment slot="aside-fixed">
     <ProfileCard />
   </Fragment>
 </GridLayout>
src/pages/archives/[...time].astro
@@ -31,7 +31,7 @@ const { group } = Astro.props;
   <div class="flex flex-col gap-4">
     <TimeArchives group={group} />
   </div>
-  <Fragment slot="aside">
+  <Fragment slot="aside-fixed">
     <ProfileCard />
   </Fragment>
 </GridLayout>
src/pages/[...page].astro
@@ -29,7 +29,7 @@ const categories = await getCategories();
     baseUrl={`/page`}
     specialPage={[{ page: 1, url: '/' }]}
   />
-  <Fragment slot="aside">
+  <Fragment slot="aside-fixed">
     <ProfileCard />
   </Fragment>
 </GridLayout>
src/config.ts
@@ -13,7 +13,7 @@ export const siteConfig: SiteConfig = {
   subtitle: '',
   lang: 'zh_CN', // "en" | "zh_CN" | "zh_TW"
   favicon: [''],
-  postsPerPage: 2,
+  postsPerPage: 10,
 };
 
 export const profileConfig: ProfileConfig = {