Browse Source

Update Stasis version and add GraphQL example

master
Jonas Duri 8 months ago
parent
commit
73078fb17a

+ 29
- 9
package-lock.json View File

@@ -879,6 +879,11 @@
879 879
         "@types/node": "*"
880 880
       }
881 881
     },
882
+    "@types/graphql": {
883
+      "version": "14.0.7",
884
+      "resolved": "https://registry.npmjs.org/@types/graphql/-/graphql-14.0.7.tgz",
885
+      "integrity": "sha512-BoLDjdvLQsXPZLJux3lEZANwGr3Xag56Ngy0U3y8uoRSDdeLcn43H3oBcgZlnd++iOQElBpaRVDHPzEDekyvXQ=="
886
+    },
882 887
     "@types/lodash": {
883 888
       "version": "4.14.121",
884 889
       "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.121.tgz",
@@ -3535,9 +3540,9 @@
3535 3540
       "integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w=="
3536 3541
     },
3537 3542
     "get-port": {
3538
-      "version": "4.1.0",
3539
-      "resolved": "https://registry.npmjs.org/get-port/-/get-port-4.1.0.tgz",
3540
-      "integrity": "sha512-4/fqAYrzrzOiqDrdeZRKXGdTGgbkfTEumGlNQPeP6Jy8w0PzN9mzeNQ3XgHaTNie8pQ3hOUkrwlZt2Fzk5H9mA=="
3543
+      "version": "4.2.0",
3544
+      "resolved": "https://registry.npmjs.org/get-port/-/get-port-4.2.0.tgz",
3545
+      "integrity": "sha512-/b3jarXkH8KJoOMQc3uVGHASwGLPq3gSFJ7tgJm2diza+bydJPTGOibin2steecKeOylE8oY2JERlVWkAJO6yw=="
3541 3546
     },
3542 3547
     "get-stdin": {
3543 3548
       "version": "4.0.1",
@@ -3610,6 +3615,14 @@
3610 3615
         "unicode-trie": "^0.3.1"
3611 3616
       }
3612 3617
     },
3618
+    "graphql": {
3619
+      "version": "14.1.1",
3620
+      "resolved": "https://registry.npmjs.org/graphql/-/graphql-14.1.1.tgz",
3621
+      "integrity": "sha512-C5zDzLqvfPAgTtP8AUPIt9keDabrdRAqSWjj2OPRKrKxI9Fb65I36s1uCs1UUBFnSWTdO7hyHi7z1ZbwKMKF6Q==",
3622
+      "requires": {
3623
+        "iterall": "^1.2.2"
3624
+      }
3625
+    },
3613 3626
     "gray-matter": {
3614 3627
       "version": "4.0.2",
3615 3628
       "resolved": "https://registry.npmjs.org/gray-matter/-/gray-matter-4.0.2.tgz",
@@ -4691,6 +4704,11 @@
4691 4704
       "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz",
4692 4705
       "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8="
4693 4706
     },
4707
+    "iterall": {
4708
+      "version": "1.2.2",
4709
+      "resolved": "https://registry.npmjs.org/iterall/-/iterall-1.2.2.tgz",
4710
+      "integrity": "sha512-yynBb1g+RFUPY64fTrFv7nsjRrENBQJaX2UL+2Szc9REFrSNm1rpSXHGzhmAy7a9uv3vlvgBlXnf9RqmPH1/DA=="
4711
+    },
4694 4712
     "js-base64": {
4695 4713
       "version": "2.5.1",
4696 4714
       "resolved": "https://registry.npmjs.org/js-base64/-/js-base64-2.5.1.tgz",
@@ -5447,9 +5465,9 @@
5447 5465
       }
5448 5466
     },
5449 5467
     "node-releases": {
5450
-      "version": "1.1.8",
5451
-      "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.8.tgz",
5452
-      "integrity": "sha512-gQm+K9mGCiT/NXHy+V/ZZS1N/LOaGGqRAAJJs3X9Ah1g+CIbRcBgNyoNYQ+SEtcyAtB9KqDruu+fF7nWjsqRaA==",
5468
+      "version": "1.1.9",
5469
+      "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.9.tgz",
5470
+      "integrity": "sha512-oic3GT4OtbWWKfRolz5Syw0Xus0KRFxeorLNj0s93ofX6PWyuzKjsiGxsCtWktBwwmTF6DdRRf2KreGqeOk5KA==",
5453 5471
       "requires": {
5454 5472
         "semver": "^5.3.0"
5455 5473
       }
@@ -7713,15 +7731,16 @@
7713 7731
       "integrity": "sha512-ji9qxRnOVfcuLDySj9qzhGSEFVobyt1kIOSkj1qZzYLzq7Tos/oUUWvotUPQLlrsidqsK6tBH89Bc9kL5zHA6w=="
7714 7732
     },
