read demo from demo folder

This commit is contained in:
afc163 2015-05-16 15:03:33 +08:00
parent a346311d9e
commit d83608dff4
5 changed files with 35 additions and 4 deletions

View File

@ -0,0 +1,14 @@
# 基本型
- description: 你说什么我还是听不清。
---
````html
<select>
<option>选项一</option>
<option>选项二</option>
<option>选项三</option>
</select>
````

View File

@ -6,6 +6,7 @@ var CodeBox = React.createClass({
}; };
}, },
componentDidMount: function() { componentDidMount: function() {
this.props.src = this.props.src.replace(/\.md$/, '.html');
$.get('/' + this.props.src).then(function(data) { $.get('/' + this.props.src).then(function(data) {
var item = $(data); var item = $(data);
item.find('.highlight').appendTo(item); item.find('.highlight').appendTo(item);
@ -23,7 +24,10 @@ var CodeBox = React.createClass({
render: function() { render: function() {
var html = this.state.html; var html = this.state.html;
return ( return (
<div className="code-box" onClick={this.handleClick} dangerouslySetInnerHTML={{__html: html}}></div> <div className="code-box"
onClick={this.handleClick}
dangerouslySetInnerHTML={{__html: html}}>
</div>
); );
} }
}); });

View File

@ -379,7 +379,7 @@ footer ul li > a {
.main-container { .main-container {
width: calc(100% - 240px); width: calc(100% - 240px);
padding: 30px 40px; padding: 30px 40px 80px;
-webkit-animation: xRightMatrix .5s ease-out .5s backwards; -webkit-animation: xRightMatrix .5s ease-out .5s backwards;
animation: xRightMatrix .5s ease-out .5s backwards; animation: xRightMatrix .5s ease-out .5s backwards;
} }

View File

@ -97,8 +97,10 @@
<script type="text/jsx"> <script type="text/jsx">
React.render( React.render(
<CodeBoxes> <CodeBoxes>
<CodeBox src="components/button/demo/basic.html"></CodeBox> {%- set items = resource.pages|under(post.meta.directory) %}
<CodeBox src="components/button/demo/basic.html"></CodeBox> {%- for item in items %}
<CodeBox src="{{item.meta.filepath}}"></CodeBox>
{%- endfor %}
</CodeBoxes>, </CodeBoxes>,
document.getElementById('code-boxes') document.getElementById('code-boxes')
); );

View File

@ -48,6 +48,17 @@ module.exports = function(nico) {
}).filter(function(item) { }).filter(function(item) {
return item; return item;
})); }));
},
under: function(pages, directory) {
var ret = [];
Object.keys(pages).forEach(function(key) {
var page = pages[key];
console.log(key, directory);
if (key.indexOf(directory + '/demo/') === 0) {
ret.push(page);
}
});
return ret;
} }
}; };