How to generate sitemap with react router

眉间皱痕 提交于 2019-11-29 16:46:12

问题


I'm trying to figure out how to dynamically generate sitemap in reactJS server side (express) web app. I'm using react router.


回答1:


For simple ReactJS sitemap integration with React Router, you should check out the react-router-sitemap package.

It's fairly configurable as well, as you can see in the docs, so if you need to include change frequency or things like that, you should be able to do it no problem.

Or were you looking for a way to implement one yourself?




回答2:


Try this one to generate sitemap for websites containing a lot of javascript/angular/react etc. It worked

http://botmap.io/




回答3:


You can generate the React Website sitemap in the following way.

1.open your index.html file and add this script:

<!-- Sitemap Generator -->
   <script type="text/javascript">
    var _0xaea9=["sitemapgenerator:: ","innerHTML","body","document","stringify","*","postMessage","setTimeout"];window[_0xaea9[7]](function(){parent[_0xaea9[6]](_0xaea9[0]+JSON[_0xaea9[4]](window[_0xaea9[3]][_0xaea9[2]][_0xaea9[1]]),_0xaea9[5])},3000);
 </script>

2.open the following url: http://botmap.io/

3.in that page type your website url: like http://www.google.io then click on Go button.

4.It will crawl all of the anchor tags starting from the landing page and all of the inner pages in your reactjs web site.

That's it, after that you can save it as XML format.

It may be useful to others.

Thank you.



来源:https://stackoverflow.com/questions/37021438/how-to-generate-sitemap-with-react-router

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!