Fix absolute paths in html

This commit is contained in:
LordMathis 2019-02-18 21:27:43 +01:00
parent 23ffc87168
commit c2732983d0
2 changed files with 4 additions and 3 deletions

View File

@ -1,12 +1,13 @@
import fs from 'fs'
import jsonfile from 'jsonfile'
import path from 'path'
import config from '../../config.json'
export function getData (reqPath = '') {
if (reqPath === '') {
return readData(config.dataPath)
} else {
const fileName = '../../renders/' + reqPath + '.html'
const fileName = path.join(process.cwd(), 'renders/', reqPath + '.html')
return readFile(fileName)
}
};

View File

@ -34,13 +34,13 @@ function renderFullPage (html, data) {
<!-- Font Awesome -->
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" rel="preload" integrity="sha384-T8Gy5hrqNKT+hzMclPo118YTQO6cYprQmhrYwIiQ/3axmI1hQomh7Ud2hPOy8SP1" crossorigin="anonymous">
<!-- Stylesheet -->
<link href="static/bundle.css" rel="stylesheet" rel="preload">
<link href="/static/bundle.css" rel="stylesheet" rel="preload">
<!-- Initial Data -->
<script>window.__INITIAL_DATA__ = ${serialize(data)}</script>
</head>
<body>
<div id="root">${html}</div>
<script src="static/bundle.js" async></script>
<script src="/static/bundle.js" async></script>
</body>
</html>
`