feat: add siteConfig loader

This commit is contained in:
endiliey 2018-07-28 16:06:07 +08:00
parent 06faff3474
commit 94c45e36cb
11 changed files with 4726 additions and 51 deletions

View file

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

View file

@ -0,0 +1,5 @@
---
title: Hello, World !
---
Hello World

View file

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

View file

@ -0,0 +1,5 @@
---
title: Hello, World !
---
Hello World

View file

@ -0,0 +1,28 @@
const path = require('path');
const fs = require('fs');
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)).toMatchInlineSnapshot(`
Object {
"description": "Hello World",
"title": "Hello World",
}
`);
});
test('custom', () => {
expect(loadConfig(customDir)).toMatchInlineSnapshot(`
Object {
"base": "blogi",
"description": "Hello World",
"dest": "blogi",
"title": "Hello World",
}
`);
});
});