mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-14 01:27:35 +02:00
* fix: #1114 static files in `blog/assets` is not working * lint fix
This commit is contained in:
parent
db6017903b
commit
a1e7af7e0e
6 changed files with 114 additions and 23 deletions
|
@ -4,12 +4,12 @@
|
|||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const cssnano = require('cssnano');
|
||||
const autoprefixer = require('autoprefixer');
|
||||
const postcss = require('postcss');
|
||||
const path = require('path');
|
||||
const escapeStringRegexp = require('escape-string-regexp');
|
||||
const siteConfig = require('../../website/siteConfig.js');
|
||||
|
||||
function getSubDir(file, refDir) {
|
||||
const subDir = path.dirname(path.relative(refDir, file)).replace(/\\/g, '/');
|
||||
|
@ -66,10 +66,27 @@ function autoPrefixCss(cssContent) {
|
|||
.then(result => result.css);
|
||||
}
|
||||
|
||||
function replaceAssetsLink(oldContent, location) {
|
||||
let fencedBlock = false;
|
||||
const lines = oldContent.split('\n').map(line => {
|
||||
if (line.trim().startsWith('```')) {
|
||||
fencedBlock = !fencedBlock;
|
||||
}
|
||||
return fencedBlock
|
||||
? line
|
||||
: line.replace(
|
||||
/\]\(assets\//g,
|
||||
`](${siteConfig.baseUrl}${location}/assets/`,
|
||||
);
|
||||
});
|
||||
return lines.join('\n');
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getSubDir,
|
||||
getLanguage,
|
||||
isSeparateCss,
|
||||
minifyCss,
|
||||
autoPrefixCss,
|
||||
replaceAssetsLink,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue