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.

How can I map parameterized route in homepage?

See original GitHub issue

Hello People,

Iā€™m trying to create blog on this tool with vue, but I donā€™t know how to map /posts/:post in homepage? my setup: WindiCSS, Markdown, Vue (without TS) and of course vite-plugin-ssr. Is it possible to do this using tools I have?

If you donā€™t understand something, please write, then I will describe this.

Thank You

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
brilloutcommented, May 16, 2021

I see.

So, you have a list of blog posts somewhere saved in a variable, letā€™s say myBlogPosts.

You add that variable to contextProps.pageProps:

// .page.server.js

const myBlogPosts = /* your logic to retrieve your list of blog post */

export function addContextProps() {
  const pageProps = {
    myBlogPosts
  }
  return { pageProps }
}

// We make `contextProps.pageProps` available to the browser
export const passToClient = ['pageProps']

Then you pass contextProps.pageProps to your Vue root component as decribed in the docs.

Then you generate the list of <a> links using pageProps.myBlogPosts and using Vueā€™s v-for attribute: <li v-for="post in myBlogPosts">.

0reactions
brilloutcommented, May 16, 2021

šŸ‘

Iā€™m closing this since itā€™s not a bug nor feature request.

But feel free to keep me updated if you run into a major headache situation šŸ˜ƒ.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - How to map route with two parameters value where the ...
I am having trouble in route mapping. I have a ActionResult with two parameter where first parameter(category) is compulsory and second parameter(page no)Ā ......
Read more >
The Complete Guide to URL parameters with React Router
1, React Router comes with a useParams Hook that returns an object with a mapping between the URL parameter and its value. import...
Read more >
Parameterised Routes ā€¢ Angular - codecraft.tv
With parameterised routes we can support variable paths in our routes. Angular also supports optional routes via passing in an object to the...
Read more >
How to Use Route Parameters in Angular - Sam Julien
The first way is through the route snapshot. The route snapshot provides the initial value of the route parameter map (called the paramMap...
Read more >
Full React Tutorial #25 - Route Parameters - YouTube
Key moments. View all Ā· Route Parameter Ā· Route Parameter Ā· Route Parameter Ā· Route Parameters Ā· Route Parameters Ā· Route Parameters Ā·...
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