diff --git a/lib/commands/start.js b/lib/commands/start.js index 8597da303d..fa26169e3f 100644 --- a/lib/commands/start.js +++ b/lib/commands/start.js @@ -12,7 +12,7 @@ const portfinder = require('portfinder'); const serve = require('webpack-serve'); const webpackNiceLog = require('webpack-nicelog'); const HtmlWebpackPlugin = require('html-webpack-plugin'); -const load = require('../loader'); +const load = require('../load'); const createDevConfig = require('../webpack/dev'); async function getPort(port) { diff --git a/lib/loader/blog.js b/lib/load/blog.js similarity index 94% rename from lib/loader/blog.js rename to lib/load/blog.js index 7d5704d53d..c2dccf848d 100644 --- a/lib/loader/blog.js +++ b/lib/load/blog.js @@ -10,7 +10,7 @@ function fileToPath(file) { if (indexRE.test(file)) { return file.replace(indexRE, '/$1'); } - return `/${file.replace(mdRE, '').replace(/\\/g, '/')}.html`; + return `/${file.replace(mdRE, '').replace(/\\/g, '/')}`; } function parse(fileString) { diff --git a/lib/loader/config.js b/lib/load/config.js similarity index 100% rename from lib/loader/config.js rename to lib/load/config.js diff --git a/lib/loader/docs.js b/lib/load/docs.js similarity index 90% rename from lib/loader/docs.js rename to lib/load/docs.js index a117b5deeb..d5dfa0e7ce 100644 --- a/lib/loader/docs.js +++ b/lib/load/docs.js @@ -10,7 +10,7 @@ function fileToPath(file) { if (indexRE.test(file)) { return file.replace(indexRE, '/$1'); } - return `/${file.replace(mdRE, '').replace(/\\/g, '/')}.html`; + return `/${file.replace(mdRE, '').replace(/\\/g, '/')}`; } function parse(fileString) { @@ -22,6 +22,7 @@ function parse(fileString) { return {metadata, content}; } +// still TODO. still copy paste from blog logic async function loadDocs(siteDir) { const blogFiles = await globby(['**/*.md'], { cwd: siteDir diff --git a/lib/loader/index.js b/lib/load/index.js similarity index 100% rename from lib/loader/index.js rename to lib/load/index.js diff --git a/test/loader/__fixtures__/custom/config.js b/test/loader/__fixtures__/custom/config.js deleted file mode 100644 index 0c4661619e..0000000000 --- a/test/loader/__fixtures__/custom/config.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - title: 'Hello World', - description: 'Hello World', - dest: 'blogi', - base: 'blogi' -}; diff --git a/test/loader/__fixtures__/custom/foo/bar.md b/test/loader/__fixtures__/custom/foo/bar.md deleted file mode 100644 index ba294597fd..0000000000 --- a/test/loader/__fixtures__/custom/foo/bar.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -title: Lorem ipsum -date: 2018-06-20 ---- - -Lorem ipsum diff --git a/test/loader/__fixtures__/custom/foo/baz.md b/test/loader/__fixtures__/custom/foo/baz.md deleted file mode 100644 index c4e0cbf40d..0000000000 --- a/test/loader/__fixtures__/custom/foo/baz.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -title: Baz -date: 2018-05-20 ---- -Life is so good diff --git a/test/loader/__fixtures__/custom/hello.md b/test/loader/__fixtures__/custom/hello.md deleted file mode 100644 index 6d86ef4978..0000000000 --- a/test/loader/__fixtures__/custom/hello.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -title: Hello, World ! -date: 2018-07-28 ---- - -Hello World diff --git a/test/loader/__fixtures__/simple/config.js b/test/loader/__fixtures__/simple/config.js deleted file mode 100644 index 22d383d3c4..0000000000 --- a/test/loader/__fixtures__/simple/config.js +++ /dev/null @@ -1,4 +0,0 @@ -module.exports = { - title: 'Hello World', - description: 'Hello World' -}; diff --git a/test/loader/__fixtures__/simple/hello.md b/test/loader/__fixtures__/simple/hello.md deleted file mode 100644 index 6d86ef4978..0000000000 --- a/test/loader/__fixtures__/simple/hello.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -title: Hello, World ! -date: 2018-07-28 ---- - -Hello World diff --git a/test/loader/__snapshots__/blog.test.js.snap b/test/loader/__snapshots__/blog.test.js.snap deleted file mode 100644 index 04dd3fe1ad..0000000000 --- a/test/loader/__snapshots__/blog.test.js.snap +++ /dev/null @@ -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 !", - }, -] -`; diff --git a/test/loader/__snapshots__/config.test.js.snap b/test/loader/__snapshots__/config.test.js.snap deleted file mode 100644 index 21049a5948..0000000000 --- a/test/loader/__snapshots__/config.test.js.snap +++ /dev/null @@ -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", -} -`; diff --git a/test/loader/blog.test.js b/test/loader/blog.test.js deleted file mode 100644 index 28f61e0b90..0000000000 --- a/test/loader/blog.test.js +++ /dev/null @@ -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(); - }); -}); diff --git a/test/loader/config.test.js b/test/loader/config.test.js deleted file mode 100644 index f1b137dbdf..0000000000 --- a/test/loader/config.test.js +++ /dev/null @@ -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(); - }); -});