refactor: rename loader to load as not to confuse webpack loader

This commit is contained in:
endiliey 2018-08-07 00:41:05 +08:00
parent 36eee2941a
commit 9fef99cb18
15 changed files with 4 additions and 131 deletions

View file

@ -12,7 +12,7 @@ const portfinder = require('portfinder');
const serve = require('webpack-serve'); const serve = require('webpack-serve');
const webpackNiceLog = require('webpack-nicelog'); const webpackNiceLog = require('webpack-nicelog');
const HtmlWebpackPlugin = require('html-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin');
const load = require('../loader'); const load = require('../load');
const createDevConfig = require('../webpack/dev'); const createDevConfig = require('../webpack/dev');
async function getPort(port) { async function getPort(port) {

View file

@ -10,7 +10,7 @@ function fileToPath(file) {
if (indexRE.test(file)) { if (indexRE.test(file)) {
return file.replace(indexRE, '/$1'); return file.replace(indexRE, '/$1');
} }
return `/${file.replace(mdRE, '').replace(/\\/g, '/')}.html`; return `/${file.replace(mdRE, '').replace(/\\/g, '/')}`;
} }
function parse(fileString) { function parse(fileString) {

View file

@ -10,7 +10,7 @@ function fileToPath(file) {
if (indexRE.test(file)) { if (indexRE.test(file)) {
return file.replace(indexRE, '/$1'); return file.replace(indexRE, '/$1');
} }
return `/${file.replace(mdRE, '').replace(/\\/g, '/')}.html`; return `/${file.replace(mdRE, '').replace(/\\/g, '/')}`;
} }
function parse(fileString) { function parse(fileString) {
@ -22,6 +22,7 @@ function parse(fileString) {
return {metadata, content}; return {metadata, content};
} }
// still TODO. still copy paste from blog logic
async function loadDocs(siteDir) { async function loadDocs(siteDir) {
const blogFiles = await globby(['**/*.md'], { const blogFiles = await globby(['**/*.md'], {
cwd: siteDir cwd: siteDir

View file

@ -1,6 +0,0 @@
module.exports = {
title: 'Hello World',
description: 'Hello World',
dest: 'blogi',
base: 'blogi'
};

View file

@ -1,6 +0,0 @@
---
title: Lorem ipsum
date: 2018-06-20
---
Lorem ipsum

View file

@ -1,5 +0,0 @@
---
title: Baz
date: 2018-05-20
---
Life is so good

View file

@ -1,6 +0,0 @@
---
title: Hello, World !
date: 2018-07-28
---
Hello World

View file

@ -1,4 +0,0 @@
module.exports = {
title: 'Hello World',
description: 'Hello World'
};

View file

@ -1,6 +0,0 @@
---
title: Hello, World !
date: 2018-07-28
---
Hello World

View file

@ -1,46 +0,0 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`loadBlog custom 1`] = `
Array [
Object {
"content": "
Hello World
",
"date": 2018-07-28T00:00:00.000Z,
"path": "/hello.html",
"title": "Hello, World !",
},
Object {
"content": "
Lorem ipsum
",
"date": 2018-06-20T00:00:00.000Z,
"path": "/foo/bar.html",
"title": "Lorem ipsum",
},
Object {
"content": "
Life is so good
",
"date": 2018-05-20T00:00:00.000Z,
"path": "/foo/baz.html",
"title": "Baz",
},
]
`;
exports[`loadBlog simple 1`] = `
Array [
Object {
"content": "
Hello World
",
"date": 2018-07-28T00:00:00.000Z,
"path": "/hello.html",
"title": "Hello, World !",
},
]
`;

View file

@ -1,17 +0,0 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`loadConfig custom 1`] = `
Object {
"base": "blogi",
"description": "Hello World",
"dest": "blogi",
"title": "Hello World",
}
`;
exports[`loadConfig simple 1`] = `
Object {
"description": "Hello World",
"title": "Hello World",
}
`;

View file

@ -1,17 +0,0 @@
const path = require('path');
const loadBlog = require('../../lib/loader/blog');
describe('loadBlog', () => {
const simpleDir = path.join(__dirname, '__fixtures__', 'simple');
const customDir = path.join(__dirname, '__fixtures__', 'custom');
test('simple', async () => {
const blogDatas = await loadBlog(simpleDir);
expect(blogDatas).toMatchSnapshot();
});
test('custom', async () => {
const blogDatas = await loadBlog(customDir);
expect(blogDatas).toMatchSnapshot();
});
});

View file

@ -1,15 +0,0 @@
const path = require('path');
const loadConfig = require('../../lib/loader/config');
describe('loadConfig', () => {
const simpleDir = path.join(__dirname, '__fixtures__', 'simple');
const customDir = path.join(__dirname, '__fixtures__', 'custom');
test('simple', () => {
expect(loadConfig(simpleDir)).toMatchSnapshot();
});
test('custom', () => {
expect(loadConfig(customDir)).toMatchSnapshot();
});
});