Skip to content

Commit 3b5eb3e

Browse files
committed
first draft of Klipse integration
jsx-in-depth: one klipse snippet
1 parent 38ec8dd commit 3b5eb3e

File tree

5 files changed

+64
-5
lines changed

5 files changed

+64
-5
lines changed

content/docs/introducing-jsx.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ It is called JSX, and it is a syntax extension to JavaScript. We recommend using
1818

1919
JSX produces React "elements". We will explore rendering them to the DOM in the [next section](/docs/rendering-elements.html). Below, you can find the basics of JSX necessary to get you started.
2020

21+
22+
<pre class="hidden"><code class="gatsby-code-klipse-eval-js" data-external-libs="https://cdnjs.cloudflare.com/ajax/libs/react/15.4.1/react-with-addons.js, https://cdnjs.cloudflare.com/ajax/libs/react/15.4.1/react-dom.js">
23+
!!React
24+
</code></pre>
25+
26+
<div>
27+
Hello World
28+
</div>
29+
2130
### Embedding Expressions in JSX
2231

2332
You can embed any [JavaScript expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#Expressions) in JSX by wrapping it in curly braces.
@@ -65,6 +74,29 @@ function getGreeting(user) {
6574
}
6675
```
6776

77+
Hello
78+
~~~klipse-eval-js
79+
2+3
80+
~~~
81+
82+
83+
Simple
84+
85+
~~~klipse-render-jsx
86+
&lt;p&gt;Hello World &lt;/p&gt;
87+
~~~
88+
89+
Again:
90+
91+
~~~klipse-jsx
92+
function getGreeting(user) {
93+
if (user) {
94+
return &lt;h1&gt;Hello, {formatName(user)}!&lt;/h1&gt;;
95+
}
96+
return &lt;h1&gt;Hello, Stranger.&lt;/h1&gt;;
97+
}
98+
~~~
99+
68100
### Specifying Attributes with JSX
69101

70102
You may use quotes to specify string literals as attributes:
@@ -160,3 +192,6 @@ We will explore rendering React elements to the DOM in the next section.
160192
>**Tip:**
161193
>
162194
>We recommend using the ["Babel" language definition](http://babeljs.io/docs/editors) for your editor of choice so that both ES6 and JSX code is properly highlighted. This website uses the [Oceanic Next](https://labs.voronianski.com/oceanic-next-color-scheme/) color scheme which is compatible with it.
195+
196+
197+

content/docs/jsx-in-depth.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,23 @@ React.createElement(
3131
)
3232
```
3333

34+
Here is an interactive version of the jsx snippet:
35+
~~~klipse-transpile-jsx
36+
&lt;MyButton color="blue" shadowSize={2}&gt;
37+
Click Me
38+
&lt;/MyButton&gt;
39+
~~~
40+
41+
Here is an interactive version of the jsx snippet:
42+
<pre>
43+
<code class="gatsby-code-klipse-transpile-jsx">
44+
&lt;MyButton color="blue" shadowSize={2}&gt;
45+
Click Me
46+
&lt;/MyButton&gt;
47+
</code>
48+
</pre>
49+
50+
3451
You can also use the self-closing form of the tag if there are no children. So:
3552

3653
```js

gatsby-config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ module.exports = {
7575
trackingId: 'UA-41298772-1',
7676
},
7777
},
78+
{
79+
resolve: 'gatsby-plugin-klipse',
80+
options: {
81+
classPrefix: 'gatsby-code-',
82+
}
83+
},
7884
{
7985
resolve: 'gatsby-plugin-feed',
8086
options: {

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"gatsby-plugin-feed": "^1.3.9",
3131
"gatsby-plugin-glamor": "^1.6.4",
3232
"gatsby-plugin-google-analytics": "^1.0.4",
33+
"gatsby-plugin-klipse": "^2.0.0",
3334
"gatsby-plugin-manifest": "^1.0.4",
3435
"gatsby-plugin-netlify": "^1.0.4",
3536
"gatsby-plugin-nprogress": "^1.0.7",

yarn.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3866,6 +3866,10 @@ gatsby-plugin-google-analytics@^1.0.4:
38663866
dependencies:
38673867
babel-runtime "^6.26.0"
38683868

3869+
gatsby-plugin-klipse@^2.0.0:
3870+
version "2.0.0"
3871+
resolved "https://registry.yarnpkg.com/gatsby-plugin-klipse/-/gatsby-plugin-klipse-2.0.0.tgz#422e611c24ac758652399838929d4a6102e61a8e"
3872+
38693873
gatsby-plugin-manifest@^1.0.4:
38703874
version "1.0.8"
38713875
resolved "https://registry.yarnpkg.com/gatsby-plugin-manifest/-/gatsby-plugin-manifest-1.0.8.tgz#8c155cd2aed54759554c25bf9efb4a2c48de6429"
@@ -5374,14 +5378,10 @@ [email protected]:
53745378
version "2.1.1"
53755379
resolved "https://registry.yarnpkg.com/items/-/items-2.1.1.tgz#8bd16d9c83b19529de5aea321acaada78364a198"
53765380

5377-
5381+
[email protected], iterall@^1.1.0:
53785382
version "1.1.3"
53795383
resolved "https://registry.yarnpkg.com/iterall/-/iterall-1.1.3.tgz#1cbbff96204056dde6656e2ed2e2226d0e6d72c9"
53805384

5381-
iterall@^1.1.0:
5382-
version "1.1.1"
5383-
resolved "https://registry.yarnpkg.com/iterall/-/iterall-1.1.1.tgz#f7f0af11e9a04ec6426260f5019d9fcca4d50214"
5384-
53855385
jest-docblock@^21.0.0:
53865386
version "21.2.0"
53875387
resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-21.2.0.tgz#51529c3b30d5fd159da60c27ceedc195faf8d414"

0 commit comments

Comments
 (0)