7715 7733
     "stasis-generator": {
7716
-      "version": "0.0.5",
7717
-      "resolved": "https://registry.npmjs.org/stasis-generator/-/stasis-generator-0.0.5.tgz",
7718
-      "integrity": "sha512-4O0PahkCdRU7AAyvlDdQNmwx3nlhrAf6osIoIRDoqpyXlYdCeHIVHnYPthCHqMviQXRLMWoWDjzapXgLoHsdmA==",
7734
+      "version": "0.1.0",
7735
+      "resolved": "https://registry.npmjs.org/stasis-generator/-/stasis-generator-0.1.0.tgz",
7736
+      "integrity": "sha512-4dfUNWEyy5DrO5/RTYPBsyyxetw0IpfSym3szHlAtat9dbCEZbpSLAqLpP3NGF/uUFJKIWVh4QZui3ZF81/6zQ==",
7719 7737
       "requires": {
7720 7738
         "@types/chokidar": "^1.7.5",
7721 7739
         "@types/fs-extra": "^5.0.4",
7722 7740
         "@types/fs-extra-promise": "^1.0.7",
7723 7741
         "@types/get-port": "^4.0.1",
7724 7742
         "@types/glob": "^7.1.1",
7743
+        "@types/graphql": "^14.0.7",
7725 7744
         "@types/lodash": "^4.14.121",
7726 7745
         "@types/node": "^11.9.0",
7727 7746
         "@types/opn": "^5.1.0",
@@ -7733,6 +7752,7 @@
7733 7752
         "fs-extra-promise": "^1.0.1",
7734 7753
         "get-port": "^4.1.0",
7735 7754
         "glob": "^7.1.3",
7755
+        "graphql": "^14.1.1",
7736 7756
         "gray-matter": "^4.0.2",
7737 7757
         "handlebars": "^4.1.0",
7738 7758
         "lodash": "^4.17.11",

+ 1
- 1
package.json View File

@@ -29,6 +29,6 @@
29 29
     "sass": "^1.17.2"
30 30
   },
31 31
   "dependencies": {
32
-    "stasis-generator": "0.0.5"
32
+    "stasis-generator": "^0.1.0"
33 33
   }
34 34
 }

+ 32
- 0
src/graphql/index.js View File

@@ -0,0 +1,32 @@
1
+module.exports = {
2
+  createSchema: (pages, config) => {
3
+    return `
4
+	type Query {
5
+        pageByIndex(index: Int!): Page
6
+		    pageByTitle(title: String!): Page
7
+        pages: [Page]
8
+        posts: [Page]
9
+    }
10
+    type Page {
11
+        html: String
12
+		frontmatter: Frontmatter
13
+        excerpt: String
14
+        relativePath: String
15
+        active: Boolean
16
+    }
17
+	type Frontmatter {
18
+		title: String
19
+		date: String
20
+		layout: String
21
+	}
22
+	`
23
+  } ,
24
+  createRoot: (pages, config) => {
25
+    return {
26
+      pages: () => pages,
27
+      pageByIndex: args => pages[args.index],
28
+      pageByTitle: args => pages.filter(p => p.frontmatter.tile === args.title),
29
+      posts: args => pages.filter(p => p.frontmatter.type === 'blog')
30
+    }
31
+  }
32
+}

+ 6
- 4
src/layouts/base.hbs View File

@@ -20,10 +20,12 @@
20 20
 			</nav>
21 21
 		</div>
22 22
 		<main>
