mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-16 18:46:57 +02:00
chore(loader): prettier & eslint
This commit is contained in:
parent
d2e12a8e61
commit
7116374adf
5 changed files with 108 additions and 118 deletions
|
@ -3,18 +3,13 @@ const path = require('path');
|
|||
const fm = require('front-matter');
|
||||
const globby = require('globby');
|
||||
const indexRE = /(^|.*\/)index\.md$/i;
|
||||
const extRE = /\.md$/;
|
||||
const mdRE = /\.md$/;
|
||||
|
||||
function fileToPath(file) {
|
||||
if (indexRE.test(file)) {
|
||||
// index.md -> /
|
||||
// foo/index.md -> /foo/
|
||||
return file.replace(indexRE, '/$1');
|
||||
} else {
|
||||
// foo.md -> /foo.html
|
||||
// foo/bar.md -> /foo/bar.html
|
||||
return `/${file.replace(extRE, '').replace(/\\/g, '/')}.html`;
|
||||
}
|
||||
return `/${file.replace(mdRE, '').replace(/\\/g, '/')}.html`;
|
||||
}
|
||||
|
||||
function parse(fileString) {
|
||||
|
@ -39,7 +34,7 @@ async function loadBlog(sourceDir) {
|
|||
|
||||
return {
|
||||
path: fileToPath(file),
|
||||
content: content,
|
||||
content,
|
||||
title: metadata.title,
|
||||
date: metadata.date
|
||||
};
|
||||
|
|
|
@ -8,7 +8,7 @@ module.exports = function loadConfig(sourceDir, deleteCache = true) {
|
|||
}
|
||||
let config = {};
|
||||
if (fs.existsSync(configPath)) {
|
||||
config = require(configPath);
|
||||
config = require(configPath); // eslint-disable-line
|
||||
}
|
||||
return config;
|
||||
};
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
const path = require('path');
|
||||
const loadConfig = require('./config');
|
||||
const loadBlog = require('./blog');
|
||||
|
||||
|
@ -9,8 +8,6 @@ module.exports = async function load(sourceDir) {
|
|||
// 2. extract data from all blog files
|
||||
const blogDatas = await loadBlog(sourceDir);
|
||||
|
||||
// 3. TODO
|
||||
|
||||
return {
|
||||
siteConfig,
|
||||
blogDatas
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const loadBlog = require('../../lib/loader/blog');
|
||||
|
||||
describe('loadBlog', () => {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const loadConfig = require('../../lib/loader/config');
|
||||
|
||||
describe('loadConfig', () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue