Removed grunt task for building live edits and removed js link conditional at bottom of layout since we're no longer conditionally loading live edit js for cookbook pages
Connor McSheffrey committed
Oct 29, 2013 at 18:04 UTC
5847536c9ddac2891db49b25f071070d9f757c02
2 files changed
+1
-86
docs/Gruntfile.js
deleted
-83
@@ -1,83 +0,0 @@
1
-module.exports = function(grunt) {
2
-
3
- // Project configuration.
4
- grunt.initConfig({
5
- pkg: grunt.file.readJSON('../package.json')
6
- });
7
-
8
- /**
9
- * Write React component to js file
10
- * @param {String} liveEditJS
11
- * @param {String} componentName
12
- */
13
- function writeToLiveSampleJS(liveEditJS, componentName) {
14
-
15
- grunt.file.write('js/cookbook/' + componentName + '.js', liveEditJS);
16
- }
17
-
18
- /**
19
- * Update HTML file to include an ID and script src link
20
- */
21
- function writeToHTML(markdown, componentName) {
22
- grunt.file.write('_site/cookbook' + componentName + '.html', markdown);
23
- }
24
-
25
- function readFromCookbookEntry(abspath, rootdir, subdir, filename) {
26
-
27
- var markdown = grunt.file.read(abspath),
28
- codeSample = /```[\S]+\s*[\s\S]*?```/g,
29
-
30
- // read markdown file for code sample
31
- matchedJS = markdown.match(codeSample),
32
- trimmedJS,
33
- componentName,
34
- componentNameCamelCase,
35
- componentNameUpperCase,
36
- liveEditJS = '';
37
-
38
- // File has no code sample
39
- if (matchedJS === null) {
40
- return;
41
- };
42
-
43
- // Here we should iterate over matched code samples
44
-
45
- for( var i = 0; i < matchedJS.length; i++) {
46
-
47
-
48
- // Remove markdown syntax
49
- matchedJS = matchedJS[i].slice(5, -3);
50
-
51
- // remove file extension
52
- componentName = filename.slice(0, -3) + i;
53
-
54
- // Uppercase with underscores (FOO_COMPONENT)
55
- componentNameUpperCase = componentName.toUpperCase().replace(/[\. ,:-]+/g, "_").slice(6);
56
-
57
- // Camelcase (fooExample)
58
- componentNameCamelCase = componentName.replace(/-([a-z])/g, function (g) { return g[1].toUpperCase() }).slice(5);
59
-
60
- // Add code sample to live edit
61
- liveEditJS += '/**\n * @jsx React.DOM\n */\n\n var ' + componentNameUpperCase + '_COMPONENT = "' + matchedJS + '";\n React.renderComponent(\n ReactPlayground( {codeText:' + componentNameUpperCase + '_COMPONENT} ),\n document.getElementById("' + componentNameCamelCase + '")\n );'
62
-
63
- writeToLiveSampleJS(liveEditJS, componentName);
64
-
65
- }
66
-
67
-
68
-
69
- // writeToHTML(markdown, componentName);
70
- }
71
-
72
- grunt.registerTask('makeLiveSamples', 'Create live edit JS file for code samples in React Cookbook entries', function() {
73
- var rootdir = 'cookbook/';
74
-
75
- // Recurse through cookbook directory
76
- grunt.file.recurse(rootdir, readFromCookbookEntry);
77
-
78
- });
79
-
80
- // Default task(s).
81
- grunt.registerTask('default', ['makeLiveSamples']);
82
-
83
-};
\ No newline at end of file
docs/_layouts/default.html
+1
-3
@@ -74,9 +74,7 @@
74
</footer>
75
</div>
76
<div id="fb-root"></div>
77
- {% if page.script %}
78
- <script type="text/javascript" src="/react/js/{{page.script}}"></script>
79
- {% endif %}
77
+
78
<script>
79
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
80
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),