-
Notifications
You must be signed in to change notification settings - Fork 2
/
gatsby2.html
1529 lines (951 loc) · 37.6 KB
/
gatsby2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Stay Static - Build Single-Page Static Websites w/ Gatsby (and GraphQL)</title>
<meta name="generator" content="Slide Show (S9) v4.0.1 on Ruby 2.3.3 (2016-11-21) [i386-mingw32]">
<meta name="author" content="Your Name Here" >
<!-- S6 style sheet links -->
<link rel="stylesheet" href="s62/screen.css">
<link rel="stylesheet" href="gatsby2.css">
</head>
<body>
<article id="presentation">
<section class="slide " id="1">
<!-- _S9SLIDE_ -->
<h1 id="agenda">Agenda</h1>
<ul>
<li>Dynamic Website Generators
<ul>
<li>Why Static? Inside a Dynamic WordPress Page Query</li>
</ul>
</li>
<li>Static Website Generators</li>
<li>Hello, Gatsby!
<ul>
<li>Open Source Heroes - Kyle Mathews</li>
</ul>
</li>
<li>Getting Started w/ Gatsby
<ul>
<li>Gatsby Commands</li>
<li>Gatsby Quick Starter - Ready-to-Use/Fork Themes</li>
<li>Hello, React World! - The World’s Simplest Gatsby Website</li>
<li>Gatsby In Action - Why Gatsby (v0)? Live Hot Reloading</li>
<li>Gatsby In Action - Why Gatsby (v1)? Continued</li>
</ul>
</li>
<li>Gatsby Stay Static Sample Website
<ul>
<li>Gatsby Stay Static Website - File Structure</li>
<li>Gatsby Stay Static Website - Pages</li>
<li>Gatsby Stay Static Site - Posts with Front Matter
<ul>
<li>Markdown Madness - Markdown Library Options in Gatsby</li>
</ul>
</li>
<li>Gatsby Stay Static Website - Datafiles</li>
<li>Gatsby Stay Static Website - HTML Web Components - Loops</li>
<li>Gatsby Stay Static Website - HTML Web Components - Includes</li>
<li>Gatsby Stay Static Website - Configuration / Settings</li>
<li>Gatsby Stay Static Website Demo</li>
<li>Going Live - Free (Static) Website Hosting Options</li>
</ul>
</li>
<li>What’s GraphQL?
<ul>
<li>Gatsby GraphQL Example - Query Site Metadata</li>
<li>Gatsby GraphQL Example - Query Filesystem</li>
<li>What’s GraphiQL?</li>
<li>Gatsby GraphQL Example - Query Markdown Pages</li>
<li>Gatsby GraphQL Example - WordPress Post Query</li>
<li>How to Use GraphQL and React with Gatsby?</li>
</ul>
</li>
<li>CSS-in-JS - Start using CSS in JavaScript (JS)</li>
<li>Gatsby (Static) Websites in the “Real World”</li>
</ul>
</section>
<section class="slide " id="2">
<!-- _S9SLIDE_ -->
<h1 id="10-years-ago---dynamic-website-generators-in-2007">10 Years Ago - Dynamic Website Generators in 2007</h1>
<p><strong>The Biggies</strong> (PHP Rules!)</p>
<ul>
<li>WordPress</li>
<li>Drupal</li>
<li>Joomla!</li>
</ul>
<p>On your live production site requires</p>
<ul>
<li>database (e.g. mysql)</li>
<li>application server (e.g. mod_php)</li>
<li>web server (e.g. apache)</li>
</ul>
<p>On every request - (re)builds the page on-the-fly
e.g. queries the database, runs scripts,
merges templates, etc.</p>
</section>
<section class="slide " id="3">
<!-- _S9SLIDE_ -->
<h1 id="why-static-inside-a-dynamic-wordpress-page-query">Why Static? Inside a Dynamic WordPress Page Query</h1>
<ol>
<li>When a visitor first clicks on or types a URL for a page that is part of your blog, WordPress starts by running a few core files (wp-config.php, wp-settings.php, etc.) If you are interested in the specifics of the file loading order, start at index.php and follow the chain of files as each PHP file includes/requires additional PHP files (or read this excellent post at humanshell.net)</li>
<li>WordPress loads and initializes any plugins you have activated (calls the plugin init actions).</li>
<li>WordPress loads the “text domain” for internationalization, and the functions.php file from the currently active theme.</li>
<li>WordPress runs the wp() function (in wp-includes/functions.php), which calls $wp->main() ($wp is an object of class WP, which is defined in wp-includes/class-wp.php). This tells WordPress to:
<ol>
<li>Parse the URL into a query specification using WP->parse_request() – more on that below.</li>
<li>Set all the is_ variables that are used by Conditional Tags using $wp_query->parse_query() ($wp_query is an object of class WP_Query, which is defined in wp-includes/query.php). Note that in spite of this function’s name, in this case WP_Query->parse_query doesn’t actually do any parsing for us, since that is done before-hand by WP->parse_request().</li>
<li>Convert the query specification into a MySQL database query, and run the database query to get the list of posts, in function WP_Query->get_posts(). Save the posts in the $wp_query object to be used in the WordPress Loop.</li>
<li>Handle 404 errors.</li>
<li>Send the blog’s HTTP headers.</li>
<li>Set up some variables for the WordPress Loop.</li>
</ol>
</li>
<li>WordPress loads your template, figures out which template file to use according to the Template Hierarchy, and runs that file (basically doing whatever your template file says to do). Or, WordPress could run one of the feed files (such as wp-rss2.php) instead.</li>
<li>Generally, the template or feed file runs the WordPress Loop to print blog posts or a static page.</li>
<li>The template or feed file will also likely print out permalinks to some archives, categories, or posts using built-in WordPress functions.</li>
</ol>
<p>And so and so on and so on and so on.</p>
<p>(Source: <a href="https://codex.wordpress.org/Query_Overview">codex.wordpress.org/Query_Overview</a>)</p>
</section>
<section class="slide " id="4">
<!-- _S9SLIDE_ -->
<h1 id="10-years-later---dynamic-website-generators-today-in-2017">10 Years Later - Dynamic Website Generators Today in 2017?</h1>
<p><strong>The Biggies</strong> (PHP Rules!)</p>
<ul>
<li>WordPress</li>
<li>Drupal</li>
<li>Joomla!</li>
</ul>
<p>See the difference ;-) JavaScript Fatigue - Anyone?
Use WordPress (PHP) ;-)
28.8% of the Internet and counting.</p>
</section>
<section class="slide " id="5">
<!-- _S9SLIDE_ -->
<h1 id="static-website-generators--builders-in-1999">Static Website Generators / Builders in 1999</h1>
<p><strong>The Biggies</strong> in 1999</p>
<ol>
<li>Macromedia Dreamweaver</li>
<li>Microsoft FrontPage</li>
<li>Netscape Composer</li>
</ol>
<p>And today?</p>
</section>
<section class="slide " id="6">
<!-- _S9SLIDE_ -->
<h1 id="hello-gatsby">Hello, Gatsby!</h1>
<p>by Kyle Mathews et al (★12 869) -
github: <a href="https://github.com/gatsbyjs/gatsby"><code>gatsbyjs/gatsby</code></a></p>
<p><img src="i/gatsbyjsorg-website.png" alt="" /></p>
<p>(Source: <a href="https://gatsbyjs.org">gatsbyjs.org</a>)</p>
</section>
<section class="slide " id="7">
<!-- _S9SLIDE_ -->
<h1 id="getting-started-w-gatsby">Getting Started w/ Gatsby</h1>
<p>Gatsby is a JavaScript package using Webpack, React, React Router,
React Helmet, GraphQL, Markdown
and more to let you build static websites.
Use npm to install e.g.:</p>
<pre><code>$ npm install -g gatsby-cli
</code></pre>
</section>
<section class="slide " id="8">
<!-- _S9SLIDE_ -->
<h1 id="gatsby-commands">Gatsby Commands</h1>
<p>Try:</p>
<pre><code>$ gatsby -h
</code></pre>
<p>prints</p>
<pre><code>Usage:
gatsby [command] [options]
Available Commands:
new [rootPath] [starter] Create new Gatsby project.
develop [options] Start development server. Watches files and rebuilds and hot reloads
if something changes
build [options] Build a Gatsby project.
serve [options] Serve built site.
Options:
-h, --help output usage information
-V, --version output the version number
</code></pre>
<p>See the <a href="https://github.com/statictimes/quickrefs/blob/master/GATSBY.md">Gatsby Quick Reference (Cheat Sheet)</a></p>
</section>
<section class="slide " id="9">
<!-- _S9SLIDE_ -->
<h1 id="gatsby-quick-starter---ready-to-usefork-themes">Gatsby Quick Starter - Ready-to-Use/Fork Themes</h1>
<ul>
<li>Hello, React World!</li>
<li>Simple website (default)</li>
<li>Simple blog</li>
<li>Simple documentation website</li>
<li>Kitchen sink demo site</li>
</ul>
<p>To get started use:</p>
<pre><code>$ gatsby new hello https://github.com/gatsbyjs/gatsby-starter-hello-world
</code></pre>
<p>Basically the same as:</p>
<pre><code>$ git clone https://github.com/gatsbyjs/gatsby-starter-hello-world
$ cd gatsby-starter-hello-world
$ npm install
</code></pre>
<p>To test drive use:</p>
<pre><code>$ gatsby develop
</code></pre>
<p>And open the browser. Voila.</p>
</section>
<section class="slide " id="10">
<!-- _S9SLIDE_ -->
<h1 id="hello-react-world---the-worlds-simplest-gatsby-website">Hello, React World! - The World’s Simplest Gatsby Website</h1>
<p>Web Page - <code>src/pages/index.js</code>:</p>
<pre><code>import React from "react"
export default () => <div>Hello, React World!</div>
</code></pre>
<p>That’s it! Add <code>package.json</code>:</p>
<pre><code>{
"name": "gatsby-starter-hello-react-world",
"scripts": {
"develop": "gatsby develop",
"build": "gatsby build",
"serve": "gatsby serve"
},
"dependencies": {
"gatsby": "^1.8.11",
"gatsby-link": "^1.4.1"
}
}
</code></pre>
<p>And install / run / build etc.:</p>
<pre><code>$ npm install
$ npm run build
</code></pre>
</section>
<section class="slide " id="11">
<!-- _S9SLIDE_ -->
<h1 id="open-source-heroes---kyle-mathews">Open Source Heroes - Kyle Mathews</h1>
<p>Kyle Mathews working on Gatsby.js full-time since August 2016.
Looking for sponsorship/consulting.</p>
<p>Trivia Quiz - Q: How many open source JavaScript (node module) packages
on npm?</p>
<p>A:</p>
<ul>
<li>[ A ] 100+</li>
<li>[ B ] 200+</li>
<li>[ C ] 500+</li>
<li>[ D ] 1000+</li>
</ul>
<p>Comparison: The Vienna React “Mafia”:</p>
<ul>
<li>49 packages by <a href="https://www.npmjs.com/~nikgraf">Nik Graf (<code>~nikgraf</code>)</a></li>
<li>35 packages by <a href="https://www.npmjs.com/~mxstbr">Max Stoiber (<code>~mxstbr</code>)</a></li>
<li>17 packages by <a href="https://www.npmjs.com/~okonet">Andrey Okonetchnikov (<code>~okonet</code>)</a></li>
<li>7 packages by <a href="https://www.npmjs.com/~ryyppy">Patrick Stapfer (<code>~ryyppy</code>)</a></li>
</ul>
<p><a href="https://www.npmjs.com/~kylemathews">Click for answer</a> ;-).</p>
</section>
<section class="slide " id="12">
<!-- _S9SLIDE_ -->
<h1 id="gatsby-stay-static-sample-website">Gatsby Stay Static Sample Website</h1>
<p>Shows how-to-use:</p>
<ul>
<li>Posts (e.g. Blog News ‘n’ Updates Posts Sorted by Date)</li>
<li>Pages (e.g. About Page)</li>
<li>Datafiles (e.g. Links ‘n’ Bookmarks)</li>
</ul>
<p><img src="i/staystatic-samplesite.png" alt="" /></p>
</section>
<section class="slide " id="13">
<!-- _S9SLIDE_ -->
<h1 id="gatsby-in-action---why-gatsby-v0-live-hot-reloading">Gatsby In Action - Why Gatsby (v0)? Live Hot Reloading</h1>
<p>No. 1 Selling Point (Gatsby v0) - Hot (!) Reloading - Thanks to Webpack</p>
<p>Works for:</p>
<ul>
<li>React Web Components (Templates)</li>
<li>Your Writing (in Markdown) e.g. Posts / Pages</li>
<li>Styles</li>
<li>Configuration in gatsby-config.js e.g. Site Title, Author Name, etc.</li>
</ul>
<p>New! (in Gatsby v1) Works for:</p>
<ul>
<li>Adding New Files too!</li>
</ul>
</section>
<section class="slide " id="14">
<!-- _S9SLIDE_ -->
<h1 id="gatsby-in-action---why-gatsby-v1-continued">Gatsby In Action - Why Gatsby (v1)? Continued</h1>
<p>New Selling Points from (new) Gatsby.js Website:</p>
<ul>
<li>Modern web tech without the headache => e.g. React, Webpack, etc. out-of-the-box all setup ready-to-use</li>
<li>Bring your own data => e.g. pull data from any sources w/ GraphQL</li>
<li>Static Progressive Web Apps (PWA) => e.g. code and data splitting out-of-the-box all setup ready-to-use</li>
<li>Speed past the competition => e.g. build the fastest possible website;
pre-build pages, etc.</li>
<li>And some more.</li>
</ul>
<p>(Source: <a href="https://gatsbyjs.org">GatsbyJS.org</a>)</p>
</section>
<section class="slide " id="15">
<!-- _S9SLIDE_ -->
<h1 id="gatsby-stay-static-website---file-structure">Gatsby Stay Static Website - File Structure</h1>
<pre><code>│ gatsby-config.js
│ gatsby-node.js
│ package.json
└───src/
├───components/
│ Footer.js
│ Header.js
│ LinkList.js
│ PostList.js
├───css/
│ style.css
├───data/
│ links.js
├───layouts/
│ index.js
├───pages/
│ │ about.js
│ │ index.js
│ └───posts/
│ new-build-system.md
│ new-repo-maps.md
│ new-season.md
└───templates/
post.js
</code></pre>
<p>(Source: <a href="https://github.com/staystatic/staystatic/tree/master/gatsby"><code>staystatic/gatsby</code></a>)</p>
</section>
<section class="slide " id="16">
<!-- _S9SLIDE_ -->
<h1 id="gatsby-stay-static-website---pages">Gatsby Stay Static Website - Pages</h1>
<pre><code>import React from "react"
export default () =>
<div>
<h1>About</h1>
<p>
Gatsby Static Site Sample. Shows how to use:
</p>
<ol>
<li>Pages (see <code>src/pages/about.html</code>)</li>
<li>Posts (see <code>src/pages/posts/*.md</code>)</li>
<li>Custom Content Types (see <code>src/data/links.js</code>)</li>
</ol>
</div>
</code></pre>
<p>(Source: <a href="https://github.com/staystatic/staystatic/blob/master/gatsby/src/pages/about.js"><code>staystatic/gatsby/src/pages/about.js</code></a>)</p>
</section>
<section class="slide " id="17">
<!-- _S9SLIDE_ -->
<h1 id="gatsby-stay-static-site---posts-with-front-matter">Gatsby Stay Static Site - Posts with Front Matter</h1>
<p>YAML + Markdown</p>
<pre><code>---
title: "beer.db - New Repo /maps - Free 'Full-Screen' Interactive Beer Maps w/ Brewery Listings"
date: "2015-08-25"
---
The beer.db project - offering free public domain beer, brewery
and brewpubs data - added a new repo, that is, `/maps`
for hosting 'full-screen' interactive beer maps with brewery listings.
See an example [beer map for Austria](http://openbeer.github.io/maps/at)
(~200 breweries n brewpubs) live or
[check the source](https://github.com/openbeer/maps) using the mapbox.js mapping library.
...
</code></pre>
<p>(Source: <a href="https://github.com/staystatic/staystatic/blob/master/gatsby/src/pages/posts/new-repo-maps.md"><code>staystatic/gatsby/pages/posts/new-repo-maps.md</code></a>)</p>
</section>
<section class="slide " id="18">
<!-- _S9SLIDE_ -->
<h1 id="markdown-madness---markdown-library-options-in-gatsby">Markdown Madness - Markdown Library Options in Gatsby</h1>
<p><strong>remark</strong> ★1 064 by Titus et al (github: <a href="https://github.com/wooorm/remark">wooorm/remark</a>)</p>
<p>Markdown processor powered by plugins.</p>
<p>Gatsby remark plugins / goodies include:</p>
<ul>
<li>Rendering math equations with KaTeX</li>
<li>Code and syntax highlighting with Prism.js</li>
<li>Copying linked files and intercepting local links</li>
<li>Responsive images and iframes</li>
<li>And much more</li>
</ul>
</section>
<section class="slide " id="19">
<!-- _S9SLIDE_ -->
<h1 id="gatsby-stay-static-website---datafiles">Gatsby Stay Static Website - Datafiles</h1>
<p><strong>Datafile</strong> - JavaScript</p>
<pre><code>//////////////////////////
// Links 'n' Bookmarks
export default [
{ title: "football.db - Open Football Data",
url: "https://github.com/openfootball" },
{ title: "beer.db - Open Beer, Brewery 'n' Brewpub Data",
url: "https://github.com/openbeer" },
{ title: "world.db - Open World Data",
url: "https://github.com/openmundi" }
]
</code></pre>
<p>(Source: <a href="https://github.com/staystatic/staystatic/blob/master/gatsby/src/data/links.js"><code>staystatic/gatsby/src/data/links.js</code></a>)</p>
</section>
<section class="slide " id="20">
<!-- _S9SLIDE_ -->
<h1 id="gatsby-stay-static-website----html-web-components---loops">Gatsby Stay Static Website - HTML Web Components - Loops</h1>
<p><strong>Templates</strong> - React HTML Web Components</p>
<pre><code>import React from "react"
export default ({links}) =>
<ul>
{ links.map( link => <li><a href={link.url}>{link.title}</a></li> )}
</ul>
// Use like:
// <LinkList links={links}/>
</code></pre>
<p>(Source: <a href="https://github.com/staystatic/staystatic/blob/master/gatsby/src/components/LinkList.js"><code>staystatic/gatsby/src/components/LinkList.js</code></a>)</p>
</section>
<section class="slide " id="21">
<!-- _S9SLIDE_ -->
<h1 id="gatsby-stay-static-website----html-web-components---loops-cont">Gatsby Stay Static Website - HTML Web Components - Loops (Cont.)</h1>
<pre><code>import React from "react"
import Link from "gatsby-link"
export default ({posts}) =>
<ul>
{posts.map( ({node : post}) =>
<li><Link to={post.fields.slug}>{post.frontmatter.title}</Link></li> )}
</ul>
// Use like:
// <PostList posts={posts}/>
</code></pre>
<p>(Source: <a href="https://github.com/staystatic/staystatic/blob/master/gatsby/src/components/PostList.js"><code>staystatic/gatsby/src/components/PostList.html</code></a>)</p>
</section>
<section class="slide " id="22">
<!-- _S9SLIDE_ -->
<h1 id="gatsby-stay-static-website---html-web-components---includes">Gatsby Stay Static Website - HTML Web Components - Includes</h1>
<p><strong>Templates</strong> - React HTML Web Components</p>
<pre><code>import Header from "../components/Header"
import Footer from "../components/Footer"
export default ({ children }) =>
<div>
<Header/>
<div>
{children()}
</div>
<Footer/>
</div>
</code></pre>
<p>(Source: <a href="https://github.com/staystatic/staystatic/blob/master/gatsby/src/layouts/index.js"><code>staystatic/gatsby/src/layouts/index.js</code></a>)</p>
</section>
<section class="slide " id="23">
<!-- _S9SLIDE_ -->
<h1 id="gatsby-stay-static-website---html-web-components---includes-cont">Gatsby Stay Static Website - HTML Web Components - Includes (Cont.)</h1>
<pre><code>import React from "react"
export default () =>
<div id="footer">
A <a href="http://staystatic.github.io">Stay Static</a> Sample Site
</div>
</code></pre>
<p>(Source: <a href="https://github.com/staystatic/staystatic/blob/master/gatsby/src/components/Footer.js"><code>staystatic/gatsby/src/components/Footer.js</code></a>)</p>
<pre><code>import React from 'react'
import Link from 'gatsby-link'
export default ({data}) =>
<div id="header">
<table style={{width: "100%"}}>
<tbody>
<tr>
<td>
<Link to={"/"}>{ data.site.siteMetadata.title }</Link>
</td>
<td style={{textAlign: "right"}}>
<Link to={"/about/"}>About</Link>
</td>
</tr>
</tbody>
</table>
</div>
</code></pre>
<p>(Source: <a href="https://github.com/staystatic/staystatic/blob/master/gatsby/src/components/Header.js"><code>staystatic/gatsby/src/components/Header.js</code></a>)</p>
</section>
<section class="slide " id="24">
<!-- _S9SLIDE_ -->
<h1 id="gatsby-stay-static-website---configuration--settings">Gatsby Stay Static Website - Configuration / Settings</h1>
<p>JavaScript</p>
<pre><code>module.exports = {
siteMetadata: {
title: "Gatsby (+GraphQL) Stay Static Site Sample",
},
pathPrefix: "/sites/gatsby-graphql"
}
</code></pre>
<p>(Source: <a href="https://github.com/staystatic/staystatic/blob/master/gatsby/gatsby-config.js"><code>staystatic/gatsby/gatsby-config.js</code></a>)</p>
</section>
<section class="slide " id="25">
<!-- _S9SLIDE_ -->
<h1 id="gatsby---summary">Gatsby - Summary</h1>
<table>
<thead>
<tr>
<th>-</th>
<th>Gatsby</th>
</tr>
</thead>
<tbody>
<tr>
<td>GitHub Stars (+1s)</td>
<td>★12 870</td>
</tr>
</tbody>
<tbody>
<tr>
<td>Settings / Configuration</td>
<td>JavaScript</td>
</tr>
<tr>
<td>HTML Templates</td>
<td>React</td>
</tr>
<tr>
<td>. Layouts</td>
<td>React</td>
</tr>
<tr>
<td>. Includes</td>
<td>React</td>
</tr>
<tr>
<td>Front Matter / Meta Data</td>
<td>YAML</td>
</tr>
<tr>
<td>Datafiles</td>
<td>JavaScript</td>
</tr>
<tr>
<td>CSS Preprocessing</td>
<td>CSS-in-JS, Sass, PostCSS etc.</td>
</tr>
<tr>
<td>HTML “Shortcodes”</td>
<td>Markdown</td>
</tr>
</tbody>
</table>
</section>
<section class="slide " id="26">
<!-- _S9SLIDE_ -->
<h1 id="gatsby-stay-static-website-demo">Gatsby Stay Static Website Demo</h1>
<pre><code>$ gatsby build
</code></pre>
<p>results in</p>
<pre><code>success delete html files from previous builds - 0.016 s
success open and validate gatsby-config.js - 0.006 s
success copy gatsby files - 0.052 s
success source and transform nodes - 0.106 s
success building schema - 0.148 s
success createLayouts - 0.011 s
success createPages - 0.034 s
success createPagesStatefully - 0.014 s
success extract queries from components - 0.105 s
success run graphql queries - 0.007 s
success write out page data - 0.006 s
success update schema - 0.082 s
info bootstrap finished - 3.354 s
success Building CSS - 5.017 s
success Building production JavaScript bundles - 9.895 s
success Building static HTML for pages - 2.197 s
Done building in 20.475 seconds
</code></pre>
</section>
<section class="slide " id="27">
<!-- _S9SLIDE_ -->
<h1 id="gatsby-stay-static-website-demo-cont">Gatsby Stay Static Website Demo (Cont.)</h1>
<p>File Structure in <code>/public</code>:</p>
<pre><code>│ app-2acd99fcfc70c7ec8a0a.js
│ app-2acd99fcfc70c7ec8a0a.js.map
│ build-js-styles.css
│ build-js-styles.css.map
│ chunk-manifest.json
│ commons-a706efda9882e3aecc8c.js
│ commons-a706efda9882e3aecc8c.js.map
│ component---src-layouts-index-js-c7801619b3d290cd7234.js
│ component---src-layouts-index-js-c7801619b3d290cd7234.js.map
│ component---src-pages-about-js-ec83f8cb31d5d651db6a.js
│ component---src-pages-about-js-ec83f8cb31d5d651db6a.js.map
│ component---src-pages-index-js-7a4ee00b60c522c51efc.js
│ component---src-pages-index-js-7a4ee00b60c522c51efc.js.map
│ component---src-templates-post-js-2c2b6669e1eef7a2bf41.js
│ component---src-templates-post-js-2c2b6669e1eef7a2bf41.js.map
│ index.html
│ path----c622219dd6f45a37b480.js
│ path----c622219dd6f45a37b480.js.map
│ path---about-a0e39f21c11f6a62c5ab.js
│ path---about-a0e39f21c11f6a62c5ab.js.map
│ path---index-a1a20f675945a44dff76.js
│ path---index-a1a20f675945a44dff76.js.map
│ path---posts-new-build-system-28812c3926bd90e09ffd.js
│ path---posts-new-build-system-28812c3926bd90e09ffd.js.map
│ path---posts-new-repo-maps-b4a76498aa30a97236aa.js
│ path---posts-new-repo-maps-b4a76498aa30a97236aa.js.map
│ path---posts-new-season-3ff4114e155504f291d4.js
│ path---posts-new-season-3ff4114e155504f291d4.js.map
│ render-page.js.map
│ stats.json
│ styles.css
│
├───about/
│ index.html
│
└───posts/
├───new-build-system/
│ index.html
│
├───new-repo-maps/
│ index.html
│
└───new-season/
index.html
</code></pre>
</section>
<section class="slide " id="28">
<!-- _S9SLIDE_ -->
<h1 id="going-live---free-static-website-hosting-options">Going Live - Free (Static) Website Hosting Options</h1>
<ul>
<li>GitHub Pages – use git push</li>
<li>GitLab Pages – use git push</li>
<li>Surge.sh – go live with six keystrokes - s u r g e [ENTER]</li>
<li>Google Firebase (Free Tier)</li>
<li>Netlify (Free OpenSource Tier)</li>
<li>And Many More</li>
</ul>
</section>
<section class="slide " id="29">
<!-- _S9SLIDE_ -->
<h1 id="gatsby-goodies---whats-missing">Gatsby Goodies - What’s Missing?</h1>
<p>GraphQL - Query any Data Source (at Build-Time)</p>
<p>And much much more.</p>
</section>
<section class="slide " id="30">
<!-- _S9SLIDE_ -->
<h1 id="whats-graphql">What’s GraphQL?</h1>
<p>A data query language (by example).</p>
<p>QL => Query Language</p>
<p><img src="i/graphqlorg-website.png" alt="" /></p>
<p>(Source: <a href="http://graphql.org">graphql.org</a>)</p>
</section>
<section class="slide " id="31">
<!-- _S9SLIDE_ -->
<h1 id="gatsby-graphql-example---query-site-metadata">Gatsby GraphQL Example - Query Site Metadata</h1>
<pre><code>{
site {
siteMetadata {
title
}
}
}
</code></pre>
<p>resulting in:</p>
<pre><code>{
"site": {
"siteMetadata": {
"title": "Gatsby (+GraphQL) Stay Static Site Sample"
}
}
}
</code></pre>
</section>
<section class="slide " id="32">
<!-- _S9SLIDE_ -->
<h1 id="gatsby-graphql-example---query-filesystem">Gatsby GraphQL Example - Query Filesystem</h1>
<pre><code>{
allFile
{ edges
{ node {
relativePath
prettySize
birthTime
}}}
}
</code></pre>
<p>resulting in:</p>
<pre><code>{
"allFile": {
"edges": [
{
"node": {
"relativePath": "pages/about.js",
"prettySize": "343 B",
"birthTime": "2017-09-02T16:21:53.799Z"
}
},
{
"node": {
"relativePath": "pages/index.js",
"prettySize": "863 B",
"birthTime": "2017-09-02T16:53:52.821Z"
}
},
{
"node": {
"relativePath": "pages/posts/new-repo-maps.md",
"prettySize": "516 B",
"birthTime": "2017-09-02T16:21:53.799Z"
}
},
{
"node": {
"relativePath": "pages/posts/new-build-system.md",
"prettySize": "892 B",
"birthTime": "2017-09-02T16:21:53.799Z"
}
},
{
"node": {
"relativePath": "pages/posts/new-season.md",
"prettySize": "1.03 kB",
"birthTime": "2017-09-02T16:21:53.799Z"
}
}
]
}
}
</code></pre>
</section>
<section class="slide " id="33">
<!-- _S9SLIDE_ -->
<h1 id="whats-graphiql">What’s GraphiQL?</h1>
<p>An in-browser IDE for exploring GraphQL.
Built into Gatsby! (only during development).</p>
<pre><code>$ gatsby develop
Your site is running at http://localhost:8000
Your graphql debugger is running at http://localhost:8000/___graphql
</code></pre>
<p><img src="i/graphiql.png" alt="" /></p>
</section>
<section class="slide " id="34">
<!-- _S9SLIDE_ -->
<h1 id="gatsby-graphql-example---query-markdown-pages">Gatsby GraphQL Example - Query Markdown Pages</h1>
<pre><code>{ allMarkdownRemark {
totalCount
edges {
node {
frontmatter {
title