Commit 653a3cb

HPCesia <me@hpcesia.com>
2025-03-26 08:16:30
fix: getAllReferences.getArticle
1 parent 6d41ef5
Changed files (1)
src/utils/content-utils.ts
@@ -167,15 +167,15 @@ export async function getAllReferences() {
       collection = 'posts';
       refPath = `posts/${refPath}`;
     }
-    const { id, title } = pathMap[refPath];
-    if (id) {
-      if (collection === 'spec') {
-        const article = specs.find((it) => it.id === id);
-        if (article) return { title, collection, id };
-      } else {
-        const article = posts.find((it) => it.id === id);
-        if (article) return { title, collection: 'posts', id };
-      }
+    const data = pathMap[refPath];
+    if (!data) return null;
+    const { id, title } = data;
+    if (collection === 'spec') {
+      const article = specs.find((it) => it.id === id);
+      if (article) return { title, collection, id };
+    } else {
+      const article = posts.find((it) => it.id === id);
+      if (article) return { title, collection: 'posts', id };
     }
     return null;
   };