Issue: When using the static HTML adapter with internationalized routes ([...lang]) and MDX files, npm run build.server fails to generate the expected language-specific HTML files (e.g., /en/example/index.html).
File Structure:
src/routes/[...lang]/example/index.mdx
Solution:
- Create a separate file (e.g.,
hack.ts) with theonStaticGenerateimplementation:
import { StaticGenerateHandler } from "@builder.io/qwik-city";
export const onStaticGenerate: StaticGenerateHandler = () => {
return {
params: ["en", "es", "fr"],
};
};
- Export the
onStaticGeneratefunction in your MDX file:
export { onStaticGenerate } from "./hack"
This will properly generate the static HTML files for each language variant during build.
Build Command:
vite build --c adapters/static/vite.config.ts
Hope this saves someone else from debugging! 🚀