lunasqu.ee-nuxt/server/api/blog/archive.ts

17 lines
368 B
TypeScript
Raw Normal View History

2022-10-16 09:37:13 +00:00
import { getArchiveTree } from '~~/lib/blog/read-posts';
export default defineEventHandler(async (event) => {
2022-10-16 11:04:03 +00:00
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);
2022-10-16 09:37:13 +00:00
});