Skip to content

Commit

Permalink
SSR guides pages using router.pages
Browse files Browse the repository at this point in the history
Using [this comment](gatsbyjs/gatsby#1457 (comment)) to get TS wired up, so we could import our TS Router in gatsby-node.
  • Loading branch information
samselikoff committed Sep 2, 2019
1 parent 744f67c commit 197d923
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 9 deletions.
25 changes: 18 additions & 7 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,20 @@
*
* See: https://www.gatsbyjs.org/docs/node-apis/
*/
require("source-map-support").install()
require("ts-node").register({
compilerOptions: {
module: "commonjs",
target: "es2017",
},
})

// require = require("esm")(module)
const fs = require("fs")
const path = require("path")
const Router = require("./src/lib/router").Router

let router = new Router()

// I think this was from an earlier strategy at getting the snippet contents, but
// we went back to remark because it supports line highlighting
Expand Down Expand Up @@ -48,11 +60,12 @@ exports.createPages = ({ actions }) => {
})
}

// TODO: Create all pages programatically
createAppPage("/")
createAppPage("/docs/getting-started/introduction")
createAppPage("/docs/getting-started/installation")
createAppPage("/docs/getting-started/usage")
// TODO: Filter out pages with dynamic segments
router.pages.forEach(page => {
createAppPage(page.fullPath)
})

// TODO: Create all API docs pages dynamically
createAppPage("/api/classes/association")
createAppPage("/api/classes/base-route-handler")
createAppPage("/api/classes/base-shorthand-route-handler")
Expand All @@ -78,8 +91,6 @@ exports.createPages = ({ actions }) => {
createAppPage("/api/classes/serializer")
createAppPage("/api/classes/serializer-registry")
createAppPage("/api/classes/server")
createAppPage("/examples/main/react")
createAppPage("/examples/main/vue")

/*
TODO: Create all redirects programatically. All non-page routes should
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@
"react-helmet": "^5.2.1",
"react-transition-group": "^4.2.2",
"remark-slug": "^5.1.2",
"source-map-support": "^0.5.13",
"tailwindcss": "^1.1.2",
"tmp": "^0.1.0"
"tmp": "^0.1.0",
"ts-node": "^8.3.0"
},
"devDependencies": {
"@testing-library/jest-dom": "^4.0.0",
Expand Down
3 changes: 3 additions & 0 deletions src/lib/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Foo() {
console.log("hi")
}
36 changes: 35 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2325,6 +2325,11 @@ are-we-there-yet@~1.1.2:
delegates "^1.0.0"
readable-stream "^2.0.6"

arg@^4.1.0:
version "4.1.1"
resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.1.tgz#485f8e7c390ce4c5f78257dbea80d4be11feda4c"
integrity sha512-SlmP3fEA88MBv0PypnXZ8ZfJhwmDeIE3SP71j37AiXQBXYosPV0x6uISAaHYSlSVhmHOVkomen0tbGk6Anlebw==

argparse@^1.0.7:
version "1.0.10"
resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911"
Expand Down Expand Up @@ -4888,6 +4893,11 @@ diff-sequences@^24.9.0:
resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-24.9.0.tgz#5715d6244e2aa65f48bba0bc972db0b0b11e95b5"
integrity sha512-Dj6Wk3tWyTE+Fo1rW8v0Xhwk80um6yFYKbuAxc9c3EZxIHFDYwbi34Uk42u1CdnIiVorvt4RmlSDjIPyzGC2ew==

diff@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.1.tgz#0c667cb467ebbb5cea7f14f135cc2dba7780a8ff"
integrity sha512-s2+XdvhPCOF01LRQBC8hf4vhbVmI2CGS5aZnxLJlT5FtdhPCDFq80q++zK2KlrVorVDdL5BOGZ/VfLrVtYNF+Q==

diffie-hellman@^5.0.0:
version "5.0.3"
resolved "https://registry.yarnpkg.com/diffie-hellman/-/diffie-hellman-5.0.3.tgz#40e8ee98f55a2149607146921c63e1ae5f3d2875"
Expand Down Expand Up @@ -9814,7 +9824,7 @@ make-dir@^2.0.0, make-dir@^2.1.0:
pify "^4.0.1"
semver "^5.6.0"

make-error@1.x:
make-error@1.x, make-error@^1.1.1:
version "1.3.5"
resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.5.tgz#efe4e81f6db28cadd605c70f29c831b58ef776c8"
integrity sha512-c3sIjNUow0+8swNwVpqoH4YCShKNFkMaw6oH1mNS2haDZQqkeZFlHS3dhoeEbKKmJB4vXpJucU6oH75aDYeE9g==
Expand Down Expand Up @@ -13636,6 +13646,14 @@ source-map-resolve@^0.5.0, source-map-resolve@^0.5.2:
source-map-url "^0.4.0"
urix "^0.1.0"

source-map-support@^0.5.13:
version "0.5.13"
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.13.tgz#31b24a9c2e73c2de85066c0feb7d44767ed52932"
integrity sha512-SHSKFHadjVA5oR4PPqhtAVdcBWwRYVd6g6cAXnIbRiIwc2EhPrTuKUBdSLvlEKyIP3GCf89fltvcZiP9MMFA1w==
dependencies:
buffer-from "^1.0.0"
source-map "^0.6.0"

source-map-support@^0.5.6, source-map-support@~0.5.10:
version "0.5.12"
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.12.tgz#b4f3b10d51857a5af0138d3ce8003b201613d599"
Expand Down Expand Up @@ -14566,6 +14584,17 @@ ts-jest@^24.0.2:
semver "^5.5"
yargs-parser "10.x"

ts-node@^8.3.0:
version "8.3.0"
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-8.3.0.tgz#e4059618411371924a1fb5f3b125915f324efb57"
integrity sha512-dyNS/RqyVTDcmNM4NIBAeDMpsAdaQ+ojdf0GOLqE6nwJOgzEkdRNzJywhDfwnuvB10oa6NLVG1rUJQCpRN7qoQ==
dependencies:
arg "^4.1.0"
diff "^4.0.1"
make-error "^1.1.1"
source-map-support "^0.5.6"
yn "^3.0.0"

ts-pnp@^1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/ts-pnp/-/ts-pnp-1.1.2.tgz#be8e4bfce5d00f0f58e0666a82260c34a57af552"
Expand Down Expand Up @@ -15856,6 +15885,11 @@ yeast@0.1.2:
resolved "https://registry.yarnpkg.com/yeast/-/yeast-0.1.2.tgz#008e06d8094320c372dbc2f8ed76a0ca6c8ac419"
integrity sha1-AI4G2AlDIMNy28L47XagymyKxBk=

yn@^3.0.0:
version "3.1.1"
resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50"
integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==

yoga-layout-prebuilt@^1.9.3:
version "1.9.3"
resolved "https://registry.yarnpkg.com/yoga-layout-prebuilt/-/yoga-layout-prebuilt-1.9.3.tgz#11e3be29096afe3c284e5d963cc2d628148c1372"
Expand Down

0 comments on commit 197d923

Please sign in to comment.