Ready to get started?

Join Adocasts Plus for $8.00/mo or sign into your account to get access to all of our lessons.

robot mascot smiling

Dynamic Demo Routes for Components

In this lesson, we'll set up a dynamic route, which will be used to serve demos of the various components we'll be building.

Published
Oct 21, 23
Duration
2m 58s

Developer, dog lover, and burrito eater. Currently teaching AdonisJS, a fully featured NodeJS framework, and running Adocasts where I post new lessons weekly. Professionally, I work with JavaScript, .Net C#, and SQL Server.

Adocasts

Burlington, KY

Next, we’re going to get our routes set up for all the different components we’re going to build throughout this series.

Defining the Dynamic Route

First, let’s navigate into our start/routes.ts file, and define a route for our component pages. These are the pages we’ll use to demo the various components we’ll be building and their styles and variants.

// start/routes.ts

Route.get('/components/:name', async ({ params, view }) => {
  return view.render(`pages/components/${params.name}`)
}).as('components')

In this route, :name is a route parameter that will allow us to specify the component name dynamically. It’ll then map to a page in our project, which we’ll define in a moment.

Ready to get started?

Join Adocasts Plus for $8.00/mo or sign into your account to get access to all of our lessons.

Join The Discussion! (0 Comments)

Please sign in or sign up for free to join in on the dicussion.

robot comment bubble

Be the first to Comment!