From 5179ffbbe195825c220efa980079f014805ca684 Mon Sep 17 00:00:00 2001 From: Benjy Cui Date: Wed, 19 Oct 2016 17:39:25 +0800 Subject: [PATCH] site: support demo[only] --- site/theme/template/Content/ComponentDoc.jsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/site/theme/template/Content/ComponentDoc.jsx b/site/theme/template/Content/ComponentDoc.jsx index 8d77bfec29..44a5c10033 100644 --- a/site/theme/template/Content/ComponentDoc.jsx +++ b/site/theme/template/Content/ComponentDoc.jsx @@ -31,14 +31,15 @@ export default class ComponentDoc extends React.Component { const { doc, location } = props; const { content, meta } = doc; const locale = this.context.intl.locale; - const demos = Object.keys(props.demos).map(key => props.demos[key]) - .filter(demoData => !demoData.meta.hidden); + const demos = Object.keys(props.demos).map(key => props.demos[key]); const expand = this.state.expandAll; const isSingleCol = meta.cols === 1; const leftChildren = []; const rightChildren = []; - demos.sort((a, b) => a.meta.order - b.meta.order) + const showedDemo = demos.some(demo => demo.meta.only) ? + demos.filter(demo => demo.meta.only) : demos.filter(demo => !demo.meta.hidden); + showedDemo.sort((a, b) => a.meta.order - b.meta.order) .forEach((demoData, index) => { if (index % 2 === 0 || isSingleCol) { leftChildren.push(