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 fs from 'fs'
import jsonfile from 'jsonfile' import jsonfile from 'jsonfile'
import path from 'path'
import config from '../../config.json' import config from '../../config.json'
export function getData (reqPath = '') { export function getData (reqPath = '') {
if (reqPath === '') { if (reqPath === '') {
return readData(config.dataPath) return readData(config.dataPath)
} else { } else {
const fileName = '../../renders/' + reqPath + '.html' const fileName = path.join(process.cwd(), 'renders/', reqPath + '.html')
return readFile(fileName) return readFile(fileName)
} }
}; };

View File

@ -34,13 +34,13 @@ function renderFullPage (html, data) {
<!-- Font Awesome --> <!-- 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"> <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 --> <!-- Stylesheet -->
<link href="static/bundle.css" rel="stylesheet" rel="preload"> <link href="/static/bundle.css" rel="stylesheet" rel="preload">
<!-- Initial Data --> <!-- Initial Data -->
<script>window.__INITIAL_DATA__ = ${serialize(data)}</script> <script>window.__INITIAL_DATA__ = ${serialize(data)}</script>
</head> </head>
<body> <body>
<div id="root">${html}</div> <div id="root">${html}</div>
<script src="static/bundle.js" async></script> <script src="/static/bundle.js" async></script>
</body> </body>
</html> </html>
` `