@@ -15,13 +15,23 @@ import React, {Component} from 'react';
15
15
import TitleAndMetaTags from 'components/TitleAndMetaTags' ;
16
16
import { colors , media , sharedStyles } from 'theme' ;
17
17
import createOgUrl from 'utils/createOgUrl' ;
18
+ import loadScript from 'utils/loadScript' ;
19
+ import { babelURL } from 'site-constants' ;
20
+ import ReactDOM from 'react-dom' ;
18
21
19
22
class Home extends Component {
20
23
componentDidMount ( ) {
21
- mountCodeExample ( 'helloExample' , HELLO_COMPONENT ) ;
22
- mountCodeExample ( 'timerExample' , TIMER_COMPONENT ) ;
23
- mountCodeExample ( 'todoExample' , TODO_COMPONENT ) ;
24
- mountCodeExample ( 'markdownExample' , MARKDOWN_COMPONENT ) ;
24
+ renderExamplePlaceholder ( 'helloExample' ) ;
25
+ renderExamplePlaceholder ( 'timerExample' ) ;
26
+ renderExamplePlaceholder ( 'todoExample' ) ;
27
+ renderExamplePlaceholder ( 'markdownExample' ) ;
28
+
29
+ loadScript ( babelURL ) . then ( ( ) => {
30
+ mountCodeExample ( 'helloExample' , HELLO_COMPONENT ) ;
31
+ mountCodeExample ( 'timerExample' , TIMER_COMPONENT ) ;
32
+ mountCodeExample ( 'todoExample' , TODO_COMPONENT ) ;
33
+ mountCodeExample ( 'markdownExample' , MARKDOWN_COMPONENT ) ;
34
+ } ) ;
25
35
}
26
36
27
37
render ( ) {
@@ -163,6 +173,16 @@ Home.propTypes = {
163
173
location : PropTypes . object . isRequired ,
164
174
} ;
165
175
176
+ // TODO Improve this temporarily placeholder as part of
177
+ // converting the home page from markdown template to a Gatsby
178
+ // page (see issue #2)
179
+ function renderExamplePlaceholder ( containerId ) {
180
+ ReactDOM . render (
181
+ < h4 > Loading code example...</ h4 > ,
182
+ document . getElementById ( containerId ) ,
183
+ ) ;
184
+ }
185
+
166
186
const CtaItem = ( { children, primary = false } ) => (
167
187
< div
168
188
css = { {
0 commit comments