Skip to content

Commit

Permalink
fix: don't create plugin index by tools, should support i18n (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
popomore authored Jun 2, 2017
1 parent 9f7c242 commit 9e742fe
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
2 changes: 0 additions & 2 deletions lib/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/themes/egg/layout/plugin.swig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="page-main">
<article class="markdown-body">
<h1>内置插件列表</h1>
<h1>{{page.title}}</h1>
<ul>
{% for plugin in site.data.plugins %}
<li>
Expand Down
10 changes: 5 additions & 5 deletions test/build.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,18 @@ 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);

let pluginA = yield fs.readFile(path.join(target, 'source/zh-cn/plugins/a.md'), 'utf8');
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'));
});
});

Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/framework/docs/source/en/plugins/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
layout: plugin
title: Plugin List
---
3 changes: 3 additions & 0 deletions test/fixtures/framework/docs/source/zh-cn/plugins/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
layout: plugin
title: 内置插件列表
---

0 comments on commit 9e742fe

Please sign in to comment.