1

All static routes and dynamic routes are generated, but not index.html. Why not?

In nuxt-config.js I have:

const staticRoutes =
  [
    '/about',
    '/contact',
    '/portfolio'
  ]
const dynamicRoutes = async () => {
  const routes = await axios.get('https://my-site.com/wp/wp-json/projects/v1/posts')
    .then(res => res.data.map((project) => `/project/${project.ID}/${project.post_name}`))

  return routes
}

1 Answer 1

1
+200

You have to edit your dynamicRoutes function to add the index / route in your routes:

const dynamicRoutes = async () => {
  const routes = await axios.get('https://fabricepallaud.com/wp/wp-json/projects/v1/posts')
    .then(res => res.data.map((project) => `/project/${project.ID}/${project.post_name}`))

  routes.push("/")

  return routes
}

see https://github.com/nuxt-community/router-module#using-top-level-options

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.