diff --git a/biome.json b/biome.json index 4e1d87a..c1215bb 100644 --- a/biome.json +++ b/biome.json @@ -76,6 +76,6 @@ "globals": ["Bun", "HTMLRewriter", "BufferEncoding"] }, "files": { - "ignore": ["node_modules", "dist", ".nuxt"] + "ignore": ["node_modules", "dist", ".nuxt", ".output"] } } diff --git a/nuxt.config.ts b/nuxt.config.ts index 80fa140..30908d7 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -1,5 +1,35 @@ +import { readdirSync } from "node:fs"; +import { join } from "node:path"; import { defineNuxtConfig } from "nuxt/config"; +/* + * Reads the content directory and returns an array of all the files in the directory and subdirectories. + */ +const getRouteRenderingPaths = () => { + const contentDir = join(process.cwd(), "content"); + const paths: string[] = []; + + const readDir = (dir: string) => { + const files = readdirSync(dir); + for (const file of files) { + const filePath = join(dir, file); + if (file.endsWith(".md")) { + paths.push( + filePath + .replace(contentDir, "/articles") + .replace(".md", ""), + ); + } else { + readDir(filePath); + } + } + }; + + readDir(contentDir); + + return paths; +}; + // https://nuxt.com/docs/api/configuration/nuxt-config export default defineNuxtConfig({ modules: [ @@ -66,6 +96,13 @@ export default defineNuxtConfig({ image: { domains: ["images.pexels.com"], }, + sitemap: { + sources: [...getRouteRenderingPaths(), "/"], + }, + // For sitemap generation + site: { + url: "https://versia.blog", + }, nitro: { preset: "bun", minify: true,