23
-			<p>Loop over all your pages using the `pages` variable inside your templates</p>
24
-			<pre>
25
-				{{json pages}}
26
-			</pre>
23
+            <h1>Loop over all your pages using GraphQL</h1>
24
+            <ul>
25
+                {{#each this.query.data.pages}}
26
+                    <li><a href="{{this.relativePath}}">{{this.frontmatter.title}}</a></li>
27
+                {{/each}}
28
+            </ul>
27 29
 		</main>
28 30
 	</div>
29 31
 </body>

+ 6
- 3
src/layouts/blog-archive.hbs View File

@@ -21,10 +21,13 @@
21 21
 			</nav>
22 22
 		</div>
23 23
 		<main>
24
+            <div>
25
+                {{{body}}}
26
+            </div>
24 27
 			<ol class="terminal-toc">
25
-			{{#each pages}}
26
-				<li><a href="{{this.relativePath}}">{{this.meta.title}}</a></li>
27
-			{{/each}}
28
+                {{#each this.query.data.posts}}
29
+                    <li><a href="{{this.relativePath}}">{{this.frontmatter.title}}</a></li>
30
+                {{/each}}
28 31
 			</ol>
29 32
 		</main>
30 33
 	</div>

+ 70
- 0
src/pages/blog/hello-universe.md View File

@@ -0,0 +1,70 @@
1
+---
2
+layout: blog
3
+title: Hello Universe
4
+type: blog
5
+---
6
+
7
+## Hello Universe.
8
+
9
+Lorem markdownum Ulixem non animam relicta, mite pectus: **a** quam cupidine
10
+clausa undae, nec quid sonuere sedes. Inhaerebat nudaque flammaque exclamant
11
+nostrum servata optandi caput illo attollens comes sollertia unxit descendat,
12
+Helenamque crebros obruta male. Saeviat et flammis accipe sedibus nervis
13
+spolioque in molem *reparabile sulco* et brevi, et et, pro caedis. Ex te, rerum
14
+ab cecinisse totas timeto reccidat tantumque *quoque dominoque* venti.
15
+
16
+- Quassasque in servat cernitis cernentem extremas
17
+- Fieri laetitiae undis
18
+- Aqua aurea laetis invidiosus inculpata
19
+- Armo traherent Hectore deos rursus
20
+
21
+In in *rogum colebat*, est noxque vetustas pariter reticere, et tempora et
22
+frustra extemplo. Dixere movit meta terrae [sopistis
23
+est](http://mansura-nostraque.net/gurgitefelixque.php); lustrat regni, destituit
24
+lacrimas propiore noctes animus poenas concurrere.
25
+
26
+## Et solebat missa dubitet mea tam
27
+
28
+Indice siccis vestrum dum manifesta arsit stimuletur utinam guttura recentes.
29
+Meum praecingitur nurus?
30
+
31
+Unus flammis pater. Est possit Achille ponitque adspicias temeraria terrent
32
+sororis capiti.
33
+
34
+## Premebat plura nostris nova cum infirmos mihi
35
+
36
+Fuso pubis tollere ripae ponti res protinus, frustra [amat](http://www.una.io/),
37
+potiturque. Metus quam flammas manu Triptolemus ante: mitis casusque sacrilega
38
+deprendit contra stipe; hasta agmen quamquam? Deflent luminibus Numici ab
39
+remissis iacentem sonantia.
40
+
41
+Quae tulit dea, *pecudis nos* medias fastigia, veste. Fecit medio virgam pecoris
42
+tamen: si [nurusque iuvabat](http://gavisus.com/) tu effugit calido Calydonius
43
+Subaris inexpugnabile his.
44
+
45
+    if (zeroDbmsIntellectual == e_netbios) {
46
+        tutorialScareware -= nanometer_processor_finder / yahooHocWpa(
47
+                personal_virus, mirrored);
48
+        default_ide_intranet += lanDaemon + 2;
49
+        big_bar_banner.data_dial(mail(pipeline_domain_smm, 1,
50
+                virus_yottabyte_backup), disk_visual_wep.ruby_parallel(
51
+                lossless_io_internic));
52
+    } else {
53
+        megabyte_storage_matrix.module = nntp - logic_lpi_drive;
54
+        telecommunications.cpm.isp(-3);
55
+    }
56
+    if (bank(bit_code - 5, error_computer_stack)) {
57
+        wordConstant(diskMacStorage(google_aiff_circuit), word.standby(dpi,
58
+                copy_document_definition, 1), e_wireless - bittorrent);
59
+    } else {
60
+        cd(start, -5);
61
+        gps_disk_orientation += spider;
62
+        blob.software += 2;
63
+    }
64
+    var friend = characterScraping + partition_analyst;
65
+
66
+Rettulit repetunt natus. Sic feris me vultus, e veribus ignaro, Hecaten in hanc,
67
+cum cognoscenda. Quotiens sonum, o respicit est Aeneae venerat io solvit vesica.
68
+Premunt respice violenta *animoque locum* inguinibus habebat summa suos aurum
69
+opacas dives pharetratae Ixione essent. *Non nostri damnans* pondus cum possent
70
+est.

+ 62
- 1
src/pages/blog/hello-world.md View File

@@ -1,7 +1,68 @@
1 1
 ---
2 2
 layout: blog
3 3
 title: Hello World
4
+type: blog
4 5
 ---
5 6
 
6 7
 ## Hello world.
7
-This is an example blog post.
8
+
9
+Lorem markdownum spumisque sponte Aurora, si luminis dilexit sub pello harena,
10
+nec, colebatur hausi obvertere illa. Dum Pelion, ictu impetus, fores coniunctior
11
+rogat, laude. Leto fortuna, si lactentem illa natura tam; adhuc *villo
12
+cruentior* eratis. Gradive iuvenum. Huc exaudi testis vindexque mundum.
13
+
14
+    var fat = mashup_lpi_boot(io, rippingGpuAddress);
15
+    resources.troubleshooting(page_publishing_motherboard.data(soundFile, plugXp
16
+            - idePhpInterface, internic));
17
+    if (multicasting) {
18
+        p_system(gigo + textCybersquatterDeprecated, cable.compiler(tween_dbms,
19
+                bar_system_capacity));
20
+    } else {
21
+        servletFile = 2;
22
+    }
23
+    var key = vle_halftone_android;
24
+    if (rdf_pharming(ip_pci_card, compression + avatarJfs, remote_biometrics)) {
25
+        formatUpload += cd_wysiwyg_module;
26
+        samba_unit_smartphone = native;
27
+        hashtag_ipx.newbie_printer_spider(post_view(memory_repeater));
28
+    } else {
29
+        desktop += -4;
30
+        barAd += 4 - banner + rjNetiquetteHard.android(nasRom, irq);
31
+        number_art_pseudocode(aiff_web, tagSliLogic);
32
+    }
33
+
34
+## Umeris sine
35
+
36
+Contemptor subitae ortus precor illa, deorum accipe? In epulis ab pietas putat,
37
+ab **addunt** a dicta undam atque mentem decursa Paeonis.
38
+
39
+Pedesque gemma ab Cassiope caedit admota. Montes bracchia securae Atlantiades
40
+adde pectusque. Sed maris quoque, est magis hominesque tenebat ignes ornant:
41
+casus lapsa promunturiumque pervenit se cumque pudorem!
42
+
43
+## Tum donavi tetigit Phineu procul
44
+
45
+Rursus hinc, ut latoque segetes deme invideatis potest igne tactis Actaea dabat
46
+erat orbus hi numinis resistunt falsa obscenas. Vitreis suspiria, monitis
47
+nomina, veniat. Lapsasque gratus tremit ima viget diximus paulatim undis colorem
48
+subnixa **subposuisse cruciata** tantum se serae habenas. Negare in alis, ire
49
+huc!
50
+
51
+## Ferebat generosos lustrat concipias genuisse humus iaculum
52
+
53
+Elimat dominasque avenis virgo meos rogabat nullam novissima hostes, et
54
+harundine tamen; crudelis subita quam, **acu credere**. Saepe in iaculis quoque
55
+ait est inter suam fontana lancea foret? Tenentem ab laeta; est postquam tura
56
+hactenus pascua certis, litora.
57
+
58
+## Est putat instabat et copia liquitur occubuisse
59
+
60
+Retinet laudibus modo tristia adveniens angue mersitque resolvit perque tardae.
61
+Arma imoque, matris sive modo **pedibus**!
62
+
63
+Lumina egredere et virgo obliquis, *vita* chlamydem augebat secus id mediusve:
64
+ferunt mortuaque urbe tuae scopulis officiis. A num matrem glaebam Cyllaron
65
+lanificae ova prius adfixa uda specus seque cunas aut navale causa Tyrrhenaque
66
+ambo; oblitis. Secum favorque sustinui manus. Sociati filia exstat temptat
67
+refugit vero, et a coniunx intres. Virgineo additus mutatis ausorum; ipsa, ora
68
+dixisse mutavit, sceleri!

+ 11
- 1
src/pages/blog/index.md View File

@@ -1,4 +1,14 @@
1 1
 ---
2 2
 layout: blog-archive
3 3
 title: All Blog Posts
4
----
4
+query: '{
5
+    posts {
6
+        frontmatter {
7
+            title
8
+        }
9
+        relativePath
10
+    }
11
+}'
12
+---
13
+
14
+## All blog post

+ 8
- 0
src/pages/index.md View File

@@ -1,6 +1,14 @@
1 1
 ---
2 2
 layout: base
3 3
 title: Stasis Basic Example
4
+query: '{
5
+    pages {
6
+        frontmatter {
7
+            title
8
+        }
9
+        relativePath
10
+    }
11
+}'
4 12
 ---
5 13
 
6 14
 # Hello World

+ 1
- 0
stasis.config.json View File

@@ -3,6 +3,7 @@
3 3
 	"publicPath": "dist",
4 4
 	"assetsPath": "assets",
5 5
 	"staticPath": "static",
6
+	"graphQlPath": "graphql",
6 7
 	"entryAssets": [
7 8
 		"**/*"
8 9
 	]

Loading…
Cancel
Save