-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnuxt.config.ts
40 lines (36 loc) · 1.1 KB
/
nuxt.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
runtimeConfig: {
TINA_TOKEN: process.env.TINA_TOKEN,
public: {
PUBLIC_TINA_CLIENT_ID: process.env.PUBLIC_TINA_CLIENT_ID,
},
},
compatibilityDate: "2024-11-01",
devtools: { enabled: true },
routeRules: {
"/admin": {
// Temporary redirect using a 307 status code
redirect: "/admin/index.html",
},
},
hooks: {
async "prerender:routes"(ctx) {
// Fetch all post slugs at build time
const { client } = await import("./tina/__generated__/client");
const postsResponse = await client.queries.postConnection();
// Extract slugs
const postSlugs = postsResponse?.data?.postConnection?.edges
?.map((post) => post?.node?._sys.filename)
.filter(Boolean); // Ensure no undefined values
// Register dynamic routes for pre-rendering
if (postSlugs) {
for (const slug of postSlugs) {
ctx.routes.add(`/posts/${slug}`);
}
}
},
},
css: ["/assets/css/main.css"],
modules: ["@nuxtjs/tailwindcss"],
});