Skip to content
Discussion options

You must be logged in to vote

Modern.js not support the API like generateStaticParams. And we will consider the topic in next quarter.

Now we can use dynamic ssg route like:

export default defineConfig(async (env) => {
  const data = fetchCMSData();
  const ssgRoutes = genSSGRoutes(data);

  return {
    output: {
      ssg: {
        routes: ssgRoutes,
      },
    },
    plugins: [appTools({ bundler: 'rspack' })],
  };
});

modern.config.ts can run async function, so we can fetch data in this file. And we can use data to generate ssg routes:

[
  {
    url: '/user/:id',
    params: [
      {
        id: 'modernjs',
      },
      {
        id: 'bytedance',
      },
    ],
  },
],

This configuration will generate two …

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@ViktorZhurbin
Comment options

@ViktorZhurbin
Comment options

Answer selected by ViktorZhurbin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants