1 |
|
2 |
|
3 | var default_meta = require('./default-metadata.json');
|
4 |
|
5 | module.exports = function generatePage(state){
|
6 | var { content } = state;
|
7 | var meta = Object.assign({}, default_meta, state.meta);
|
8 |
|
9 | return `<!DOCTYPE html>
|
10 | <html lang="${meta.lang}">
|
11 | <head>
|
12 | <title>${meta.title}</title>
|
13 | <meta charset="${meta.charset}">
|
14 | <meta name="viewport" content="${meta.viewport}">
|
15 | <meta name="description" content="${meta.description}">
|
16 | <meta name="keywords" content="${meta.keywords}">
|
17 | <meta name="author" content="${meta.author}">
|
18 | ${
|
19 | meta.hasOwnProperty('extra')
|
20 | ?meta.extra.length
|
21 | ? meta.extra.map(value => `<meta ${value}>`)
|
22 | : ''
|
23 | :''
|
24 | }
|
25 | <meta name="description" content="${meta.description}">
|
26 | ${
|
27 | meta.hasOwnProperty('stylesheets')
|
28 | ?meta.stylesheets.length
|
29 | ?meta.stylesheets.map(value => `<link rel="stylesheet" href="${value}">`).join('\n')
|
30 | : ''
|
31 | : ''
|
32 | }
|
33 | <link rel="icon" type="image/png" href="${meta.favicon}">
|
34 | </head>
|
35 | <body>
|
36 | ${content}
|
37 |
|
38 | ${
|
39 | meta.hasOwnProperty('scripts')
|
40 | ?meta.scripts.length
|
41 | ?meta.scripts.map(value => `<script src="${value}"></script>`).join('\n')
|
42 | : ''
|
43 | : ''
|
44 | }
|
45 | </body>
|
46 | </html>`;
|
47 | };
|