22 lines
539 B
TypeScript
Raw Normal View History

2022-10-16 12:37:13 +03:00
import { getArchiveTree } from '~~/lib/blog/read-posts';
2024-04-20 20:32:12 +03:00
import type { BlogPost } from '~~/lib/types/post';
2022-10-16 12:37:13 +03:00
export default defineEventHandler(async (event) => {
2022-10-16 14:04:03 +03:00
const query = getQuery(event);
2022-12-02 18:52:51 +02:00
const include = (content: BlogPost) => {
2022-10-16 14:04:03 +03:00
if (query.tag) {
2022-12-02 18:52:51 +02:00
const tags = Array.isArray(query.tag) ? query.tag : [query.tag];
if (
!content.tags?.length ||
!tags.every((tag) => content.tags.includes(tag))
) {
2022-10-16 14:04:03 +03:00
return false;
}
}
return true;
};
return getArchiveTree(include);
2022-10-16 12:37:13 +03:00
});