Closed francisrod01 closed 5 years ago
@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.
@francisrod01 did you have to figure it out?
@kuflash I'll see it tomorrow and go back with the answer. Thanks! :)
The-Code-Monkey says: https://github.com/kuflash/react-router-sitemap/issues/85#issuecomment-462902779
There is you just have to do a fetch with a dB call that gets the slugs from your dB and format it in the way for params to work I'll show you our setup at work tomorrow when I do it for out latest project
Yes, I know. Before to implement that I've been creating a table structure separating all the SEO including all slugs related by the topics. That way prevents I created a VIEW or something else in MongoDB further to indexes for performance of millions of links.
@francisrod01 unfortunately I can not understand what your problem. If you have all data in MongoDB, why you don't create connect to it and get all data for generate sitemap? Script for build sitemap is run once to create the XML file, and not for each sitemap request, for example, by a robot.
@kuflash I mentioned I'll create that. I think this is the best solution to do that so I'll close for now.
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:
@kuflash What I could do to solve the param problem? Using database to list those urls?