@ztl-uwu/nuxt-content
Version:
Write your content inside your Nuxt app
19 lines (18 loc) • 745 B
JavaScript
import { defineEventHandler } from "h3";
import { useRuntimeConfig } from "#imports";
export default defineEventHandler(async (event) => {
const { getContentIndex } = await import("../content-index.js");
const { cacheStorage, serverQueryContent } = await import("../storage.js");
const { content } = useRuntimeConfig();
const now = Date.now();
const contents = await serverQueryContent(event).find();
await getContentIndex(event);
const navigation = await $fetch(`${content.api.baseURL}/navigation`);
await cacheStorage().setItem("content-navigation.json", navigation);
return {
generatedAt: now,
generateTime: Date.now() - now,
contents: content.experimental.cacheContents ? contents : [],
navigation
};
});