// nitro hook to get Directus files working on ssg // https://github.com/codepie-io/nuxt3-dynamic-routes/blob/main/nuxt.config.ts // + ssg homemade caching to not retrieve all the files each generation import { crawlMedia } from './ssg_hooks/crawlMedia.js' import { cacheMedia } from './ssg_hooks/cacheMedia.js' export default defineNuxtConfig({ devtools: { enabled: true }, modules: [ '@nuxtjs/seo', '@nuxtjs/i18n', ], runtimeConfig: { apiURL: process.env.DIRECTUS_URL, apiToken: process.env.DIRECTUS_API_TOKEN, }, nitro: { hooks: { async 'prerender:routes'(routes) { await crawlMedia(routes); }, }, prerender: { routes: [ '/api/items/global_translations', '/api/items/works_translations', '/api/items/works', ] }, }, hooks: { 'nitro:build:public-assets': async () => { const imageSizes = [ { small: 750 }, { large: 1920 }, ]; await cacheMedia(imageSizes); } }, app: { pageTransition: { name: 'page', mode: 'out-in' } // define in the app.vue css }, site: { url: process.env.URL, defaultLocale: 'fr', name: '', description: '' }, compatibilityDate: '2024-08-14', }) // TODO // - lazy images static // - clean media url // - 404 static // - handle file deletion