Commit 610b143

HPCesia <me@hpcesia.com>
2025-01-30 05:29:17
refactor: replace abbrlink to slug
1 parent c831b9b
src/components/PostPage.astro
@@ -30,7 +30,7 @@ posts = posts.slice((currentPage - 1) * postsPerPage, currentPage * postsPerPage
       return (
         <PostCard
           title={data.title}
-          url={'/posts/' + data.abbrlink + '/'}
+          url={'/posts/' + data.slug + '/'}
           published={data.published}
           tags={data.tags}
           category={data.category}
src/components/TimeArchives.astro
@@ -36,7 +36,7 @@ const { group } = Astro.props;
                   {monthGroup.posts.map((post) => (
                     <PostCard
                       title={post.data.title}
-                      url={`/posts/${post.data.abbrlink}/`}
+                      url={`/posts/${post.data.slug}/`}
                       published={post.data.published}
                       tags={post.data.tags || []}
                       category={post.data.category}
src/content/posts/manual.md
@@ -1,6 +1,6 @@
 ---
 title: Maunal
-abbrlink: '12345678'
+slug: '12345678'
 published: 2025-01-16 22:01:22
 category: TEST
 tags:
src/pages/archives/categories/index.astro
@@ -50,7 +50,7 @@ if (uncategorizedPosts.length > 0)
               {categoryPosts.get(category)?.map((post) => (
                 <PostCard
                   title={post.data.title}
-                  url={`/posts/${post.data.abbrlink}/`}
+                  url={`/posts/${post.data.slug}/`}
                   published={post.data.published}
                   tags={post.data.tags || []}
                   category={post.data.category}
src/pages/archives/tags/index.astro
@@ -51,7 +51,7 @@ if (untaggedPosts.length > 0) tagPosts.set(i18n(I18nKey.untagged), untaggedPosts
               {tagPosts.get(tag)?.map((post) => (
                 <PostCard
                   title={post.data.title}
-                  url={`/posts/${post.data.abbrlink}/`}
+                  url={`/posts/${post.data.slug}/`}
                   published={post.data.published}
                   tags={post.data.tags || []}
                   category={post.data.category}
src/pages/posts/[article].astro
@@ -12,7 +12,7 @@ import { getCollection, render } from 'astro:content';
 export async function getStaticPaths() {
   const articles = await getCollection('posts');
   return articles.map((article) => ({
-    params: { article: article.data.abbrlink },
+    params: { article: article.data.slug },
     props: { article },
   }));
 }
src/pages/rss.xml.ts
@@ -13,7 +13,7 @@ export async function GET(context: AstroGlobal) {
       title: post.data.title,
       pubDate: post.data.published,
       description: post.data.description,
-      link: `/posts/${post.data.abbrlink}`,
+      link: `/posts/${post.data.slug}`,
     })),
   });
 }
src/types/data.ts
@@ -1,7 +1,7 @@
 export type BlogPostData = {
   body: string;
   title: string;
-  abbrlink: string;
+  slug: string;
   published: Date;
   description: string;
   tags: string[];
src/content.config.ts
@@ -8,7 +8,7 @@ const postsCollection = defineCollection({
   }),
   schema: z.object({
     title: z.string(),
-    abbrlink: z.string(),
+    slug: z.string(),
     published: z.date(),
     updated: z.date().optional(),
     draft: z.boolean().optional().default(false),