fix: do not hardcode siteConfig path (#1150)

* Fix broken build

Do not hardcode path in require to siteConfig

* Just require instead of loadConfig

* Actually use loadConfig

I think the test may be wrong too.

* refactor & nits

* jest mock to fix test

* fix test
This commit is contained in:
Joel Marcey 2018-12-07 10:09:25 -08:00 committed by Endilie Yacop Sucipto
parent 71824a3541
commit c78a8b4262
5 changed files with 19 additions and 11 deletions

View file

@ -4,12 +4,16 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
const CWD = process.cwd();
const React = require('react');
const path = require('path');
const fs = require('fs-extra');
const metadataUtils = require('./metadataUtils');
const {replaceAssetsLink} = require('./utils.js');
const {renderToStaticMarkupWithDoctype} = require('./renderUtils');
const loadConfig = require('./config');
const siteConfig = loadConfig(`${CWD}/siteConfig.js`);
function urlToSource(url) {
if (!url || typeof url !== 'string') {
@ -59,7 +63,10 @@ function getMetadata(file) {
const metadata = Object.assign(
{
path: fileToUrl(file),
content: replaceAssetsLink(result.rawContent, 'blog'),
content: replaceAssetsLink(
result.rawContent,
`${siteConfig.baseUrl}blog`,
),
},
result.metadata,
);