diff --git a/examples/gatsby/decks/hello.mdx b/examples/gatsby/decks/hello.mdx new file mode 100644 index 0000000..01bffa1 --- /dev/null +++ b/examples/gatsby/decks/hello.mdx @@ -0,0 +1,6 @@ + +# Hello + +--- + +This is built with gatsby-theme-mdx-deck diff --git a/examples/gatsby/gatsby-config.js b/examples/gatsby/gatsby-config.js new file mode 100644 index 0000000..cfccbee --- /dev/null +++ b/examples/gatsby/gatsby-config.js @@ -0,0 +1,12 @@ +module.exports = { + pathPrefix: '/mdx-deck', + plugins: [ + 'gatsby-plugin-catch-links', + { + resolve: 'gatsby-theme-mdx-deck', + options: { + basePath: '/slides', + }, + }, + ], +} diff --git a/examples/gatsby/package.json b/examples/gatsby/package.json new file mode 100644 index 0000000..8efa895 --- /dev/null +++ b/examples/gatsby/package.json @@ -0,0 +1,19 @@ +{ + "name": "@mdx-deck/gatsby-example", + "version": "1.0.0", + "main": "index.js", + "license": "MIT", + "scripts": { + "start": "gatsby develop", + "build": "gatsby build --prefix-paths", + "serve": "gatsby serve --prefix-paths", + "gh-pages": "npx gh-pages -d public" + }, + "dependencies": { + "gatsby": "*", + "gatsby-plugin-catch-links": "^2.1.2", + "gatsby-theme-mdx-deck": "3.0.8-alpha.0", + "react": "^16.8.6", + "react-dom": "^16.8.6" + } +} diff --git a/examples/gatsby/src/pages/index.mdx b/examples/gatsby/src/pages/index.mdx new file mode 100644 index 0000000..d2ccc9f --- /dev/null +++ b/examples/gatsby/src/pages/index.mdx @@ -0,0 +1,4 @@ + +# MDX Deck Gatsby Example + +- [Deck](/slides) diff --git a/packages/gatsby-theme/gatsby-node.js b/packages/gatsby-theme/gatsby-node.js index 5edd4ee..7af73b8 100644 --- a/packages/gatsby-theme/gatsby-node.js +++ b/packages/gatsby-theme/gatsby-node.js @@ -101,16 +101,19 @@ exports.createPages = async ({ graphql, actions, reporter, pathPrefix }) => { // single deck mode if (decks.length === 1) { const [deck] = decks - const matchPath = [basePath, '*'].join('/') const base = basePath === '/' ? '' : basePath - const slug = [pathPrefix, base].filter(Boolean).join('/') + const matchPath = [base, '*'].join('/') + + const slug = [pathPrefix, base].filter(Boolean).join('') + console.log({ pathPrefix, base, slug, matchPath }) + createPage({ path: basePath, matchPath, component: DeckTemplate, context: { ...deck.node, - slug, + slug: base, }, }) return diff --git a/yarn.lock b/yarn.lock index 40f3b4d..3daf837 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3145,6 +3145,22 @@ babel-preset-gatsby@^0.2.6: babel-plugin-macros "^2.4.2" babel-plugin-transform-react-remove-prop-types "^0.4.24" +babel-preset-gatsby@^0.2.8: + version "0.2.8" + resolved "https://registry.yarnpkg.com/babel-preset-gatsby/-/babel-preset-gatsby-0.2.8.tgz#976adb62bcf73f1a53374deb3a3a37b8880d5745" + integrity sha512-Cks3TRbx0CvjwW25noYZwideKp/gH8RJypuwd8gJ/Y1JDXrE7Vnjkvct6QH61XLcX7QIkRoissvOt1QqNWyaIg== + dependencies: + "@babel/plugin-proposal-class-properties" "^7.0.0" + "@babel/plugin-syntax-dynamic-import" "^7.0.0" + "@babel/plugin-transform-runtime" "^7.0.0" + "@babel/plugin-transform-spread" "^7.2.2" + "@babel/preset-env" "^7.4.1" + "@babel/preset-react" "^7.0.0" + "@babel/runtime" "^7.4.5" + babel-plugin-dynamic-import-node "^1.2.0" + babel-plugin-macros "^2.4.2" + babel-plugin-transform-react-remove-prop-types "^0.4.24" + babel-preset-jest@^24.6.0: version "24.6.0" resolved "https://registry.yarnpkg.com/babel-preset-jest/-/babel-preset-jest-24.6.0.tgz#66f06136eefce87797539c0d63f1769cc3915984" @@ -6540,6 +6556,57 @@ gatsby-cli@^2.7.15: ink "^2.0.5" ink-spinner "^3.0.1" +gatsby-cli@^2.7.20: + version "2.7.20" + resolved "https://registry.yarnpkg.com/gatsby-cli/-/gatsby-cli-2.7.20.tgz#1117b21802741c18ec6d16cd53dbb7f41bba8d22" + integrity sha512-LVFv8RvMc8zLjCMHOJAdx0nA3Pg7baX7kFUyC/ixMJwhUSy/qUKtt4VNCpGnnTpqjO+743kyVQuw+zNK3dQtIg== + dependencies: + "@babel/code-frame" "^7.0.0" + "@babel/runtime" "^7.0.0" + "@hapi/joi" "^15.1.0" + better-opn "^0.1.4" + bluebird "^3.5.0" + chalk "^2.4.2" + ci-info "^2.0.0" + clipboardy "^1.2.3" + common-tags "^1.4.0" + configstore "^4.0.0" + convert-hrtime "^2.0.0" + core-js "^2.5.0" + envinfo "^5.8.1" + execa "^0.8.0" + fs-exists-cached "^1.0.0" + fs-extra "^4.0.1" + gatsby-telemetry "^1.1.7" + hosted-git-info "^2.6.0" + is-valid-path "^0.1.1" + lodash "^4.17.14" + meant "^1.0.1" + node-fetch "^2.6.0" + object.entries "^1.1.0" + opentracing "^0.14.3" + pretty-error "^2.1.1" + progress "^2.0.3" + prompts "^2.1.0" + react "^16.8.4" + resolve-cwd "^2.0.0" + semver "^6.1.1" + source-map "0.5.7" + stack-trace "^0.0.10" + strip-ansi "^5.2.0" + update-notifier "^2.3.0" + uuid "3.3.2" + yargs "^12.0.5" + yurnalist "^1.0.5" + optionalDependencies: + ink "^2.3.0" + ink-spinner "^3.0.1" + +gatsby-core-utils@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/gatsby-core-utils/-/gatsby-core-utils-1.0.3.tgz#f7616192ac0b4d0fc04587d924533c3cece70980" + integrity sha512-01B0wqVTftFcYwVR7HGJy+Nriy+xxC++VZhsWNCFWtby1NwfSDUwkoScGcZ/jXvg9waEmBC1n70FwVIDnoHzSA== + gatsby-graphiql-explorer@^0.2.3: version "0.2.3" resolved "https://registry.yarnpkg.com/gatsby-graphiql-explorer/-/gatsby-graphiql-explorer-0.2.3.tgz#fdfc6c1b8b5019df57aad025badb552e3141f6e4" @@ -6556,6 +6623,15 @@ gatsby-link@^2.2.2: "@types/reach__router" "^1.0.0" prop-types "^15.6.1" +gatsby-link@^2.2.3: + version "2.2.3" + resolved "https://registry.yarnpkg.com/gatsby-link/-/gatsby-link-2.2.3.tgz#2477c0093a0183014ce8012758db94e06d0cf43d" + integrity sha512-uWDd7QMXIlHk4mTakcUEsvw/VGqcG2M72DFfEDJq50X7gyrm2pwHwsPnT5MQsuqCF+SVNG4ryzJ8TyQotoF/fQ== + dependencies: + "@babel/runtime" "^7.0.0" + "@types/reach__router" "^1.0.0" + prop-types "^15.6.1" + gatsby-page-utils@^0.0.5: version "0.0.5" resolved "https://registry.yarnpkg.com/gatsby-page-utils/-/gatsby-page-utils-0.0.5.tgz#faefc2ece9f14bfd161ddd0104d1e12b54ef7a70" @@ -6570,7 +6646,7 @@ gatsby-page-utils@^0.0.5: micromatch "^3.1.10" slash "^1.0.0" -gatsby-plugin-catch-links@^2.1.0: +gatsby-plugin-catch-links@^2.1.0, gatsby-plugin-catch-links@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/gatsby-plugin-catch-links/-/gatsby-plugin-catch-links-2.1.2.tgz#f7e04e2b390341ba4b1f8f0e12d4bcf78b1e542d" integrity sha512-ur17fNloBJItWH1CtADFyPDqBHfe2NKV0OenuVpCEIHq4mKdWjPO1Q7cC+0/ZKN1GikpsTAabwXy4JwWIKUSew== @@ -6704,6 +6780,161 @@ gatsby-telemetry@^1.1.6: stack-utils "1.0.2" uuid "3.3.2" +gatsby-telemetry@^1.1.7: + version "1.1.7" + resolved "https://registry.yarnpkg.com/gatsby-telemetry/-/gatsby-telemetry-1.1.7.tgz#dd2a363852ce87990249586e75189e7b05d1f561" + integrity sha512-mVJwkg4kdHGBt1OKlpcDO1gKoRd5oiJHKYR1jGrShXbB8FE4c52Z2Geg0xMKNXCeUbMUEZB78IPGlJ94nnPAag== + dependencies: + "@babel/code-frame" "^7.0.0" + "@babel/runtime" "^7.0.0" + bluebird "^3.5.0" + boxen "^3.1.0" + ci-info "2.0.0" + configstore "^4.0.0" + envinfo "^5.8.1" + fs-extra "^7.0.1" + git-up "4.0.1" + is-docker "1.1.0" + lodash "^4.17.14" + node-fetch "2.3.0" + resolve-cwd "^2.0.0" + source-map "^0.5.7" + stack-trace "^0.0.10" + stack-utils "1.0.2" + uuid "3.3.2" + +gatsby@*: + version "2.13.41" + resolved "https://registry.yarnpkg.com/gatsby/-/gatsby-2.13.41.tgz#918e22432b4d487420e4bbf65fbbe1cdd8d3b05e" + integrity sha512-vTPAt4xq2WOqx8EOUA72zUb9joyYiYowK0eBmt4O+HEyDHnLieubO66srTgH0XDsdXKpc1Aivug9oeKgIV5vdQ== + dependencies: + "@babel/code-frame" "^7.0.0" + "@babel/core" "^7.0.0" + "@babel/parser" "^7.0.0" + "@babel/polyfill" "^7.0.0" + "@babel/runtime" "^7.0.0" + "@babel/traverse" "^7.0.0" + "@gatsbyjs/relay-compiler" "2.0.0-printer-fix.2" + "@hapi/joi" "^15.0.0" + "@mikaelkristiansson/domready" "^1.0.9" + "@pieh/friendly-errors-webpack-plugin" "1.7.0-chalk-2" + "@reach/router" "^1.1.1" + address "1.0.3" + autoprefixer "^9.6.0" + babel-core "7.0.0-bridge.0" + babel-eslint "^9.0.0" + babel-loader "^8.0.0" + babel-plugin-add-module-exports "^0.2.1" + babel-plugin-dynamic-import-node "^1.2.0" + babel-plugin-remove-graphql-queries "^2.7.2" + babel-preset-gatsby "^0.2.8" + better-opn "0.1.4" + better-queue "^3.8.6" + bluebird "^3.5.0" + browserslist "3.2.8" + cache-manager "^2.9.0" + cache-manager-fs-hash "^0.0.6" + chalk "^2.3.2" + chokidar "2.1.2" + common-tags "^1.4.0" + compression "^1.7.3" + convert-hrtime "^2.0.0" + copyfiles "^1.2.0" + core-js "^2.5.0" + cors "^2.8.5" + css-loader "^1.0.0" + debug "^3.1.0" + del "^3.0.0" + detect-port "^1.2.1" + devcert-san "^0.3.3" + dotenv "^4.0.0" + eslint "^5.6.0" + eslint-config-react-app "^3.0.0" + eslint-loader "^2.1.0" + eslint-plugin-flowtype "^2.46.1" + eslint-plugin-graphql "^3.0.3" + eslint-plugin-import "^2.9.0" + eslint-plugin-jsx-a11y "^6.0.3" + eslint-plugin-react "^7.8.2" + event-source-polyfill "^1.0.5" + express "^4.16.3" + express-graphql "^0.7.1" + fast-levenshtein "^2.0.6" + file-loader "^1.1.11" + flat "^4.0.0" + fs-exists-cached "1.0.0" + fs-extra "^5.0.0" + gatsby-cli "^2.7.20" + gatsby-core-utils "^1.0.3" + gatsby-graphiql-explorer "^0.2.3" + gatsby-link "^2.2.3" + gatsby-plugin-page-creator "^2.1.5" + gatsby-react-router-scroll "^2.1.3" + gatsby-telemetry "^1.1.7" + glob "^7.1.1" + got "8.0.0" + graphql "^14.1.1" + graphql-compose "^6.3.2" + graphql-playground-middleware-express "^1.7.10" + invariant "^2.2.4" + is-relative "^1.0.0" + is-relative-url "^2.0.0" + is-wsl "^1.1.0" + jest-worker "^23.2.0" + json-loader "^0.5.7" + json-stringify-safe "^5.0.1" + lodash "^4.17.14" + lokijs "^1.5.7" + md5 "^2.2.1" + md5-file "^3.1.1" + micromatch "^3.1.10" + mime "^2.2.0" + mini-css-extract-plugin "^0.4.0" + mitt "^1.1.2" + mkdirp "^0.5.1" + moment "^2.21.0" + name-all-modules-plugin "^1.0.1" + normalize-path "^2.1.1" + null-loader "^0.1.1" + opentracing "^0.14.3" + optimize-css-assets-webpack-plugin "^5.0.1" + parseurl "^1.3.2" + physical-cpu-count "^2.0.0" + pnp-webpack-plugin "^1.4.1" + postcss-flexbugs-fixes "^3.0.0" + postcss-loader "^2.1.3" + prop-types "^15.6.1" + raw-loader "^0.5.1" + react-dev-utils "^4.2.3" + react-error-overlay "^3.0.0" + react-hot-loader "^4.12.5" + redux "^4.0.0" + redux-thunk "^2.3.0" + semver "^5.6.0" + shallow-compare "^1.2.2" + sift "^5.1.0" + signal-exit "^3.0.2" + slash "^1.0.0" + socket.io "^2.0.3" + stack-trace "^0.0.10" + string-similarity "^1.2.0" + style-loader "^0.21.0" + terser-webpack-plugin "1.2.4" + "true-case-path" "^1.0.3" + type-of "^2.0.1" + url-loader "^1.0.1" + util.promisify "^1.0.0" + uuid "^3.1.0" + v8-compile-cache "^1.1.0" + webpack "~4.28.4" + webpack-dev-middleware "^3.0.1" + webpack-dev-server "^3.1.14" + webpack-hot-middleware "^2.21.0" + webpack-merge "^4.1.0" + webpack-stats-plugin "^0.1.5" + xstate "^4.3.2" + yaml-loader "^0.5.0" + gatsby@^2.13.24, gatsby@^2.13.25: version "2.13.25" resolved "https://registry.yarnpkg.com/gatsby/-/gatsby-2.13.25.tgz#8cb7614059f837c708957d06ce34819e3a073f06" @@ -7862,7 +8093,7 @@ ink-spinner@^3.0.1: cli-spinners "^1.0.0" prop-types "^15.5.10" -ink@^2.0.5: +ink@^2.0.5, ink@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/ink/-/ink-2.3.0.tgz#222136be17bb72fc742e19090483e7e0e7dc3690" integrity sha512-931rgXHAS3hM++8ygWPOBeHOFwTzHh3pDAVZtiBVOUH6tVvJijym43ODUy22ySo2NwYUFeR/Zj3xuWzBEKMiHw== @@ -9619,6 +9850,11 @@ loglevel@^1.6.3: resolved "https://registry.yarnpkg.com/loglevel/-/loglevel-1.6.3.tgz#77f2eb64be55a404c9fd04ad16d57c1d6d6b1280" integrity sha512-LoEDv5pgpvWgPF4kNYuIp0qqSJVWak/dML0RY74xlzMZiT9w77teNAwKYKWBTYjlokMirg+o3jBwp+vlLrcfAA== +lokijs@^1.5.7: + version "1.5.7" + resolved "https://registry.yarnpkg.com/lokijs/-/lokijs-1.5.7.tgz#3bbeb5c2dbffebd78d035bac82c7c4e6055870f0" + integrity sha512-2SqUV6JH4f15Z5/7LVsyadSUwHhZppxhujgy/VhVqiRYMGt5oaocb7fV/3JGjHJ6rTuEIajnpTLGRz9cJW/c3g== + longest-streak@^2.0.1: version "2.0.3" resolved "https://registry.yarnpkg.com/longest-streak/-/longest-streak-2.0.3.tgz#3de7a3f47ee18e9074ded8575b5c091f5d0a4105"