Skip to content

Commit b992988

Browse files
committed
fix: amend doc server
1 parent af6da61 commit b992988

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ API 解释说明。
2424

2525
- `lang` 表示要获取的文档的语言,目前支持 `zh`/`en` 两种。
2626
- `key` 表示要获取的文档的唯一标识符,这个 `key` 要和文档的文件名一致。
27-
- `sections` 可选参数,表示要获取文档的哪几部分,这里的 `section` 要和制定文档中的 `data-section` 属性一致。如果 `sections` 为空,则表示获取整篇文档。
27+
- `sections` 可选参数,表示要获取文档的哪几部分,这里的 `section` 要和制定文档中的 `data-section` 属性一致。如果不传 `sections` `sections` 为空数组,则表示获取整篇文档。
2828

2929
**返回值**
3030

src/server/controllers/docs.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ export function retrieveDocs(criteria, htmlDocs) {
2424
const fragment = JSDOM.fragment(doc.data);
2525
item.sections.forEach(section => {
2626
const element = fragment.querySelector(`[data-section=${section}]`);
27-
if (element) {
28-
result.data.push(element.outerHTML);
29-
}
27+
result.data.push(element?.outerHTML);
3028
});
3129
results.push(result);
3230
});

0 commit comments

Comments
 (0)