Skip to content

Commit

Permalink
Added nitro hook for blog
Browse files Browse the repository at this point in the history
  • Loading branch information
omgitsjan committed May 21, 2024
1 parent c0c920c commit edd456d
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { promises as fs } from 'fs'
import path from 'path'

// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
extends: [process.env.NUXT_UI_PRO_PATH || "@nuxt/ui-pro"],
Expand All @@ -21,7 +24,17 @@ export default defineNuxtConfig({

globals.forEach((c) => (c.global = true));
},
async 'nitro:config'(nitroConfig) {
const contentDir = path.resolve(__dirname, 'content/2.blog')
const files = await fs.readdir(contentDir)
const routes = files
.filter(file => file.endsWith('.md'))
.map(file => `/blog/${file.replace('.md', '')}`)

nitroConfig.prerender.routes.push(...routes)
}
},
ssr: true,
ui: {
icons: ["heroicons", "simple-icons", "mdi", "line-md"],
},
Expand All @@ -45,4 +58,4 @@ export default defineNuxtConfig({
},
},
},
});
})

0 comments on commit edd456d

Please sign in to comment.