Home > database >  How to create dynamic URL page structure in nextjs? if one URL is subset of another URL format
How to create dynamic URL page structure in nextjs? if one URL is subset of another URL format

Time:12-09

I have two URL matches on react js

  1. '/:countryCode([a-z]{2})/:category/:genre'
  2. '/:countryCode([a-z]{2})/:category/:genre/:performer'

If it matches with 3 dynamic parameters it redirects to the genre page. If it matches with another one it turns to the performer page.

How can I create a page structure on nextjs. /pages/[countryCode]/[category]/[genre]/[performer] How it will works on both cases

CodePudding user response:

inside genre folder create a file index.js

CodePudding user response:

pages/
  [countryCode]/
    [category]/
      [genre]/
        [performer].js //Matches [countryCode]/[category]/[genre]/[performer]
        index.js //Matches [countryCode]/[category]/[genre]/
  • Related