fix: getAllReferences.getArticle

This commit is contained in:
HPCesia 2025-03-26 16:16:30 +08:00
parent 6d41ef585a
commit 653a3cbd71

View File

@ -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;
};