chore(loader): prettier & eslint

This commit is contained in:
endiliey 2018-07-28 18:48:37 +08:00
parent d2e12a8e61
commit 7116374adf
5 changed files with 108 additions and 118 deletions

View file

@ -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
};

View file

@ -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;
};

View file

@ -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

View file

@ -1,5 +1,4 @@
const path = require('path');
const fs = require('fs');
const loadBlog = require('../../lib/loader/blog');
describe('loadBlog', () => {

View file

@ -1,5 +1,4 @@
const path = require('path');
const fs = require('fs');
const loadConfig = require('../../lib/loader/config');
describe('loadConfig', () => {