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.

There's no possible to generate all links based on the routes

See original GitHub issue

There’s no possible to generate all links based on the routes, because I had to created a new route-list without import any component. (just links)

Envs:

  • npm: 6.5.0
  • node: 8.11.2
  • react-router-sitemap: 1.2.0
import React from 'react';
import { Route, Redirect } from 'react-router';

export default (
  <Route>
    <Route path="/" />
    <Route path="/about" />
    <Route path="/contact" />
    <Route path="/company/:id" />
    <Route path="/know-more" />
    <Route path="/cities">
      <Route path='/:slug'>
        <Route path='/event/:eventSlug' />
        <Route path='/ads' />
      </Route>
    </Route>
  </Route>
);

@kuflash What I could do to solve the param problem? Using database to list those urls?

<url> <loc>https://my-page.net/</loc> </url>
<url> <loc>https://my-page.net/about</loc> </url>
<url> <loc>https://my-page.net/contact</loc> </url>
<url> <loc>https://my-page.net/company/:id</loc> </url>
<url> <loc>https://my-page.net/know-more/business</loc> </url>
<url> <loc>https://my-page.net/city-promotion</loc> </url>
<url> <loc>https://my-page.net/city-promotion/:slug</loc> </url>
<url> <loc>https://my-page.net/city-promotion/:slug/event/:eventSlug</loc> </url>
<url> <loc>https://my-page.net/city-promotion/:slug/ad-sample</loc> </url>

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
kuflashcommented, Feb 1, 2019

@francisrod01 yes, if you use dynamic routes you need load data for this routes. You can load it’s from DB and create rules for mapping data to dynamic routes. Example creating this params stored in example file.

Some pseudocode:

fetch('https://example.com/data-for-routes.json')
  .then((response) => {
    const paramsConfig = {
	'/company/:id': [
	  { id: response.ids }, // array of ids
	],
        '/cities/:slug/event/:eventSlug': [{
          slug: response.slugs, // array of slugs
          eventSlug: response.eventSlugs, // array of event slugs
        }],
    };
    new Sitemap(router)
      .applyParams(paramsConfig)
      .build('http://my-site.ru', { limitCountPaths: 5000 })
      .save('./sitemap.xml', '/static/')
  });

Also, you can read docs.

1reaction
francisrod01commented, Feb 13, 2019

@kuflash I mentioned I’ll create that. I think this is the best solution to do that so I’ll close for now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

web crawler - Get a list of URLs from a site - Stack Overflow
Create a mapping between the well known old URLs and the new ones. Redirect when you see an old URL. · If you...
Read more >
How To Handle Routing in React Apps with React Router
Step 2 — Adding Routes. In this step, you'll create a base router with individual routes for each page. You'll order your routes...
Read more >
URLs and Routing - Meteor Guide
How to drive your Meteor app's UI using URLs with FlowRouter.
Read more >
Configuring links | React Navigation
In this guide, we will configure React Navigation to handle external links. This is necessary if you want to:
Read more >
Understanding Links in React.js - Pluralsight
In regular apps without a library like React, links are created with an ... components that need re-rendering based on a specified route....
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