personal-site/nuxt.config.ts

86 lines
2.1 KiB
TypeScript
Raw Normal View History

2025-02-16 19:31:39 -08:00
import * as pages from "./utils/page_updater/update_pagelist";
2025-01-04 02:47:38 -08:00
2025-02-16 19:31:39 -08:00
// Import the generated page list.
const blog_list_json = (await import("./assets/meta/post_list.json")).default;
2025-01-04 02:47:38 -08:00
2025-02-16 19:31:39 -08:00
const blog_list: pages.PageList = pages.PageList.fromJSON(JSON.stringify(blog_list_json));
// Nitro expects a string array of routes.
const blog_nitro_routes: string[] = [];
// Iterate over each available language.
for (const [lang, langData] of Object.entries(blog_list.languages)) {
// For each category in this language.
for (const [categoryName, category] of Object.entries(langData.categories)) {
// For each post, use its canonical id to build the route.
for (const post of category.posts) {
// Get the canonical id (removes the language folder, e.g. "en/page.md" becomes "page.md")
const canonicalId = pages.PageList.getCanonicalId(post.id);
// Remove the file extension (e.g. "page.md" becomes "page")
const postSlug = canonicalId.replace(/\.md$/, '');
// Build the localized route (e.g. "/en/article/page")
blog_nitro_routes.push(`/${lang}/article/${postSlug}`);
}
2025-01-04 02:47:38 -08:00
}
2025-01-04 11:45:02 -08:00
}
2025-02-16 19:31:39 -08:00
2025-01-04 11:45:02 -08:00
console.log(blog_nitro_routes);
2025-01-04 02:47:38 -08:00
2024-12-21 19:11:09 -08:00
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
2025-02-16 19:31:39 -08:00
compatibilityDate: "2024-11-01",
2025-02-16 19:34:32 -08:00
ssr: true,
2024-12-21 19:11:09 -08:00
postcss: {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
},
2025-01-04 13:03:03 -08:00
routeRules: {
2025-02-16 19:31:39 -08:00
"/article/:category:/:id": {
redirect: "/article/:category:/:id/index.html",
},
2025-01-04 13:03:03 -08:00
},
2024-12-21 19:11:09 -08:00
app: {
2024-12-22 12:22:47 -08:00
pageTransition: {
2025-02-16 19:31:39 -08:00
name: "page",
mode: "out-in",
2024-12-22 12:22:47 -08:00
},
2024-12-21 19:11:09 -08:00
},
modules: [
2025-02-16 19:31:39 -08:00
"nuxt-particles",
"@nuxt/test-utils/module",
"@nuxt/content",
"@nuxtjs/i18n",
2024-12-21 19:11:09 -08:00
],
2025-02-16 19:31:39 -08:00
i18n: {
vueI18n: './i18n.config.ts',
locales: [
{
code: 'en',
name: 'English'
},
{
code: 'tp',
name: 'Toki Pona'
}
]
},
2025-01-04 02:47:38 -08:00
content: {
// ... options
2025-02-16 19:31:39 -08:00
api: {
baseURL: '/api/_content'
}
2025-01-04 02:47:38 -08:00
},
2025-01-04 11:45:02 -08:00
nitro: {
prerender: {
2025-01-04 13:03:03 -08:00
routes: blog_nitro_routes,
2025-02-16 19:31:39 -08:00
autoSubfolderIndex: true,
},
2025-01-04 11:45:02 -08:00
},
2024-12-21 19:11:09 -08:00
particles: {
2025-02-16 19:31:39 -08:00
mode: "slim",
lazy: true,
},
});