1
1
mirror of https://github.com/c8r/x0.git synced 2024-09-11 21:57:26 +03:00

Only render static once

This commit is contained in:
Brent Jackson 2017-12-07 12:54:30 -05:00
parent eea30867fc
commit 4166117955
3 changed files with 33 additions and 8 deletions

View File

@ -1,5 +1,30 @@
<!DOCTYPE html>
<meta charset='utf-8'>
<title>Hello</title><meta name="viewport" content="width=device-width,initial-scale=1"/><div><h1>Hello <!-- -->32</h1><button>+</button></div>
<script id='__initial-props__' type='application/json'>{"count":32,"title":"Compositor x0","_basename":"/x0","d":"docs","outDir":"docs"}</script>
<title>Compositor x0</title><meta name="description"/><meta name="twitter:card" content="summary"/><meta name="twitter:site" content="@getcompositor"/><meta name="twitter:title" content="Compositor x0"/><meta name="twitter:title"/><meta name="twitter:image" content="https://compositor.io/logo/dist/compositor-black.png"/><style>
*{box-sizing:border-box}
body {
font-family: -apple-system, BlinkMacSystemFont, sans-serif;
line-height: 1.5;
min-height: 100vh;
color: white;
background-color: black;
-webkit-font-smoothing: antialiased;
}
</style><div class="_cxs0 _cxs1 _cxs2 _cxs3"><nav><div class="_cxs4 _cxs5 _cxs6 _cxs3 _cxs3"><a href="https://compositor.io" class="_cxs7 _cxs3"><div class="_cxs4 _cxs5 _cxs8 _cxs3"><svg xmlns="http://www.w3.org/2000/svg" viewBox="-12 -12 24 24" style="display:block;margin:0" width="32" height="32"><rect x="-12" y="-12" width="24" height="24" fill="black"></rect><rect x="-4" y="-8" width="8" height="16" fill="white"></rect></svg><div class="_cxs9 _cxs3 _cxsa _cxsb _cxs3 _cxs3">Compositor</div></div></a><div class="_cxsc _cxs3"></div><a href="https://github.com/c8r/x0" class="_cxsd _cxsa _cxse">GitHub</a><a class="twitter-share-button" href="https://twitter.com/intent/tweet">Tweet</a></div></nav><header><div class="_cxsf _cxs3"><h1 m="0" class="_cxsg _cxsh">x0 <!-- -->32</h1><button>+</button><div class="_cxs3 _cxsi _cxsb _cxsj _cxs3">Zero-config React development environment and static site generator</div><div class="_cxsk _cxs3 _cxsl _cxs3 _cxs3">v<!-- -->3.0.0-1</div></div></header><main><div class="_cxs3 _cxs3"><video loop="" autoplay="" src="demo.mp4" class="_cxsm"></video></div><div class="_cxsn _cxs3"><pre class="_cxso _cxsp _cxsq">npm install @compositor/x0</pre></div><section id="features"><div class="_cxsr _cxs3"><div class="_cxs3 _cxss _cxsb _cxsj _cxs3">Features</div><div class="_cxs4 _cxs6 _cxst _cxs3"><div class="_cxsu _cxsv _cxsw _cxsx _cxs3"><div class="_cxs3 _cxsb _cxs3 _cxs3">Isolated development environment</div></div><div class="_cxsu _cxsv _cxsw _cxsx _cxs3"><div class="_cxs3 _cxsb _cxs3 _cxs3">Static site generator</div></div><div class="_cxsu _cxsv _cxsw _cxsx _cxs3"><div class="_cxs3 _cxsb _cxs3 _cxs3">Hot reloading</div></div><div class="_cxsu _cxsv _cxsw _cxsx _cxs3"><div class="_cxs3 _cxsb _cxs3 _cxs3">Works with virtually any React component</div></div><div class="_cxsu _cxsv _cxsw _cxsx _cxs3"><div class="_cxs3 _cxsb _cxs3 _cxs3">No convoluted APIs to learn</div></div><div class="_cxsu _cxsv _cxsw _cxsx _cxs3"><div class="_cxs3 _cxsb _cxs3 _cxs3">No boilerplate required</div></div><div class="_cxsu _cxsv _cxsw _cxsx _cxs3"><div class="_cxs3 _cxsb _cxs3 _cxs3">Routing with react-router</div></div><div class="_cxsu _cxsv _cxsw _cxsx _cxs3"><div class="_cxs3 _cxsb _cxs3 _cxs3">Works with CSS-in-JS libraries like styled-components</div></div><div class="_cxsu _cxsv _cxsw _cxsx _cxs3"><div class="_cxs3 _cxsb _cxs3 _cxs3">Support for async data fetching</div></div></div></div></section><section id="get-started"><div class="_cxsr _cxs3"><div class="_cxs3 _cxss _cxsb _cxs3 _cxs3">Get Started</div><div class="_cxs3 _cxsy _cxs3">Read the docs and get started on GitHub or sign up for updates.</div><a href="https://github.com/c8r/x0" class="_cxsz _cxs10">Documentation</a><a href="https://compositor.io/#sign-up" class="_cxs11 _cxsz _cxs3">Sign Up</a></div></section><footer><div class="_cxs4 _cxsf _cxs3"><div class="_cxs3 _cxsl _cxs3 _cxs3">© 2017 Compositor, Inc.</div></div></footer></main></div><script>
window.twttr = (function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0],
t = window.twttr || {};
if (d.getElementById(id)) return t;
js = d.createElement(s);
js.id = id;
js.src = "https://platform.twitter.com/widgets.js";
fjs.parentNode.insertBefore(js, fjs);
t._e = [];
t.ready = function(f) {
t._e.push(f);
};
return t;
}(document, "script", "twitter-wjs"));
</script>
<script id='__initial-props__' type='application/json'>{"count":32,"features":["Isolated development environment","Static site generator","Hot reloading","Works with virtually any React component","No convoluted APIs to learn","No boilerplate required","Routing with react-router","Works with CSS-in-JS libraries like styled-components","Support for async data fetching"],"title":"Compositor x0","_basename":"/x0","d":"docs","outDir":"docs","hello":"hi","css":""}</script>
<script src='/bundle.js'></script>

View File

@ -33,7 +33,7 @@ const render = (Component, props, isStatic) =>
const renderHTML = async (Component, options) => {
const isStatic = options.static || !options.outDir
let body = render(Component, options, isStatic)
// let body = render(Component, options, isStatic)
const base = options.basename || ''
const script = base + '/bundle.js'
@ -45,13 +45,13 @@ const renderHTML = async (Component, options) => {
const initialProps = await getProps(Object.assign({
Component,
html: body
// html: body
}, options))
const props = Object.assign({}, options, initialProps)
if (hasInitialProps) {
body = render(Component, props, isStatic)
}
// if (hasInitialProps) {
const body = render(Component, props, isStatic)
// }
const html = createHTML({
body,

View File

@ -1,6 +1,6 @@
{
"name": "@compositor/x0",
"version": "3.0.0-1",
"version": "3.0.0-2",
"description": "Zero-config React development environment and static site generator",
"main": "index.js",
"bin": {