mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-13 17:17:28 +02:00
refactor: rename loader to load as not to confuse webpack loader
This commit is contained in:
parent
36eee2941a
commit
9fef99cb18
15 changed files with 4 additions and 131 deletions
|
@ -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) {
|
||||||
|
|
|
@ -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) {
|
|
@ -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
|
|
@ -1,6 +0,0 @@
|
||||||
module.exports = {
|
|
||||||
title: 'Hello World',
|
|
||||||
description: 'Hello World',
|
|
||||||
dest: 'blogi',
|
|
||||||
base: 'blogi'
|
|
||||||
};
|
|
|
@ -1,6 +0,0 @@
|
||||||
---
|
|
||||||
title: Lorem ipsum
|
|
||||||
date: 2018-06-20
|
|
||||||
---
|
|
||||||
|
|
||||||
Lorem ipsum
|
|
|
@ -1,5 +0,0 @@
|
||||||
---
|
|
||||||
title: Baz
|
|
||||||
date: 2018-05-20
|
|
||||||
---
|
|
||||||
Life is so good
|
|
|
@ -1,6 +0,0 @@
|
||||||
---
|
|
||||||
title: Hello, World !
|
|
||||||
date: 2018-07-28
|
|
||||||
---
|
|
||||||
|
|
||||||
Hello World
|
|
|
@ -1,4 +0,0 @@
|
||||||
module.exports = {
|
|
||||||
title: 'Hello World',
|
|
||||||
description: 'Hello World'
|
|
||||||
};
|
|
|
@ -1,6 +0,0 @@
|
||||||
---
|
|
||||||
title: Hello, World !
|
|
||||||
date: 2018-07-28
|
|
||||||
---
|
|
||||||
|
|
||||||
Hello World
|
|
|
@ -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 !",
|
|
||||||
},
|
|
||||||
]
|
|
||||||
`;
|
|
|
@ -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",
|
|
||||||
}
|
|
||||||
`;
|
|
|
@ -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();
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -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();
|
|
||||||
});
|
|
||||||
});
|
|
Loading…
Add table
Add a link
Reference in a new issue