honox
honox copied to clipboard
Unable to generate dynamic route on SSG build
What version of HonoX are you using?
0.1.39
What steps can reproduce the bug?
Create a honox project
add a route for /blog/[slug].tsx
run build
vite.config.ts for reference
import ssg from "@hono/vite-ssg";
import honox from "honox/vite";
import client from "honox/vite/client";
import tailwindcss from "@tailwindcss/vite";
import { defineConfig } from "vite";
const entry = "./app/server.ts";
export default defineConfig(({ mode }) => {
if (mode === "client") {
return {
plugins: [
honox({
client: {
input: ["./app/style.css"],
},
}),
tailwindcss(),
],
};
} else {
return {
plugins: [honox(), ssg({ entry }), tailwindcss()],
};
}
});
What is the expected behavior?
Expecting to see dynamic routes built.
What do you see instead?
I only see my root routes being built
dist/about.html 5.75 kB │ gzip: 2.44 kB
dist/services.html 6.57 kB │ gzip: 2.69 kB
dist/blog.html 7.64 kB │ gzip: 2.91 kB
dist/index.html 7.86 kB │ gzip: 3.15 kB
dist/faqs.html 10.20 kB │ gzip: 3.32 kB
✓ built in 557ms
Additional information
I'm fully aware this could be documentation thing but I've run out of ideas for this one.
Thanks
@umutahmet
You should add the ssgParams middleware imported from hono/ssg:
// app/routes/blog/_middleware.ts
import { createRoute } from 'honox/factory'
import { ssgParams } from 'hono/ssg'
export default createRoute(
ssgParams(async () => {
return [{ slug: 'post-1' }, { slug: 'post-2' }, { slug: 'post-3' }]
})
)