npm.io
1.4.6 • Published 3 years ago

simple-reproduction

Licence
ISC
Version
1.4.6
Deps
6
Size
6 kB
Vulns
0
Weekly
0
Stars
1

simple-reproduction

copy html with meta rewriting.

usage

init

const SimpleReproduction = require('simple-reproduction');

const DIST = 'dist';

const reproduction = new SimpleReproduction({
  dest: DIST,
});

reproduction.on('write', ({ htmlDest }) => {
  console.log('[write]', htmlDest);
});

reproduction.on('end', () => {
  console.log('[done]');
});
copy html with injection
reproduction.start({
  src: `${DIST}/index.html`,
  routes: {
    ['/share-test']: {
      title: 'dummy',
      meta: {
        description: 'dummy',
        'og:image': 'http://example.com/dummy1.png',
      },
    },
    ['/share-test2']: {
      title: 'dummy2',
      meta: {
        description: 'dummy',
        'og:image': 'http://example.com/dummy2.png',
      },
    },
  },
});
build pug & html injection
reproduction.start({
  src: `${DIST}/index.pug`,
  routes: {
    ['/share-test3']: {
      locals: {
        title: 'dummy3',
        description: 'dummy3',
        shareImage: 'http://example.com/dummy3.png',
      },
    },
  },
});