From 9e742fe3c2499402c63cdbbc41b89c9f3d828ee6 Mon Sep 17 00:00:00 2001 From: Haoliang Gao Date: Fri, 2 Jun 2017 21:16:59 +0800 Subject: [PATCH] fix: don't create plugin index by tools, should support i18n (#16) --- lib/base.js | 2 -- lib/themes/egg/layout/plugin.swig | 2 +- test/build.test.js | 10 +++++----- .../fixtures/framework/docs/source/en/plugins/index.md | 3 +++ .../framework/docs/source/zh-cn/plugins/index.md | 3 +++ 5 files changed, 12 insertions(+), 8 deletions(-) create mode 100644 test/fixtures/framework/docs/source/en/plugins/index.md create mode 100644 test/fixtures/framework/docs/source/zh-cn/plugins/index.md diff --git a/lib/base.js b/lib/base.js index c308d68b..5df9cd5f 100644 --- a/lib/base.js +++ b/lib/base.js @@ -156,8 +156,6 @@ class DocToolsBase extends Command { data += `- ${name}\n`; } - yield fs.writeFile(path.join(sourceDir, 'en/plugins/index.md'), 'layout: plugin\n---\n'); - yield fs.writeFile(path.join(sourceDir, 'zh-cn/plugins/index.md'), 'layout: plugin\n---\n'); yield this._writeData('plugins.yml', data); } diff --git a/lib/themes/egg/layout/plugin.swig b/lib/themes/egg/layout/plugin.swig index 3703f6e7..73170a91 100644 --- a/lib/themes/egg/layout/plugin.swig +++ b/lib/themes/egg/layout/plugin.swig @@ -1,6 +1,6 @@
-

内置插件列表

+

{{page.title}}

    {% for plugin in site.data.plugins %}
  • diff --git a/test/build.test.js b/test/build.test.js index 1aeb7f0c..df4bbd4b 100644 --- a/test/build.test.js +++ b/test/build.test.js @@ -87,11 +87,6 @@ describe('test/build.test.js', () => { const pluginData = yield fs.readFile(path.join(target, 'source/_data/plugins.yml'), 'utf8'); assert(pluginData.includes('- onerror\n')); - let pluginIndex = yield fs.readFile(path.join(target, 'source/zh-cn/plugins/index.md'), 'utf8'); - assert(pluginIndex.includes('layout: plugin\n')); - pluginIndex = yield fs.readFile(path.join(target, 'source/en/plugins/index.md'), 'utf8'); - assert(pluginIndex.includes('layout: plugin\n')); - const pluginDocs = yield fs.readdir(path.join(target, 'source/zh-cn/plugins')); assert(pluginDocs.length === 14); @@ -99,6 +94,11 @@ describe('test/build.test.js', () => { assert(pluginA.includes('中文文档')); pluginA = yield fs.readFile(path.join(target, 'source/en/plugins/a.md'), 'utf8'); assert(pluginA.includes('English Document')); + + let pluginIndex = yield fs.readFile(path.join(target, 'public/zh-cn/plugins/index.html'), 'utf8'); + assert(pluginIndex.includes('内置插件列表')); + pluginIndex = yield fs.readFile(path.join(target, 'public/en/plugins/index.html'), 'utf8'); + assert(pluginIndex.includes('Plugin List')); }); }); diff --git a/test/fixtures/framework/docs/source/en/plugins/index.md b/test/fixtures/framework/docs/source/en/plugins/index.md new file mode 100644 index 00000000..67234727 --- /dev/null +++ b/test/fixtures/framework/docs/source/en/plugins/index.md @@ -0,0 +1,3 @@ +layout: plugin +title: Plugin List +--- diff --git a/test/fixtures/framework/docs/source/zh-cn/plugins/index.md b/test/fixtures/framework/docs/source/zh-cn/plugins/index.md new file mode 100644 index 00000000..eab94a69 --- /dev/null +++ b/test/fixtures/framework/docs/source/zh-cn/plugins/index.md @@ -0,0 +1,3 @@ +layout: plugin +title: 内置插件列表 +---