question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Slug routes not building in development

See original GitHub issue

In development, running npm run dev:rollup and npm run dev:server as instructed, routes in blog/route.js are not being built.

For example, with the following in src/routes/blog/route.js, /blog/hello-world is “Not Found”:

module.exports = {
  all: () => [{ slug: 'hello-world' }],
  permalink: ({ request }) => `/blog/${request.slug}`,
};

After building with npm run build and starting the dev server again, the route loads. Subsequent changes to the Blog template do not cause dev:rollup builds and are not reflected until npm run build is executed again. Is this expected behavior?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:14 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
nickreesecommented, Sep 2, 2020

I’ve fixed the rollup on the template as well. It won’t try and rollup an empty components folder.

1reaction
nickreesecommented, Sep 2, 2020

OK sorted it out. It appears that we’re assuming a trailing slash in Elder.js. Add in a trailing slash in your route.js and it works.

module.exports = {
  all: () => [{ slug: 'hello-world' }, { slug: 'foo-bar' }],
  permalink: ({ request }) => `/blog/${request.slug}/`,
};
Read more comments on GitHub >

github_iconTop Results From Across the Web

Build error when slug ends with .html for dynamic routes #12212
When running next build I get. Error: getStaticPaths can only be used with dynamic pages, not '/articles/[slug].html'.
Read more >
Next.js routing from "pages/[...slug].js" not working
When navigating using the Link component from the index.js page to a [...slug].js page (e.g. /careers or /blog), everything works fine. BUT when ......
Read more >
NextJS build error when slug ends with .html for dynamic routes
I have been working on converting a massive WordPress site (20K posts) to NextJS. Every post on this old site has .html in...
Read more >
How to Create Dynamic Routes in Next.js - MakeUseOf
This will display the slug of the post. Dynamic Routing With getServerSideProps. Using Next.js you can fetch data at build time and create ......
Read more >
Dynamic Routing in Next.js - Andrew Aquino
js docs about adding category pages for blog posts, I winged creating a new file to dynamically generate category pages, by duplicating and ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found