lunasqu.ee-nuxt/server/api/blog/archive.ts
2022-10-16 14:04:03 +03:00

17 lines
368 B
TypeScript

import { getArchiveTree } from '~~/lib/blog/read-posts';
export default defineEventHandler(async (event) => {
const query = getQuery(event);
const include = (content) => {
if (query.tag) {
if (!content.tags?.length || !content.tags.includes(query.tag)) {
return false;
}
}
return true;
};
return getArchiveTree(include);
});