1.0.0 • Published 7 years ago

@jungle-mob/react-sitemap v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
7 years ago

React Router Dom Sitemaps

React Router Dom Sitemaps

Simple use

React app

'use strict';

import React, {Component} from 'react';
import {BrowserRouter, Switch, Route} from 'react-router-dom';


export default class Application extends Component {

    render() {
        return (<BrowserRouter>
            <div>
                <header/>
                <nav/>
                <main>
                    <Switch>
                        <Route exact path='/' component={null} changefreq='monthly' priority='0.8'/>
                        <Route path='/products' component={null} changefreq='monthly' priority='0.8'/>
                        <Route path='/orders' component={null} changefreq='monthly' priority='0.8'/>
                        <Route path='/create/order' component={null} changefreq='monthly' priority='0.8'/>
                        <Route path='/orders' component={null} changefreq='monthly' priority='0.8'/>
                        <Route path='/add/waybill/to/order' component={null} changefreq='monthly' priority='0.8'/>
                        <Route path='/deliveries' component={null} changefreq='monthly' priority='0.8'/>
                        <Route path='/cancel/order' component={null} changefreq='monthly' priority='0.8'/>
                        <Route path='/archive/orders' component={null} changefreq='monthly' priority='0.8'/>
                        <Route path='/login' component={null} changefreq='monthly' priority='0.8'/>
                    </Switch>
                </main>
                <footer/>
            </div>
        </BrowserRouter>);
    }
}

Generate sitemap

'use strict';

import path from 'path';
import fs from 'fs';
import Sitemap from '@jungle-mob/react-sitemap';

import App from 'App/App';

const sm = new Sitemap(new App().render());
let sitemap = sm.getSitemaps('https://test.com');
sitemap = '<?xml version="1.0" encoding="UTF-8"?>' + sitemap.toString();

fs.writeFileSync(path.join(__dirname, '..', 'sitemap.xml'), sitemap);