mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 23:57:22 +02:00
We look for fonts object within siteConfig.js
This commit is contained in:
parent
e0704d0f55
commit
a241a46669
3 changed files with 38 additions and 1 deletions
|
@ -346,6 +346,18 @@ function execute() {
|
|||
codeColor
|
||||
);
|
||||
|
||||
if (siteConfig.fonts) {
|
||||
Object.keys(siteConfig.fonts).forEach(key => {
|
||||
const fontString = siteConfig.fonts[key]
|
||||
.map(font => '"' + font + '"')
|
||||
.join(', ');
|
||||
cssContent = cssContent.replace(
|
||||
new RegExp('\\$' + key, 'g'),
|
||||
fontString
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
mkdirp.sync(path.dirname(targetFile));
|
||||
fs.writeFileSync(targetFile, cssContent);
|
||||
} else if (!fs.lstatSync(file).isDirectory()) {
|
||||
|
@ -357,7 +369,7 @@ function execute() {
|
|||
// copy all static files from user
|
||||
files = glob.sync(join(CWD, 'static', '**'), {dot: true});
|
||||
files.forEach(file => {
|
||||
// parse css files to replace colors according to siteConfig
|
||||
// parse css files to replace colors and fonts according to siteConfig
|
||||
if (file.match(/\.css$/) && !isSeparateCss(file)) {
|
||||
const mainCss = join(buildDir, 'css', 'main.css');
|
||||
let cssContent = fs.readFileSync(file, 'utf8');
|
||||
|
@ -368,6 +380,18 @@ function execute() {
|
|||
cssContent = cssContent.replace(new RegExp('\\$' + key, 'g'), color);
|
||||
});
|
||||
|
||||
if (siteConfig.fonts) {
|
||||
Object.keys(siteConfig.fonts).forEach(key => {
|
||||
const fontString = siteConfig.fonts[key]
|
||||
.map(font => '"' + font + '"')
|
||||
.join(', ');
|
||||
cssContent = cssContent.replace(
|
||||
new RegExp('\\$' + key, 'g'),
|
||||
fontString
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
fs.writeFileSync(mainCss, cssContent);
|
||||
} else if (!fs.lstatSync(file).isDirectory()) {
|
||||
let parts = file.split('/static/');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue