Next.js Discord

Discord Forum

Dynamic routing

Unanswered
Havana posted this in #help-forum
Open in Discord
Avatar
HavanaOP
Hi, I'm creating the dynamic routing for services pages in app router, /services/[page].tsx

I Have all the data for the pages in my local folders itself. how should i import those in dynamic routing?

Here is the code snippet:
import data from "@/content/uk/services/legal/data.json";

export default function ServicePages({ params }: { params: { slug: string } }) {
  const { content, meta } = data;
  return (
    <>
      <section>
        <h1>{content.hero.title}</h1>
        <p>{content.hero.description}</p>
      </section>
    </>
  );
}

I want to import sub-services pages data something like @/content/uk/services/${params.slug}/data.json

How should i do it?

1 Reply

Avatar
Clown
What do you by having data in local folders? Is the data in a json file? Or are they components?