add react

This commit is contained in:
afc163 2015-05-12 17:28:59 +08:00
parent 35e9a4b836
commit 892432d11e
3 changed files with 20 additions and 7 deletions

6
static/code.jsx Normal file
View File

@ -0,0 +1,6 @@
/*jshint ignore:start */
var CodeBox = React.createClass({
render: function() {
return <pre><code>{this.props.code}</code></pre>;
}
});

View File

@ -2,10 +2,3 @@
{% block title %}{{post.title}} - {{config.site.name}}{% endblock %}
{% block description %}{% if post.summay %}{{post.summary}}{% endif %}{% endblock %}
{% block main -%}
{%- include "aside.html" %}
<article class="markdown">
<h1>{{ post.title }}</h1>
{{ post.html }}
</article>
{%- endblock %}

View File

@ -13,6 +13,13 @@
<link rel="stylesheet" href="/static/tomorrow.css">
<script src="https://a.alipayobjects.com/jquery/jquery/1.11.1/jquery.js"></script>
<script src="/static/script.js"></script>
<!-- react -->
<script src="https://t.alipayobjects.com/images/T12TdfXlpbXXXXXXXX.js"></script>
<!-- JSXTransformer -->
<script src="https://t.alipayobjects.com/images/T1jCFfXdNiXXXXXXXX.js"></script>
{%- if post.meta.template === 'component' %}
<script type="text/jsx" src="/static/code.jsx"></script>
{%- endif %}
</head>
<body class="{%- if post.filepath === 'README.md' %}index-page{%- endif %}">
<header id="header">
@ -82,6 +89,13 @@
{%- endif %}
</h1>
{{ post.html }}
<div id="code-boxes"></div>
<script type="text/jsx">
React.render(
<CodeBox code="123"></CodeBox>,
document.getElementById('code-boxes')
);
</script>
</article>
</section>
{%- endif %}