Advertisement
Coldsewoo

Untitled

Aug 18th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. new PrerenderSPAPlugin({
  2.       // Required - The path to the webpack-outputted app to prerender.
  3.       staticDir: path.join(__dirname, '../web'),
  4.       // Required - Routes to render.
  5.       routes: ['/', '/blog', '/currency'],
  6.       postProcess(context) {
  7.           context.path = context.originalPath;
  8.           const titles = {
  9.             '/': 'Coldsewoo',
  10.             '/blog': 'Coldsewoo - a blog',
  11.             '/currency': 'Coldsewoo - currency',
  12.           };
  13.           const desc = {
  14.             '/': 'Home page',
  15.             '/blog': 'blog',
  16.             '/currency': 'Currency exchange information',
  17.           };
  18.           context.html = context.html.replace(
  19.             /<title>[^<]*<\/title>/i,
  20.             `<meta name="description" content="${desc[context.route]}"><meta property="og:title" content="${titles[context.route]}"><meta property="og:type" content="website"><meta property="og:site_name" content="Coldsewoo web"><meta property="og:description" content="${desc[context.route]}"><meta property="fb:admins" content="coldsewoo"><meta name="twitter:card" content="app"><meta name="twitter:site" content="@corysmc"><meta name="twitter:title" content="${titles[context.route]}"><meta name="twitter:description" content="${desc[context.route]}"><title>${titles[context.route]}</title>`
  21.           )
  22.           return context;
  23.        },
  24.     }),
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement