Skip to content

fnobi/webpack-route-data-mapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

webpack-route-data-mapper

// webpack.config.js

const routeDataMapper = require('webpack-route-data-mapper');

const sharePageData = {
  a: {
    title: 'share page A'
  },
  b: {
    title: 'share page A'
  }
};

module.exports = {
  /*
    (your loader settings)
  */
  plugins: [
    routeDataMapper({
        baseDir: `./src/pug/page`,
        src: '**/[!_]*.pug',
        // template base locals data
        locals: {
          url: 'example site'
        },
        // mapping template name for html path
        routes: {
            '/share/:shares': 'share.pug'
        },
        // data for each routing
        data: {
            shares: sharePageData
        },
    })    
  ]
};

// => will generate `/share/a/index.html` and `/share/b/index.html`

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published