├── .circleci └── config.yml ├── .editorconfig ├── .eslintignore ├── .gitignore ├── .prettierignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── examples ├── arnaud │ ├── .gitignore │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── gatsby-browser.js │ ├── gatsby-config.js │ ├── gatsby-node.js │ ├── gatsby-ssr.js │ ├── package.json │ ├── src │ │ ├── components │ │ │ ├── blogpost.js │ │ │ ├── header.js │ │ │ ├── image.js │ │ │ ├── layout.css │ │ │ ├── layout.js │ │ │ └── seo.js │ │ ├── images │ │ │ ├── gatsby-astronaut.png │ │ │ └── gatsby-icon.png │ │ ├── pages │ │ │ ├── 404.js │ │ │ └── index.js │ │ └── prismic │ │ │ └── linkResolver.js │ └── yarn.lock ├── fragments │ ├── .gitignore │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── gatsby-browser.js │ ├── gatsby-config.js │ ├── gatsby-node.js │ ├── gatsby-ssr.js │ ├── package.json │ ├── src │ │ ├── components │ │ │ ├── articles.js │ │ │ ├── header.js │ │ │ ├── image.js │ │ │ ├── layout.css │ │ │ ├── layout.js │ │ │ └── seo.js │ │ ├── fragments │ │ │ └── ArticleFragment.js │ │ ├── images │ │ │ ├── gatsby-astronaut.png │ │ │ └── gatsby-icon.png │ │ ├── pages │ │ │ ├── 404.js │ │ │ └── index.js │ │ └── utils │ │ │ └── linkResolver.js │ └── yarn.lock ├── languages │ ├── .gitignore │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── gatsby-browser.js │ ├── gatsby-config.js │ ├── gatsby-node.js │ ├── gatsby-ssr.js │ ├── package.json │ ├── src │ │ ├── components │ │ │ ├── header.js │ │ │ ├── image.js │ │ │ ├── layout.css │ │ │ ├── layout.js │ │ │ └── seo.js │ │ ├── images │ │ │ ├── gatsby-astronaut.png │ │ │ └── gatsby-icon.png │ │ ├── pages │ │ │ └── 404.js │ │ ├── templates │ │ │ ├── article.js │ │ │ └── home.js │ │ └── utils │ │ │ └── linkResolver.js │ └── yarn.lock ├── pagination │ ├── .gitignore │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── gatsby-browser.js │ ├── gatsby-config.js │ ├── gatsby-node.js │ ├── gatsby-ssr.js │ ├── package.json │ ├── src │ │ ├── components │ │ │ ├── header.js │ │ │ ├── image.js │ │ │ ├── layout.css │ │ │ ├── layout.js │ │ │ └── seo.js │ │ ├── images │ │ │ ├── gatsby-astronaut.png │ │ │ └── gatsby-icon.png │ │ ├── pages │ │ │ ├── 404.js │ │ │ └── index.js │ │ ├── templates │ │ │ └── article.js │ │ └── utils │ │ │ └── linkResolver.js │ └── yarn.lock └── static-query │ ├── .gitignore │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── gatsby-browser.js │ ├── gatsby-config.js │ ├── gatsby-node.js │ ├── gatsby-ssr.js │ ├── package.json │ ├── src │ ├── components │ │ ├── articles.js │ │ ├── header.js │ │ ├── image.js │ │ ├── layout.css │ │ ├── layout.js │ │ └── seo.js │ ├── images │ │ ├── gatsby-astronaut.png │ │ └── gatsby-icon.png │ ├── pages │ │ └── index.js │ └── utils │ │ └── linkResolver.js │ └── yarn.lock ├── lerna.json ├── package.json ├── packages └── gatsby-source-prismic-graphql │ ├── .babelrc │ ├── .editorconfig │ ├── .gitignore │ ├── CHANGELOG.md │ ├── README.md │ ├── package.json │ ├── src │ ├── components │ │ ├── PreviewPage.tsx │ │ ├── WrapPage.tsx │ │ └── withPreview.tsx │ ├── gatsby-browser.tsx │ ├── gatsby-node.ts │ ├── gatsby-ssr.tsx │ ├── index.ts │ ├── interfaces │ │ ├── Dictionary.ts │ │ ├── DocumentMetadata.ts │ │ ├── PageOptions.ts │ │ ├── PluginOptions.ts │ │ └── QueryStorage.ts │ ├── typings.d.ts │ └── utils │ │ ├── createLoadingScreen.ts │ │ ├── getApolloClient.ts │ │ ├── getIntrospectionQueryResultData.ts │ │ ├── index.ts │ │ ├── parseQueryString.ts │ │ └── url.ts │ ├── tsconfig.json │ └── yarn.lock └── yarn.lock /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | 3 | defaults: &defaults 4 | working_directory: ~/repo 5 | docker: 6 | - image: circleci/node:10 7 | 8 | jobs: 9 | test: 10 | <<: *defaults 11 | steps: 12 | - checkout 13 | - restore_cache: 14 | name: Restore Yarn Package Cache 15 | keys: 16 | - yarn-packages-{{ checksum "yarn.lock" }} 17 | - run: 18 | name: Install Dependencies 19 | command: yarn install --frozen-lockfile 20 | - save_cache: 21 | name: Save Yarn Package Cache 22 | key: yarn-packages-{{ checksum "yarn.lock" }} 23 | paths: 24 | - ~/.cache/yarn 25 | - run: yarn run setup 26 | - run: yarn run test 27 | - run: yarn run test:prettier 28 | - persist_to_workspace: 29 | root: ~/repo 30 | paths: . 31 | deploy: 32 | <<: *defaults 33 | steps: 34 | - attach_workspace: 35 | at: ~/repo 36 | - run: 37 | name: Authenticate with registry 38 | command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc 39 | - run: 40 | name: Publish package 41 | command: yarn run lerna publish --canary --force-publish --yes 42 | release: 43 | <<: *defaults 44 | steps: 45 | - attach_workspace: 46 | at: ~/repo 47 | - run: 48 | name: Authenticate with registry 49 | command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc 50 | - run: 51 | name: Publish package 52 | command: yarn run lerna publish from-git --force-publish --yes 53 | 54 | workflows: 55 | version: 2 56 | test: 57 | jobs: 58 | - test: 59 | filters: 60 | branches: 61 | ignore: master 62 | deploy_canary: 63 | jobs: 64 | - test 65 | - deploy: 66 | requires: 67 | - test 68 | filters: 69 | branches: 70 | only: master 71 | tags: 72 | ignore: /^v[0-9]+(\.[0-9]+)*$/ 73 | deploy_release: 74 | jobs: 75 | - test 76 | - release: 77 | requires: 78 | - test 79 | filters: 80 | branches: 81 | ignore: /.*/ 82 | tags: 83 | only: /^v[0-9]+(\.[0-9]+)*$/ 84 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | end_of_line = lf 7 | indent_size = 2 8 | indent_style = space 9 | insert_final_newline = true 10 | trim_trailing_whitespace = true -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | gatsby-source-prismic-graphql/**/*.js -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | *.log 3 | .DS_Store 4 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | .cache 2 | node_modules 3 | public 4 | packages/gatsby-source-prismic-graphql/**/*.js 5 | packages/gatsby-source-prismic-graphql/types/* -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## [3.6.2](https://github.com/birkir/gatsby-source-prismic-graphql/compare/v3.6.1...v3.6.2) (2020-04-28) 7 | 8 | **Note:** Version bump only for package root 9 | 10 | ## [3.6.1](https://github.com/birkir/gatsby-source-prismic-graphql/compare/v3.6.0...v3.6.1) (2020-04-28) 11 | 12 | ### Features 13 | 14 | - attp 2 ([4f42ec9](https://github.com/birkir/gatsby-source-prismic-graphql/commit/4f42ec991cfb3fc5c8e172b2ad2f64786433d1fc)) 15 | - attp 3 ([9bb118f](https://github.com/birkir/gatsby-source-prismic-graphql/commit/9bb118f9a84eb8f40b12a5a12619f8382c870884)) 16 | - no canary on releases ([5a64d7a](https://github.com/birkir/gatsby-source-prismic-graphql/commit/5a64d7a1f521096a027d445b3c1cc9af68ba6966)) 17 | 18 | # [3.6.0](https://github.com/birkir/gatsby-source-prismic-graphql/compare/v3.4.0...v3.6.0) (2020-04-28) 19 | 20 | ### Bug Fixes 21 | 22 | - fix useStaticQuery hook [#77](https://github.com/birkir/gatsby-source-prismic-graphql/issues/77) ([ba15d2b](https://github.com/birkir/gatsby-source-prismic-graphql/commit/ba15d2bf50d63593449c48f54a8c0009c6510e45)) 23 | - bump dep version to fix ERROR [#11321](https://github.com/birkir/gatsby-source-prismic-graphql/issues/11321) ([9500260](https://github.com/birkir/gatsby-source-prismic-graphql/commit/9500260c0cc81600e1b013b7e115275293ed0e89)) 24 | - change travis build to deploy stable version ([46854b8](https://github.com/birkir/gatsby-source-prismic-graphql/commit/46854b8af8b2fe90e8f944060be792eb75042448)) 25 | - fix post review ([9ecc671](https://github.com/birkir/gatsby-source-prismic-graphql/commit/9ecc6711116c05b4002c859ac77beeebe2164e73)) 26 | - fixing type & updating path-to-regexp to use new match function ([eff64d8](https://github.com/birkir/gatsby-source-prismic-graphql/commit/eff64d824438690b7c73ced8f923b5c2f661412d)) 27 | - handle pages with unicode characters ([fa698d5](https://github.com/birkir/gatsby-source-prismic-graphql/commit/fa698d56de2b539f237b18debad6752a92a3524c)) 28 | - multi-lang previews ([e4baba7](https://github.com/birkir/gatsby-source-prismic-graphql/commit/e4baba7bc2c5295bdbb9d20f083891dd127165b1)) 29 | - sanitize accessToken option ([6cb96bf](https://github.com/birkir/gatsby-source-prismic-graphql/commit/6cb96bf37f6b258ebda817c06c6a5ab0c3dbc178)) 30 | - test if page exists to display preview real url ([8705eb9](https://github.com/birkir/gatsby-source-prismic-graphql/commit/8705eb99352fda6aab41a684a25d9f16ef86e836)) 31 | - unescape createRemoteFileNode url ([018efe2](https://github.com/birkir/gatsby-source-prismic-graphql/commit/018efe287d25c1750cfb1e69564a3ca670e693b1)) 32 | - unpublish preview for Multi-language ([9ec4f89](https://github.com/birkir/gatsby-source-prismic-graphql/commit/9ec4f896b64f79bae3415419deb671a6db6dff3e)) 33 | - update function doc ([0bb6b35](https://github.com/birkir/gatsby-source-prismic-graphql/commit/0bb6b3550766313624c751fb2369207471301d3c)) 34 | 35 | ### Features 36 | 37 | - additional query size optimization ([8fcec72](https://github.com/birkir/gatsby-source-prismic-graphql/commit/8fcec72add1b3d4606ec8be27e51cce4a8f81156)) 38 | - extraPageFields option for better filtering ([66ac7ba](https://github.com/birkir/gatsby-source-prismic-graphql/commit/66ac7baa8309eb6a97633aa38a2d44f923ffc2c5)) 39 | - master should publish canary only ([6dde227](https://github.com/birkir/gatsby-source-prismic-graphql/commit/6dde2270c343d4cf35cb5e7a69b494c25abf3ed7)) 40 | - optimize query size ([57e2940](https://github.com/birkir/gatsby-source-prismic-graphql/commit/57e2940342f724ef21bc951b987a409fbc2d9d82)) 41 | - run tagged releases ([02e38e7](https://github.com/birkir/gatsby-source-prismic-graphql/commit/02e38e7e77a7a2307928a1bb1512a7d428261428)) 42 | 43 | # [3.4.0](https://github.com/birkir/gatsby-source-prismic-graphql/compare/v3.4.0-beta.2...v3.4.0) (2020-01-27) 44 | 45 | ### Features 46 | 47 | - add filter explanation to README ([4ff8a62](https://github.com/birkir/gatsby-source-prismic-graphql/commit/4ff8a62)) 48 | - add optional filter to page options ([8bb76aa](https://github.com/birkir/gatsby-source-prismic-graphql/commit/8bb76aa)) 49 | - support short language codes in generated paths ([cf559d6](https://github.com/birkir/gatsby-source-prismic-graphql/commit/cf559d6)) 50 | 51 | # [3.4.0-beta.2](https://github.com/birkir/gatsby-source-prismic-graphql/compare/v3.4.0-beta.1...v3.4.0-beta.2) (2019-08-20) 52 | 53 | ### Bug Fixes 54 | 55 | - remove/delete traverse ([927230d](https://github.com/birkir/gatsby-source-prismic-graphql/commit/927230d)) 56 | 57 | # [3.4.0-beta.1](https://github.com/birkir/gatsby-source-prismic-graphql/compare/v3.4.0-beta.0...v3.4.0-beta.1) (2019-07-29) 58 | 59 | ### Bug Fixes 60 | 61 | - bump prismic-javascript dep to fix timeout connection issues ([36f04f2](https://github.com/birkir/gatsby-source-prismic-graphql/commit/36f04f2)) 62 | - check if proptypes can be added to StaticQuery ([f05a5e6](https://github.com/birkir/gatsby-source-prismic-graphql/commit/f05a5e6)) 63 | 64 | # [3.4.0-beta.0](https://github.com/birkir/gatsby-source-prismic-graphql/compare/v3.3.1...v3.4.0-beta.0) (2019-07-18) 65 | 66 | ### Bug Fixes 67 | 68 | - improve pagination context var names; pass context for previews ([166321c](https://github.com/birkir/gatsby-source-prismic-graphql/commit/166321c)) 69 | - languages example ([84f9253](https://github.com/birkir/gatsby-source-prismic-graphql/commit/84f9253)) 70 | - logic problems with dynamic pagination already in example ([eb0fa26](https://github.com/birkir/gatsby-source-prismic-graphql/commit/eb0fa26)) 71 | - multi-locale path-generation logic, enhanced typing ([bbe2aa5](https://github.com/birkir/gatsby-source-prismic-graphql/commit/bbe2aa5)) 72 | - multi-locale support compatible with pagination ([bffeea2](https://github.com/birkir/gatsby-source-prismic-graphql/commit/bffeea2)) 73 | - sortBy works for all document types ([d861c9d](https://github.com/birkir/gatsby-source-prismic-graphql/commit/d861c9d)) 74 | - support previews in other than defaultLang ([e621a76](https://github.com/birkir/gatsby-source-prismic-graphql/commit/e621a76)) 75 | 76 | ### Features 77 | 78 | - add direct support for referencing next and prev pages ([a3c06db](https://github.com/birkir/gatsby-source-prismic-graphql/commit/a3c06db)) 79 | - add support for passing sortBy for pages ([aa893b4](https://github.com/birkir/gatsby-source-prismic-graphql/commit/aa893b4)) 80 | - create and expose cursor encoding helpers ([a1959ac](https://github.com/birkir/gatsby-source-prismic-graphql/commit/a1959ac)) 81 | - enable backwards pagination by providing lastPageEndCursor ([2f0fe1b](https://github.com/birkir/gatsby-source-prismic-graphql/commit/2f0fe1b)) 82 | 83 | ## [3.3.1](https://github.com/birkir/gatsby-source-prismic-graphql/compare/v3.3.0...v3.3.1) (2019-07-18) 84 | 85 | ### Bug Fixes 86 | 87 | - typo in README.md ([f4e5390](https://github.com/birkir/gatsby-source-prismic-graphql/commit/f4e5390)) 88 | 89 | # [3.3.0](https://github.com/birkir/gatsby-source-prismic-graphql/compare/v3.2.0...v3.3.0) (2019-07-09) 90 | 91 | ### Bug Fixes 92 | 93 | - prettier formatting in unrelated file so tests pass ([a56f66e](https://github.com/birkir/gatsby-source-prismic-graphql/commit/a56f66e)) 94 | - work around 20-page limit for Prismic queries ([861aedf](https://github.com/birkir/gatsby-source-prismic-graphql/commit/861aedf)) 95 | 96 | ### Features 97 | 98 | - gatsby-image support ([f598dcd](https://github.com/birkir/gatsby-source-prismic-graphql/commit/f598dcd)) 99 | 100 | # [3.2.0](https://github.com/birkir/gatsby-source-prismic-graphql/compare/v3.0.0-alpha.0...v3.2.0) (2019-06-04) 101 | 102 | ### Bug Fixes 103 | 104 | - add apollo-boost dependency ([c4334c8](https://github.com/birkir/gatsby-source-prismic-graphql/commit/c4334c8)) 105 | - auto yes ([cc26e91](https://github.com/birkir/gatsby-source-prismic-graphql/commit/cc26e91)) 106 | - circleci ([fe9df4a](https://github.com/birkir/gatsby-source-prismic-graphql/commit/fe9df4a)) 107 | - circleci ([fb36a78](https://github.com/birkir/gatsby-source-prismic-graphql/commit/fb36a78)) 108 | - default files ([be2afec](https://github.com/birkir/gatsby-source-prismic-graphql/commit/be2afec)) 109 | - dependency and load variables ([e826e5f](https://github.com/birkir/gatsby-source-prismic-graphql/commit/e826e5f)) 110 | - ensure location is in props ([82eb8f0](https://github.com/birkir/gatsby-source-prismic-graphql/commit/82eb8f0)) 111 | - example package name ([50ab749](https://github.com/birkir/gatsby-source-prismic-graphql/commit/50ab749)) 112 | - force publish ([d792bc9](https://github.com/birkir/gatsby-source-prismic-graphql/commit/d792bc9)) 113 | - git changes ([343dd00](https://github.com/birkir/gatsby-source-prismic-graphql/commit/343dd00)) 114 | - git config ([7b4a68c](https://github.com/birkir/gatsby-source-prismic-graphql/commit/7b4a68c)) 115 | - lerna bootstrap ([2a1a256](https://github.com/birkir/gatsby-source-prismic-graphql/commit/2a1a256)) 116 | - lerna publish ([7fec548](https://github.com/birkir/gatsby-source-prismic-graphql/commit/7fec548)) 117 | - meh ([569fea5](https://github.com/birkir/gatsby-source-prismic-graphql/commit/569fea5)) 118 | - npm login ([da0286c](https://github.com/birkir/gatsby-source-prismic-graphql/commit/da0286c)) 119 | - prettier ([fbc4395](https://github.com/birkir/gatsby-source-prismic-graphql/commit/fbc4395)) 120 | - prettier ([68ce94c](https://github.com/birkir/gatsby-source-prismic-graphql/commit/68ce94c)) 121 | - preview page with no pages option ([d271ca0](https://github.com/birkir/gatsby-source-prismic-graphql/commit/d271ca0)) 122 | - ssr strip whitespace fetch ([3f843c2](https://github.com/birkir/gatsby-source-prismic-graphql/commit/3f843c2)) 123 | - template title ([9b35c68](https://github.com/birkir/gatsby-source-prismic-graphql/commit/9b35c68)) 124 | - test deploy ([11bb7b5](https://github.com/birkir/gatsby-source-prismic-graphql/commit/11bb7b5)) 125 | - update graphql source plugin ([3b9bab0](https://github.com/birkir/gatsby-source-prismic-graphql/commit/3b9bab0)) 126 | 127 | ### Features 128 | 129 | - fragments ([34f9c78](https://github.com/birkir/gatsby-source-prismic-graphql/commit/34f9c78)) 130 | - fragments ([0bc6912](https://github.com/birkir/gatsby-source-prismic-graphql/commit/0bc6912)) 131 | - languages ([09a1c47](https://github.com/birkir/gatsby-source-prismic-graphql/commit/09a1c47)) 132 | - static query ([6666e34](https://github.com/birkir/gatsby-source-prismic-graphql/commit/6666e34)) 133 | 134 | # 3.0.0-alpha.0 (2019-03-19) 135 | 136 | ### Bug Fixes 137 | 138 | - pageContext as variables by default ([0cd8d57](https://github.com/birkir/gatsby-source-prismic-graphql/commit/0cd8d57)) 139 | - remove multiple graphql packages ([ecd1a09](https://github.com/birkir/gatsby-source-prismic-graphql/commit/ecd1a09)) 140 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright © 2019-present, Birkir Gudjonsson 5 | 6 | Permission is hereby granted, free of charge, to any person 7 | obtaining a copy of this software and associated documentation 8 | files (the “Software”), to deal in the Software without 9 | restriction, including without limitation the rights to use, 10 | copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the 12 | Software is furnished to do so, subject to the following 13 | conditions: 14 | 15 | The above copyright notice and this permission notice shall be 16 | included in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, 19 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 20 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 22 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 25 | OTHER DEALINGS IN THE SOFTWARE. 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | packages/gatsby-source-prismic-graphql/README.md -------------------------------------------------------------------------------- /examples/arnaud/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (http://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # Typescript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # dotenv environment variables file 55 | .env 56 | 57 | # gatsby files 58 | .cache/ 59 | public 60 | 61 | # Mac files 62 | .DS_Store 63 | 64 | # Yarn 65 | yarn-error.log 66 | .pnp/ 67 | .pnp.js 68 | # Yarn Integrity file 69 | .yarn-integrity 70 | -------------------------------------------------------------------------------- /examples/arnaud/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## [3.6.2](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.6.1...v3.6.2) (2020-04-28) 7 | 8 | **Note:** Version bump only for package @examples/arnaud 9 | 10 | ## [3.6.1](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.6.0...v3.6.1) (2020-04-28) 11 | 12 | **Note:** Version bump only for package @examples/arnaud 13 | 14 | # [3.6.0](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.4.0...v3.6.0) (2020-04-28) 15 | 16 | **Note:** Version bump only for package @examples/arnaud 17 | 18 | # [3.4.0](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.4.0-beta.2...v3.4.0) (2020-01-27) 19 | 20 | **Note:** Version bump only for package @examples/arnaud 21 | 22 | # [3.4.0-beta.2](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.4.0-beta.1...v3.4.0-beta.2) (2019-08-20) 23 | 24 | **Note:** Version bump only for package @examples/arnaud 25 | 26 | # [3.4.0-beta.1](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.4.0-beta.0...v3.4.0-beta.1) (2019-07-29) 27 | 28 | **Note:** Version bump only for package @examples/arnaud 29 | 30 | # [3.4.0-beta.0](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.3.1...v3.4.0-beta.0) (2019-07-18) 31 | 32 | **Note:** Version bump only for package @examples/arnaud 33 | 34 | ## [3.3.1](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.3.0...v3.3.1) (2019-07-18) 35 | 36 | **Note:** Version bump only for package @examples/arnaud 37 | 38 | # [3.3.0](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.2.0...v3.3.0) (2019-07-09) 39 | 40 | ### Features 41 | 42 | - gatsby-image support ([f598dcd](https://github.com/gatsbyjs/gatsby-starter-default/commit/f598dcd)) 43 | 44 | # [3.2.0](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.0.0-alpha.0...v3.2.0) (2019-06-04) 45 | 46 | ### Bug Fixes 47 | 48 | - circleci ([fb36a78](https://github.com/gatsbyjs/gatsby-starter-default/commit/fb36a78)) 49 | -------------------------------------------------------------------------------- /examples/arnaud/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 gatsbyjs 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /examples/arnaud/README.md: -------------------------------------------------------------------------------- 1 | 2 |

3 | 4 | Gatsby 5 | 6 |

7 |

8 | Gatsby's default starter 9 |

10 | 11 | Kick off your project with this default boilerplate. This starter ships with the main Gatsby configuration files you might need to get up and running blazing fast with the blazing fast app generator for React. 12 | 13 | _Have another more specific idea? You may want to check out our vibrant collection of [official and community-created starters](https://www.gatsbyjs.org/docs/gatsby-starters/)._ 14 | 15 | ## 🚀 Quick start 16 | 17 | 1. **Create a Gatsby site.** 18 | 19 | Use the Gatsby CLI to create a new site, specifying the default starter. 20 | 21 | ```sh 22 | # create a new Gatsby site using the default starter 23 | gatsby new my-default-starter https://github.com/gatsbyjs/gatsby-starter-default 24 | ``` 25 | 26 | 1. **Start developing.** 27 | 28 | Navigate into your new site’s directory and start it up. 29 | 30 | ```sh 31 | cd my-default-starter/ 32 | gatsby develop 33 | ``` 34 | 35 | 1. **Open the source code and start editing!** 36 | 37 | Your site is now running at `http://localhost:8000`! 38 | 39 | _Note: You'll also see a second link: _`http://localhost:8000/___graphql`_. This is a tool you can use to experiment with querying your data. Learn more about using this tool in the [Gatsby tutorial](https://www.gatsbyjs.org/tutorial/part-five/#introducing-graphiql)._ 40 | 41 | Open the `my-default-starter` directory in your code editor of choice and edit `src/pages/index.js`. Save your changes and the browser will update in real time! 42 | 43 | ## 🧐 What's inside? 44 | 45 | A quick look at the top-level files and directories you'll see in a Gatsby project. 46 | 47 | . 48 | ├── node_modules 49 | ├── src 50 | ├── .gitignore 51 | ├── .prettierrc 52 | ├── gatsby-browser.js 53 | ├── gatsby-config.js 54 | ├── gatsby-node.js 55 | ├── gatsby-ssr.js 56 | ├── LICENSE 57 | ├── package-lock.json 58 | ├── package.json 59 | └── README.md 60 | 61 | 1. **`/node_modules`**: This directory contains all of the modules of code that your project depends on (npm packages) are automatically installed. 62 | 63 | 2. **`/src`**: This directory will contain all of the code related to what you will see on the front-end of your site (what you see in the browser) such as your site header or a page template. `src` is a convention for “source code”. 64 | 65 | 3. **`.gitignore`**: This file tells git which files it should not track / not maintain a version history for. 66 | 67 | 4. **`.prettierrc`**: This is a configuration file for [Prettier](https://prettier.io/). Prettier is a tool to help keep the formatting of your code consistent. 68 | 69 | 5. **`gatsby-browser.js`**: This file is where Gatsby expects to find any usage of the [Gatsby browser APIs](https://www.gatsbyjs.org/docs/browser-apis/) (if any). These allow customization/extension of default Gatsby settings affecting the browser. 70 | 71 | 6. **`gatsby-config.js`**: This is the main configuration file for a Gatsby site. This is where you can specify information about your site (metadata) like the site title and description, which Gatsby plugins you’d like to include, etc. (Check out the [config docs](https://www.gatsbyjs.org/docs/gatsby-config/) for more detail). 72 | 73 | 7. **`gatsby-node.js`**: This file is where Gatsby expects to find any usage of the [Gatsby Node APIs](https://www.gatsbyjs.org/docs/node-apis/) (if any). These allow customization/extension of default Gatsby settings affecting pieces of the site build process. 74 | 75 | 8. **`gatsby-ssr.js`**: This file is where Gatsby expects to find any usage of the [Gatsby server-side rendering APIs](https://www.gatsbyjs.org/docs/ssr-apis/) (if any). These allow customization of default Gatsby settings affecting server-side rendering. 76 | 77 | 9. **`LICENSE`**: Gatsby is licensed under the MIT license. 78 | 79 | 10. **`package-lock.json`** (See `package.json` below, first). This is an automatically generated file based on the exact versions of your npm dependencies that were installed for your project. **(You won’t change this file directly).** 80 | 81 | 11. **`package.json`**: A manifest file for Node.js projects, which includes things like metadata (the project’s name, author, etc). This manifest is how npm knows which packages to install for your project. 82 | 83 | 12. **`README.md`**: A text file containing useful reference information about your project. 84 | 85 | ## 🎓 Learning Gatsby 86 | 87 | Looking for more guidance? Full documentation for Gatsby lives [on the website](https://www.gatsbyjs.org/). Here are some places to start: 88 | 89 | - **For most developers, we recommend starting with our [in-depth tutorial for creating a site with Gatsby](https://www.gatsbyjs.org/tutorial/).** It starts with zero assumptions about your level of ability and walks through every step of the process. 90 | 91 | - **To dive straight into code samples, head [to our documentation](https://www.gatsbyjs.org/docs/).** In particular, check out the _Guides_, _API Reference_, and _Advanced Tutorials_ sections in the sidebar. 92 | 93 | ## 💫 Deploy 94 | 95 | [![Deploy to Netlify](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/gatsbyjs/gatsby-starter-default) 96 | 97 | 98 | -------------------------------------------------------------------------------- /examples/arnaud/gatsby-browser.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Implement Gatsby's Browser APIs in this file. 3 | * 4 | * See: https://www.gatsbyjs.org/docs/browser-apis/ 5 | */ 6 | 7 | // You can delete this file if you're not using it 8 | const { registerLinkResolver } = require('gatsby-source-prismic-graphql'); 9 | 10 | registerLinkResolver(require('./src/prismic/linkResolver').linkResolver); 11 | -------------------------------------------------------------------------------- /examples/arnaud/gatsby-config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | siteMetadata: { 3 | title: `Gatsby Default Starter`, 4 | description: `Kick off your next, great Gatsby project with this default starter. This barebones starter ships with the main Gatsby configuration files you might need.`, 5 | author: `@gatsbyjs`, 6 | }, 7 | plugins: [ 8 | { 9 | resolve: `gatsby-source-prismic-graphql`, 10 | options: { 11 | repositoryName: 'gatsby-demo-site', 12 | pages: [ 13 | { 14 | type: 'Blogpos', 15 | match: '/blogpost/:uid', 16 | path: '/blogpost', 17 | component: require.resolve('./src/components/blogpost.js'), 18 | }, 19 | ], 20 | }, 21 | }, 22 | `gatsby-plugin-react-helmet`, 23 | { 24 | resolve: `gatsby-source-filesystem`, 25 | options: { 26 | name: `images`, 27 | path: `${__dirname}/src/images`, 28 | }, 29 | }, 30 | `gatsby-transformer-sharp`, 31 | `gatsby-plugin-sharp`, 32 | { 33 | resolve: `gatsby-plugin-manifest`, 34 | options: { 35 | name: `gatsby-starter-default`, 36 | short_name: `starter`, 37 | start_url: `/`, 38 | background_color: `#663399`, 39 | theme_color: `#663399`, 40 | display: `minimal-ui`, 41 | icon: `src/images/gatsby-icon.png`, // This path is relative to the root of the site. 42 | }, 43 | }, 44 | // this (optional) plugin enables Progressive Web App + Offline functionality 45 | // To learn more, visit: https://gatsby.dev/offline 46 | // 'gatsby-plugin-offline', 47 | ], 48 | }; 49 | -------------------------------------------------------------------------------- /examples/arnaud/gatsby-node.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Implement Gatsby's Node APIs in this file. 3 | * 4 | * See: https://www.gatsbyjs.org/docs/node-apis/ 5 | */ 6 | -------------------------------------------------------------------------------- /examples/arnaud/gatsby-ssr.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Implement Gatsby's SSR (Server Side Rendering) APIs in this file. 3 | * 4 | * See: https://www.gatsbyjs.org/docs/ssr-apis/ 5 | */ 6 | 7 | // You can delete this file if you're not using it 8 | -------------------------------------------------------------------------------- /examples/arnaud/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@examples/arnaud", 3 | "private": true, 4 | "version": "3.6.2", 5 | "description": "A simple starter to get up and developing quickly with Gatsby", 6 | "author": "Kyle Mathews ", 7 | "dependencies": { 8 | "@babel/polyfill": "^7.2.5", 9 | "esm": "^3.2.18", 10 | "gatsby": "^2.13.37", 11 | "gatsby-image": "^2.0.34", 12 | "gatsby-plugin-manifest": "^2.0.24", 13 | "gatsby-plugin-offline": "^2.0.25", 14 | "gatsby-plugin-react-helmet": "^3.0.10", 15 | "gatsby-plugin-sharp": "^2.2.9", 16 | "gatsby-source-filesystem": "^2.0.27", 17 | "gatsby-source-prismic-graphql": "^3.6.2", 18 | "gatsby-transformer-sharp": "^2.2.5", 19 | "prismic-reactjs": "^0.3.2", 20 | "prop-types": "^15.7.2", 21 | "react": "^16.8.4", 22 | "react-dom": "^16.8.4", 23 | "react-helmet": "^5.2.0" 24 | }, 25 | "devDependencies": { 26 | "prettier": "^1.16.4" 27 | }, 28 | "keywords": [ 29 | "gatsby" 30 | ], 31 | "license": "MIT", 32 | "scripts": { 33 | "build": "gatsby build", 34 | "develop": "gatsby develop", 35 | "format": "prettier --write src/**/*.{js,jsx}", 36 | "start": "npm run develop", 37 | "serve": "gatsby serve", 38 | "test": "echo \"Write tests! -> https://gatsby.dev/unit-testing\"" 39 | }, 40 | "eslintIgnore": [ 41 | "*.js" 42 | ], 43 | "repository": { 44 | "type": "git", 45 | "url": "https://github.com/gatsbyjs/gatsby-starter-default" 46 | }, 47 | "bugs": { 48 | "url": "https://github.com/gatsbyjs/gatsby/issues" 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /examples/arnaud/src/components/blogpost.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { RichText } from 'prismic-reactjs'; 3 | import { graphql } from 'gatsby'; 4 | import { linkResolver } from '../prismic/linkResolver'; 5 | import get from 'lodash/get'; 6 | 7 | export const query = graphql` 8 | query BlogPost($uid: String) { 9 | prismic { 10 | allBlogposs(uid: $uid) { 11 | edges { 12 | node { 13 | _meta { 14 | uid 15 | lang 16 | } 17 | title 18 | body 19 | } 20 | } 21 | } 22 | } 23 | } 24 | `; 25 | 26 | const BlogPost = props => { 27 | const edges = get(props.data, 'prismic.allBlogposs.edges', []); 28 | const data = get(edges, '0.node'); 29 | 30 | if (!data) { 31 | return null; 32 | } 33 | 34 | return ( 35 |
36 |

{RichText.asText(data.title)}

37 | {RichText.render(data.body, linkResolver)} 38 |
39 | ); 40 | }; 41 | 42 | export default BlogPost; 43 | -------------------------------------------------------------------------------- /examples/arnaud/src/components/header.js: -------------------------------------------------------------------------------- 1 | import { Link } from 'gatsby'; 2 | import PropTypes from 'prop-types'; 3 | import React from 'react'; 4 | 5 | const Header = ({ siteTitle }) => ( 6 |
12 |
19 |

20 | 27 | {siteTitle} 28 | 29 |

30 |
31 |
32 | ); 33 | 34 | Header.propTypes = { 35 | siteTitle: PropTypes.string, 36 | }; 37 | 38 | Header.defaultProps = { 39 | siteTitle: ``, 40 | }; 41 | 42 | export default Header; 43 | -------------------------------------------------------------------------------- /examples/arnaud/src/components/image.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { StaticQuery, graphql } from 'gatsby'; 3 | import Img from 'gatsby-image'; 4 | 5 | /* 6 | * This component is built using `gatsby-image` to automatically serve optimized 7 | * images with lazy loading and reduced file sizes. The image is loaded using a 8 | * `StaticQuery`, which allows us to load the image from directly within this 9 | * component, rather than having to pass the image data down from pages. 10 | * 11 | * For more information, see the docs: 12 | * - `gatsby-image`: https://gatsby.dev/gatsby-image 13 | * - `StaticQuery`: https://gatsby.dev/staticquery 14 | */ 15 | 16 | const Image = () => ( 17 | } 30 | /> 31 | ); 32 | export default Image; 33 | -------------------------------------------------------------------------------- /examples/arnaud/src/components/layout.css: -------------------------------------------------------------------------------- 1 | html { 2 | font-family: sans-serif; 3 | -ms-text-size-adjust: 100%; 4 | -webkit-text-size-adjust: 100%; 5 | } 6 | body { 7 | margin: 0; 8 | -webkit-font-smoothing: antialiased; 9 | -moz-osx-font-smoothing: grayscale; 10 | } 11 | article, 12 | aside, 13 | details, 14 | figcaption, 15 | figure, 16 | footer, 17 | header, 18 | main, 19 | menu, 20 | nav, 21 | section, 22 | summary { 23 | display: block; 24 | } 25 | audio, 26 | canvas, 27 | progress, 28 | video { 29 | display: inline-block; 30 | } 31 | audio:not([controls]) { 32 | display: none; 33 | height: 0; 34 | } 35 | progress { 36 | vertical-align: baseline; 37 | } 38 | [hidden], 39 | template { 40 | display: none; 41 | } 42 | a { 43 | background-color: transparent; 44 | -webkit-text-decoration-skip: objects; 45 | } 46 | a:active, 47 | a:hover { 48 | outline-width: 0; 49 | } 50 | abbr[title] { 51 | border-bottom: none; 52 | text-decoration: underline; 53 | text-decoration: underline dotted; 54 | } 55 | b, 56 | strong { 57 | font-weight: inherit; 58 | font-weight: bolder; 59 | } 60 | dfn { 61 | font-style: italic; 62 | } 63 | h1 { 64 | font-size: 2em; 65 | margin: 0.67em 0; 66 | } 67 | mark { 68 | background-color: #ff0; 69 | color: #000; 70 | } 71 | small { 72 | font-size: 80%; 73 | } 74 | sub, 75 | sup { 76 | font-size: 75%; 77 | line-height: 0; 78 | position: relative; 79 | vertical-align: baseline; 80 | } 81 | sub { 82 | bottom: -0.25em; 83 | } 84 | sup { 85 | top: -0.5em; 86 | } 87 | img { 88 | border-style: none; 89 | } 90 | svg:not(:root) { 91 | overflow: hidden; 92 | } 93 | code, 94 | kbd, 95 | pre, 96 | samp { 97 | font-family: monospace, monospace; 98 | font-size: 1em; 99 | } 100 | figure { 101 | margin: 1em 40px; 102 | } 103 | hr { 104 | box-sizing: content-box; 105 | height: 0; 106 | overflow: visible; 107 | } 108 | button, 109 | input, 110 | optgroup, 111 | select, 112 | textarea { 113 | font: inherit; 114 | margin: 0; 115 | } 116 | optgroup { 117 | font-weight: 700; 118 | } 119 | button, 120 | input { 121 | overflow: visible; 122 | } 123 | button, 124 | select { 125 | text-transform: none; 126 | } 127 | [type="reset"], 128 | [type="submit"], 129 | button, 130 | html [type="button"] { 131 | -webkit-appearance: button; 132 | } 133 | [type="button"]::-moz-focus-inner, 134 | [type="reset"]::-moz-focus-inner, 135 | [type="submit"]::-moz-focus-inner, 136 | button::-moz-focus-inner { 137 | border-style: none; 138 | padding: 0; 139 | } 140 | [type="button"]:-moz-focusring, 141 | [type="reset"]:-moz-focusring, 142 | [type="submit"]:-moz-focusring, 143 | button:-moz-focusring { 144 | outline: 1px dotted ButtonText; 145 | } 146 | fieldset { 147 | border: 1px solid silver; 148 | margin: 0 2px; 149 | padding: 0.35em 0.625em 0.75em; 150 | } 151 | legend { 152 | box-sizing: border-box; 153 | color: inherit; 154 | display: table; 155 | max-width: 100%; 156 | padding: 0; 157 | white-space: normal; 158 | } 159 | textarea { 160 | overflow: auto; 161 | } 162 | [type="checkbox"], 163 | [type="radio"] { 164 | box-sizing: border-box; 165 | padding: 0; 166 | } 167 | [type="number"]::-webkit-inner-spin-button, 168 | [type="number"]::-webkit-outer-spin-button { 169 | height: auto; 170 | } 171 | [type="search"] { 172 | -webkit-appearance: textfield; 173 | outline-offset: -2px; 174 | } 175 | [type="search"]::-webkit-search-cancel-button, 176 | [type="search"]::-webkit-search-decoration { 177 | -webkit-appearance: none; 178 | } 179 | ::-webkit-input-placeholder { 180 | color: inherit; 181 | opacity: 0.54; 182 | } 183 | ::-webkit-file-upload-button { 184 | -webkit-appearance: button; 185 | font: inherit; 186 | } 187 | html { 188 | font: 112.5%/1.45em georgia, serif; 189 | box-sizing: border-box; 190 | overflow-y: scroll; 191 | } 192 | * { 193 | box-sizing: inherit; 194 | } 195 | *:before { 196 | box-sizing: inherit; 197 | } 198 | *:after { 199 | box-sizing: inherit; 200 | } 201 | body { 202 | color: hsla(0, 0%, 0%, 0.8); 203 | font-family: georgia, serif; 204 | font-weight: normal; 205 | word-wrap: break-word; 206 | font-kerning: normal; 207 | -moz-font-feature-settings: "kern", "liga", "clig", "calt"; 208 | -ms-font-feature-settings: "kern", "liga", "clig", "calt"; 209 | -webkit-font-feature-settings: "kern", "liga", "clig", "calt"; 210 | font-feature-settings: "kern", "liga", "clig", "calt"; 211 | } 212 | img { 213 | max-width: 100%; 214 | margin-left: 0; 215 | margin-right: 0; 216 | margin-top: 0; 217 | padding-bottom: 0; 218 | padding-left: 0; 219 | padding-right: 0; 220 | padding-top: 0; 221 | margin-bottom: 1.45rem; 222 | } 223 | h1 { 224 | margin-left: 0; 225 | margin-right: 0; 226 | margin-top: 0; 227 | padding-bottom: 0; 228 | padding-left: 0; 229 | padding-right: 0; 230 | padding-top: 0; 231 | margin-bottom: 1.45rem; 232 | color: inherit; 233 | font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, 234 | Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif; 235 | font-weight: bold; 236 | text-rendering: optimizeLegibility; 237 | font-size: 2.25rem; 238 | line-height: 1.1; 239 | } 240 | h2 { 241 | margin-left: 0; 242 | margin-right: 0; 243 | margin-top: 0; 244 | padding-bottom: 0; 245 | padding-left: 0; 246 | padding-right: 0; 247 | padding-top: 0; 248 | margin-bottom: 1.45rem; 249 | color: inherit; 250 | font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, 251 | Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif; 252 | font-weight: bold; 253 | text-rendering: optimizeLegibility; 254 | font-size: 1.62671rem; 255 | line-height: 1.1; 256 | } 257 | h3 { 258 | margin-left: 0; 259 | margin-right: 0; 260 | margin-top: 0; 261 | padding-bottom: 0; 262 | padding-left: 0; 263 | padding-right: 0; 264 | padding-top: 0; 265 | margin-bottom: 1.45rem; 266 | color: inherit; 267 | font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, 268 | Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif; 269 | font-weight: bold; 270 | text-rendering: optimizeLegibility; 271 | font-size: 1.38316rem; 272 | line-height: 1.1; 273 | } 274 | h4 { 275 | margin-left: 0; 276 | margin-right: 0; 277 | margin-top: 0; 278 | padding-bottom: 0; 279 | padding-left: 0; 280 | padding-right: 0; 281 | padding-top: 0; 282 | margin-bottom: 1.45rem; 283 | color: inherit; 284 | font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, 285 | Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif; 286 | font-weight: bold; 287 | text-rendering: optimizeLegibility; 288 | font-size: 1rem; 289 | line-height: 1.1; 290 | } 291 | h5 { 292 | margin-left: 0; 293 | margin-right: 0; 294 | margin-top: 0; 295 | padding-bottom: 0; 296 | padding-left: 0; 297 | padding-right: 0; 298 | padding-top: 0; 299 | margin-bottom: 1.45rem; 300 | color: inherit; 301 | font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, 302 | Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif; 303 | font-weight: bold; 304 | text-rendering: optimizeLegibility; 305 | font-size: 0.85028rem; 306 | line-height: 1.1; 307 | } 308 | h6 { 309 | margin-left: 0; 310 | margin-right: 0; 311 | margin-top: 0; 312 | padding-bottom: 0; 313 | padding-left: 0; 314 | padding-right: 0; 315 | padding-top: 0; 316 | margin-bottom: 1.45rem; 317 | color: inherit; 318 | font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, 319 | Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif; 320 | font-weight: bold; 321 | text-rendering: optimizeLegibility; 322 | font-size: 0.78405rem; 323 | line-height: 1.1; 324 | } 325 | hgroup { 326 | margin-left: 0; 327 | margin-right: 0; 328 | margin-top: 0; 329 | padding-bottom: 0; 330 | padding-left: 0; 331 | padding-right: 0; 332 | padding-top: 0; 333 | margin-bottom: 1.45rem; 334 | } 335 | ul { 336 | margin-left: 1.45rem; 337 | margin-right: 0; 338 | margin-top: 0; 339 | padding-bottom: 0; 340 | padding-left: 0; 341 | padding-right: 0; 342 | padding-top: 0; 343 | margin-bottom: 1.45rem; 344 | list-style-position: outside; 345 | list-style-image: none; 346 | } 347 | ol { 348 | margin-left: 1.45rem; 349 | margin-right: 0; 350 | margin-top: 0; 351 | padding-bottom: 0; 352 | padding-left: 0; 353 | padding-right: 0; 354 | padding-top: 0; 355 | margin-bottom: 1.45rem; 356 | list-style-position: outside; 357 | list-style-image: none; 358 | } 359 | dl { 360 | margin-left: 0; 361 | margin-right: 0; 362 | margin-top: 0; 363 | padding-bottom: 0; 364 | padding-left: 0; 365 | padding-right: 0; 366 | padding-top: 0; 367 | margin-bottom: 1.45rem; 368 | } 369 | dd { 370 | margin-left: 0; 371 | margin-right: 0; 372 | margin-top: 0; 373 | padding-bottom: 0; 374 | padding-left: 0; 375 | padding-right: 0; 376 | padding-top: 0; 377 | margin-bottom: 1.45rem; 378 | } 379 | p { 380 | margin-left: 0; 381 | margin-right: 0; 382 | margin-top: 0; 383 | padding-bottom: 0; 384 | padding-left: 0; 385 | padding-right: 0; 386 | padding-top: 0; 387 | margin-bottom: 1.45rem; 388 | } 389 | figure { 390 | margin-left: 0; 391 | margin-right: 0; 392 | margin-top: 0; 393 | padding-bottom: 0; 394 | padding-left: 0; 395 | padding-right: 0; 396 | padding-top: 0; 397 | margin-bottom: 1.45rem; 398 | } 399 | pre { 400 | margin-left: 0; 401 | margin-right: 0; 402 | margin-top: 0; 403 | margin-bottom: 1.45rem; 404 | font-size: 0.85rem; 405 | line-height: 1.42; 406 | background: hsla(0, 0%, 0%, 0.04); 407 | border-radius: 3px; 408 | overflow: auto; 409 | word-wrap: normal; 410 | padding: 1.45rem; 411 | } 412 | table { 413 | margin-left: 0; 414 | margin-right: 0; 415 | margin-top: 0; 416 | padding-bottom: 0; 417 | padding-left: 0; 418 | padding-right: 0; 419 | padding-top: 0; 420 | margin-bottom: 1.45rem; 421 | font-size: 1rem; 422 | line-height: 1.45rem; 423 | border-collapse: collapse; 424 | width: 100%; 425 | } 426 | fieldset { 427 | margin-left: 0; 428 | margin-right: 0; 429 | margin-top: 0; 430 | padding-bottom: 0; 431 | padding-left: 0; 432 | padding-right: 0; 433 | padding-top: 0; 434 | margin-bottom: 1.45rem; 435 | } 436 | blockquote { 437 | margin-left: 1.45rem; 438 | margin-right: 1.45rem; 439 | margin-top: 0; 440 | padding-bottom: 0; 441 | padding-left: 0; 442 | padding-right: 0; 443 | padding-top: 0; 444 | margin-bottom: 1.45rem; 445 | } 446 | form { 447 | margin-left: 0; 448 | margin-right: 0; 449 | margin-top: 0; 450 | padding-bottom: 0; 451 | padding-left: 0; 452 | padding-right: 0; 453 | padding-top: 0; 454 | margin-bottom: 1.45rem; 455 | } 456 | noscript { 457 | margin-left: 0; 458 | margin-right: 0; 459 | margin-top: 0; 460 | padding-bottom: 0; 461 | padding-left: 0; 462 | padding-right: 0; 463 | padding-top: 0; 464 | margin-bottom: 1.45rem; 465 | } 466 | iframe { 467 | margin-left: 0; 468 | margin-right: 0; 469 | margin-top: 0; 470 | padding-bottom: 0; 471 | padding-left: 0; 472 | padding-right: 0; 473 | padding-top: 0; 474 | margin-bottom: 1.45rem; 475 | } 476 | hr { 477 | margin-left: 0; 478 | margin-right: 0; 479 | margin-top: 0; 480 | padding-bottom: 0; 481 | padding-left: 0; 482 | padding-right: 0; 483 | padding-top: 0; 484 | margin-bottom: calc(1.45rem - 1px); 485 | background: hsla(0, 0%, 0%, 0.2); 486 | border: none; 487 | height: 1px; 488 | } 489 | address { 490 | margin-left: 0; 491 | margin-right: 0; 492 | margin-top: 0; 493 | padding-bottom: 0; 494 | padding-left: 0; 495 | padding-right: 0; 496 | padding-top: 0; 497 | margin-bottom: 1.45rem; 498 | } 499 | b { 500 | font-weight: bold; 501 | } 502 | strong { 503 | font-weight: bold; 504 | } 505 | dt { 506 | font-weight: bold; 507 | } 508 | th { 509 | font-weight: bold; 510 | } 511 | li { 512 | margin-bottom: calc(1.45rem / 2); 513 | } 514 | ol li { 515 | padding-left: 0; 516 | } 517 | ul li { 518 | padding-left: 0; 519 | } 520 | li > ol { 521 | margin-left: 1.45rem; 522 | margin-bottom: calc(1.45rem / 2); 523 | margin-top: calc(1.45rem / 2); 524 | } 525 | li > ul { 526 | margin-left: 1.45rem; 527 | margin-bottom: calc(1.45rem / 2); 528 | margin-top: calc(1.45rem / 2); 529 | } 530 | blockquote *:last-child { 531 | margin-bottom: 0; 532 | } 533 | li *:last-child { 534 | margin-bottom: 0; 535 | } 536 | p *:last-child { 537 | margin-bottom: 0; 538 | } 539 | li > p { 540 | margin-bottom: calc(1.45rem / 2); 541 | } 542 | code { 543 | font-size: 0.85rem; 544 | line-height: 1.45rem; 545 | } 546 | kbd { 547 | font-size: 0.85rem; 548 | line-height: 1.45rem; 549 | } 550 | samp { 551 | font-size: 0.85rem; 552 | line-height: 1.45rem; 553 | } 554 | abbr { 555 | border-bottom: 1px dotted hsla(0, 0%, 0%, 0.5); 556 | cursor: help; 557 | } 558 | acronym { 559 | border-bottom: 1px dotted hsla(0, 0%, 0%, 0.5); 560 | cursor: help; 561 | } 562 | abbr[title] { 563 | border-bottom: 1px dotted hsla(0, 0%, 0%, 0.5); 564 | cursor: help; 565 | text-decoration: none; 566 | } 567 | thead { 568 | text-align: left; 569 | } 570 | td, 571 | th { 572 | text-align: left; 573 | border-bottom: 1px solid hsla(0, 0%, 0%, 0.12); 574 | font-feature-settings: "tnum"; 575 | -moz-font-feature-settings: "tnum"; 576 | -ms-font-feature-settings: "tnum"; 577 | -webkit-font-feature-settings: "tnum"; 578 | padding-left: 0.96667rem; 579 | padding-right: 0.96667rem; 580 | padding-top: 0.725rem; 581 | padding-bottom: calc(0.725rem - 1px); 582 | } 583 | th:first-child, 584 | td:first-child { 585 | padding-left: 0; 586 | } 587 | th:last-child, 588 | td:last-child { 589 | padding-right: 0; 590 | } 591 | tt, 592 | code { 593 | background-color: hsla(0, 0%, 0%, 0.04); 594 | border-radius: 3px; 595 | font-family: "SFMono-Regular", Consolas, "Roboto Mono", "Droid Sans Mono", 596 | "Liberation Mono", Menlo, Courier, monospace; 597 | padding: 0; 598 | padding-top: 0.2em; 599 | padding-bottom: 0.2em; 600 | } 601 | pre code { 602 | background: none; 603 | line-height: 1.42; 604 | } 605 | code:before, 606 | code:after, 607 | tt:before, 608 | tt:after { 609 | letter-spacing: -0.2em; 610 | content: " "; 611 | } 612 | pre code:before, 613 | pre code:after, 614 | pre tt:before, 615 | pre tt:after { 616 | content: ""; 617 | } 618 | @media only screen and (max-width: 480px) { 619 | html { 620 | font-size: 100%; 621 | } 622 | } 623 | -------------------------------------------------------------------------------- /examples/arnaud/src/components/layout.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Layout component that queries for data 3 | * with Gatsby's StaticQuery component 4 | * 5 | * See: https://www.gatsbyjs.org/docs/static-query/ 6 | */ 7 | 8 | import React from 'react'; 9 | import PropTypes from 'prop-types'; 10 | import { StaticQuery, graphql } from 'gatsby'; 11 | 12 | import Header from './header'; 13 | import './layout.css'; 14 | 15 | const Layout = ({ children }) => ( 16 | ( 27 | <> 28 |
29 |
37 |
{children}
38 |
39 | © {new Date().getFullYear()}, Built with 40 | {` `} 41 | Gatsby 42 |
43 |
44 | 45 | )} 46 | /> 47 | ); 48 | 49 | Layout.propTypes = { 50 | children: PropTypes.node.isRequired, 51 | }; 52 | 53 | export default Layout; 54 | -------------------------------------------------------------------------------- /examples/arnaud/src/components/seo.js: -------------------------------------------------------------------------------- 1 | /** 2 | * SEO component that queries for data with 3 | * Gatsby's useStaticQuery React hook 4 | * 5 | * See: https://www.gatsbyjs.org/docs/use-static-query/ 6 | */ 7 | 8 | import React from 'react'; 9 | import PropTypes from 'prop-types'; 10 | import Helmet from 'react-helmet'; 11 | import { useStaticQuery, graphql } from 'gatsby'; 12 | 13 | function SEO({ description, lang, meta, keywords, title }) { 14 | const { site } = useStaticQuery( 15 | graphql` 16 | query { 17 | site { 18 | siteMetadata { 19 | title 20 | description 21 | author 22 | } 23 | } 24 | } 25 | ` 26 | ); 27 | 28 | const metaDescription = description || site.siteMetadata.description; 29 | 30 | return ( 31 | 0 73 | ? { 74 | name: `keywords`, 75 | content: keywords.join(`, `), 76 | } 77 | : [] 78 | ) 79 | .concat(meta)} 80 | /> 81 | ); 82 | } 83 | 84 | SEO.defaultProps = { 85 | lang: `en`, 86 | meta: [], 87 | keywords: [], 88 | }; 89 | 90 | SEO.propTypes = { 91 | description: PropTypes.string, 92 | lang: PropTypes.string, 93 | meta: PropTypes.array, 94 | keywords: PropTypes.arrayOf(PropTypes.string), 95 | title: PropTypes.string.isRequired, 96 | }; 97 | 98 | export default SEO; 99 | -------------------------------------------------------------------------------- /examples/arnaud/src/images/gatsby-astronaut.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/birkir/gatsby-source-prismic-graphql/5003402d62fcfe865339785524b6be95c8f0b5eb/examples/arnaud/src/images/gatsby-astronaut.png -------------------------------------------------------------------------------- /examples/arnaud/src/images/gatsby-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/birkir/gatsby-source-prismic-graphql/5003402d62fcfe865339785524b6be95c8f0b5eb/examples/arnaud/src/images/gatsby-icon.png -------------------------------------------------------------------------------- /examples/arnaud/src/pages/404.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import Layout from '../components/layout'; 4 | import SEO from '../components/seo'; 5 | 6 | const NotFoundPage = () => ( 7 | 8 | 9 |

NOT FOUND

10 |

You just hit a route that doesn't exist... the sadness.

11 |
12 | ); 13 | 14 | export default NotFoundPage; 15 | -------------------------------------------------------------------------------- /examples/arnaud/src/pages/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { RichText } from 'prismic-reactjs'; 3 | import { graphql } from 'gatsby'; 4 | 5 | export const query = graphql` 6 | query { 7 | prismic { 8 | allHomepages { 9 | edges { 10 | node { 11 | title 12 | } 13 | } 14 | } 15 | } 16 | } 17 | `; 18 | 19 | const Homepage = props => { 20 | const data = props.data.prismic.allHomepages.edges[0].node; 21 | 22 | return ( 23 |
24 |

{RichText.asText(data.title)}

25 |
26 | ); 27 | }; 28 | 29 | export default Homepage; 30 | -------------------------------------------------------------------------------- /examples/arnaud/src/prismic/linkResolver.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | linkResolver(doc) { 3 | if (doc.type === 'blogpos') return `/blogpost/${doc.uid}`; 4 | else if (doc.type === 'homepage') return `/`; 5 | else return '/'; 6 | }, 7 | }; 8 | -------------------------------------------------------------------------------- /examples/fragments/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (http://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # Typescript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # dotenv environment variables file 55 | .env 56 | 57 | # gatsby files 58 | .cache/ 59 | public 60 | 61 | # Mac files 62 | .DS_Store 63 | 64 | # Yarn 65 | yarn-error.log 66 | .pnp/ 67 | .pnp.js 68 | # Yarn Integrity file 69 | .yarn-integrity 70 | -------------------------------------------------------------------------------- /examples/fragments/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## [3.6.2](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.6.1...v3.6.2) (2020-04-28) 7 | 8 | **Note:** Version bump only for package @examples/fragments 9 | 10 | ## [3.6.1](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.6.0...v3.6.1) (2020-04-28) 11 | 12 | **Note:** Version bump only for package @examples/fragments 13 | 14 | # [3.6.0](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.4.0...v3.6.0) (2020-04-28) 15 | 16 | **Note:** Version bump only for package @examples/fragments 17 | 18 | # [3.4.0](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.4.0-beta.2...v3.4.0) (2020-01-27) 19 | 20 | **Note:** Version bump only for package @examples/fragments 21 | 22 | # [3.4.0-beta.2](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.4.0-beta.1...v3.4.0-beta.2) (2019-08-20) 23 | 24 | **Note:** Version bump only for package @examples/fragments 25 | 26 | # [3.4.0-beta.1](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.4.0-beta.0...v3.4.0-beta.1) (2019-07-29) 27 | 28 | **Note:** Version bump only for package @examples/fragments 29 | 30 | # [3.4.0-beta.0](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.3.1...v3.4.0-beta.0) (2019-07-18) 31 | 32 | **Note:** Version bump only for package @examples/fragments 33 | 34 | ## [3.3.1](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.3.0...v3.3.1) (2019-07-18) 35 | 36 | **Note:** Version bump only for package @examples/fragments 37 | 38 | # [3.3.0](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.2.0...v3.3.0) (2019-07-09) 39 | 40 | ### Features 41 | 42 | - gatsby-image support ([f598dcd](https://github.com/gatsbyjs/gatsby-starter-default/commit/f598dcd)) 43 | 44 | # [3.2.0](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.0.0-alpha.0...v3.2.0) (2019-06-04) 45 | 46 | ### Features 47 | 48 | - fragments ([34f9c78](https://github.com/gatsbyjs/gatsby-starter-default/commit/34f9c78)) 49 | -------------------------------------------------------------------------------- /examples/fragments/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 gatsbyjs 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /examples/fragments/README.md: -------------------------------------------------------------------------------- 1 | 2 |

3 | 4 | Gatsby 5 | 6 |

7 |

8 | Gatsby's default starter 9 |

10 | 11 | Kick off your project with this default boilerplate. This starter ships with the main Gatsby configuration files you might need to get up and running blazing fast with the blazing fast app generator for React. 12 | 13 | _Have another more specific idea? You may want to check out our vibrant collection of [official and community-created starters](https://www.gatsbyjs.org/docs/gatsby-starters/)._ 14 | 15 | ## 🚀 Quick start 16 | 17 | 1. **Create a Gatsby site.** 18 | 19 | Use the Gatsby CLI to create a new site, specifying the default starter. 20 | 21 | ```sh 22 | # create a new Gatsby site using the default starter 23 | gatsby new my-default-starter https://github.com/gatsbyjs/gatsby-starter-default 24 | ``` 25 | 26 | 1. **Start developing.** 27 | 28 | Navigate into your new site’s directory and start it up. 29 | 30 | ```sh 31 | cd my-default-starter/ 32 | gatsby develop 33 | ``` 34 | 35 | 1. **Open the source code and start editing!** 36 | 37 | Your site is now running at `http://localhost:8000`! 38 | 39 | _Note: You'll also see a second link: _`http://localhost:8000/___graphql`_. This is a tool you can use to experiment with querying your data. Learn more about using this tool in the [Gatsby tutorial](https://www.gatsbyjs.org/tutorial/part-five/#introducing-graphiql)._ 40 | 41 | Open the `my-default-starter` directory in your code editor of choice and edit `src/pages/index.js`. Save your changes and the browser will update in real time! 42 | 43 | ## 🧐 What's inside? 44 | 45 | A quick look at the top-level files and directories you'll see in a Gatsby project. 46 | 47 | . 48 | ├── node_modules 49 | ├── src 50 | ├── .gitignore 51 | ├── .prettierrc 52 | ├── gatsby-browser.js 53 | ├── gatsby-config.js 54 | ├── gatsby-node.js 55 | ├── gatsby-ssr.js 56 | ├── LICENSE 57 | ├── package-lock.json 58 | ├── package.json 59 | └── README.md 60 | 61 | 1. **`/node_modules`**: This directory contains all of the modules of code that your project depends on (npm packages) are automatically installed. 62 | 63 | 2. **`/src`**: This directory will contain all of the code related to what you will see on the front-end of your site (what you see in the browser) such as your site header or a page template. `src` is a convention for “source code”. 64 | 65 | 3. **`.gitignore`**: This file tells git which files it should not track / not maintain a version history for. 66 | 67 | 4. **`.prettierrc`**: This is a configuration file for [Prettier](https://prettier.io/). Prettier is a tool to help keep the formatting of your code consistent. 68 | 69 | 5. **`gatsby-browser.js`**: This file is where Gatsby expects to find any usage of the [Gatsby browser APIs](https://www.gatsbyjs.org/docs/browser-apis/) (if any). These allow customization/extension of default Gatsby settings affecting the browser. 70 | 71 | 6. **`gatsby-config.js`**: This is the main configuration file for a Gatsby site. This is where you can specify information about your site (metadata) like the site title and description, which Gatsby plugins you’d like to include, etc. (Check out the [config docs](https://www.gatsbyjs.org/docs/gatsby-config/) for more detail). 72 | 73 | 7. **`gatsby-node.js`**: This file is where Gatsby expects to find any usage of the [Gatsby Node APIs](https://www.gatsbyjs.org/docs/node-apis/) (if any). These allow customization/extension of default Gatsby settings affecting pieces of the site build process. 74 | 75 | 8. **`gatsby-ssr.js`**: This file is where Gatsby expects to find any usage of the [Gatsby server-side rendering APIs](https://www.gatsbyjs.org/docs/ssr-apis/) (if any). These allow customization of default Gatsby settings affecting server-side rendering. 76 | 77 | 9. **`LICENSE`**: Gatsby is licensed under the MIT license. 78 | 79 | 10. **`package-lock.json`** (See `package.json` below, first). This is an automatically generated file based on the exact versions of your npm dependencies that were installed for your project. **(You won’t change this file directly).** 80 | 81 | 11. **`package.json`**: A manifest file for Node.js projects, which includes things like metadata (the project’s name, author, etc). This manifest is how npm knows which packages to install for your project. 82 | 83 | 12. **`README.md`**: A text file containing useful reference information about your project. 84 | 85 | ## 🎓 Learning Gatsby 86 | 87 | Looking for more guidance? Full documentation for Gatsby lives [on the website](https://www.gatsbyjs.org/). Here are some places to start: 88 | 89 | - **For most developers, we recommend starting with our [in-depth tutorial for creating a site with Gatsby](https://www.gatsbyjs.org/tutorial/).** It starts with zero assumptions about your level of ability and walks through every step of the process. 90 | 91 | - **To dive straight into code samples, head [to our documentation](https://www.gatsbyjs.org/docs/).** In particular, check out the _Guides_, _API Reference_, and _Advanced Tutorials_ sections in the sidebar. 92 | 93 | ## 💫 Deploy 94 | 95 | [![Deploy to Netlify](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/gatsbyjs/gatsby-starter-default) 96 | 97 | 98 | -------------------------------------------------------------------------------- /examples/fragments/gatsby-browser.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Implement Gatsby's Browser APIs in this file. 3 | * 4 | * See: https://www.gatsbyjs.org/docs/browser-apis/ 5 | */ 6 | 7 | // You can delete this file if you're not using it 8 | const { registerLinkResolver } = require('gatsby-source-prismic-graphql'); 9 | 10 | registerLinkResolver(require('./src/utils/linkResolver').linkResolver); 11 | -------------------------------------------------------------------------------- /examples/fragments/gatsby-config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | siteMetadata: { 3 | title: `Gatsby Default Starter`, 4 | description: `Kick off your next, great Gatsby project with this default starter. This barebones starter ships with the main Gatsby configuration files you might need.`, 5 | author: `@gatsbyjs`, 6 | }, 7 | plugins: [ 8 | { 9 | resolve: `gatsby-source-prismic-graphql`, 10 | options: { 11 | repositoryName: 'ueno-starter-kit-universally-test', 12 | }, 13 | }, 14 | `gatsby-plugin-react-helmet`, 15 | { 16 | resolve: `gatsby-source-filesystem`, 17 | options: { 18 | name: `images`, 19 | path: `${__dirname}/src/images`, 20 | }, 21 | }, 22 | `gatsby-transformer-sharp`, 23 | `gatsby-plugin-sharp`, 24 | { 25 | resolve: `gatsby-plugin-manifest`, 26 | options: { 27 | name: `gatsby-starter-default`, 28 | short_name: `starter`, 29 | start_url: `/`, 30 | background_color: `#663399`, 31 | theme_color: `#663399`, 32 | display: `minimal-ui`, 33 | icon: `src/images/gatsby-icon.png`, // This path is relative to the root of the site. 34 | }, 35 | }, 36 | // this (optional) plugin enables Progressive Web App + Offline functionality 37 | // To learn more, visit: https://gatsby.dev/offline 38 | // 'gatsby-plugin-offline', 39 | ], 40 | }; 41 | -------------------------------------------------------------------------------- /examples/fragments/gatsby-node.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Implement Gatsby's Node APIs in this file. 3 | * 4 | * See: https://www.gatsbyjs.org/docs/node-apis/ 5 | */ 6 | -------------------------------------------------------------------------------- /examples/fragments/gatsby-ssr.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Implement Gatsby's SSR (Server Side Rendering) APIs in this file. 3 | * 4 | * See: https://www.gatsbyjs.org/docs/ssr-apis/ 5 | */ 6 | 7 | // You can delete this file if you're not using it 8 | -------------------------------------------------------------------------------- /examples/fragments/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@examples/fragments", 3 | "private": true, 4 | "version": "3.6.2", 5 | "description": "A simple starter to get up and developing quickly with Gatsby", 6 | "author": "Kyle Mathews ", 7 | "dependencies": { 8 | "@babel/polyfill": "^7.2.5", 9 | "esm": "^3.2.18", 10 | "gatsby": "^2.13.37", 11 | "gatsby-image": "^2.0.34", 12 | "gatsby-plugin-manifest": "^2.0.24", 13 | "gatsby-plugin-offline": "^2.0.25", 14 | "gatsby-plugin-react-helmet": "^3.0.10", 15 | "gatsby-plugin-sharp": "^2.2.9", 16 | "gatsby-source-filesystem": "^2.0.27", 17 | "gatsby-source-prismic-graphql": "^3.6.2", 18 | "gatsby-transformer-sharp": "^2.2.5", 19 | "prismic-reactjs": "^0.3.2", 20 | "prop-types": "^15.7.2", 21 | "react": "^16.8.4", 22 | "react-dom": "^16.8.4", 23 | "react-helmet": "^5.2.0" 24 | }, 25 | "devDependencies": { 26 | "prettier": "^1.16.4" 27 | }, 28 | "keywords": [ 29 | "gatsby" 30 | ], 31 | "license": "MIT", 32 | "scripts": { 33 | "build": "gatsby build", 34 | "develop": "gatsby develop", 35 | "format": "prettier --write src/**/*.{js,jsx}", 36 | "start": "npm run develop", 37 | "serve": "gatsby serve", 38 | "test": "echo \"Write tests! -> https://gatsby.dev/unit-testing\"" 39 | }, 40 | "eslintIgnore": [ 41 | "*.js" 42 | ], 43 | "repository": { 44 | "type": "git", 45 | "url": "https://github.com/gatsbyjs/gatsby-starter-default" 46 | }, 47 | "bugs": { 48 | "url": "https://github.com/gatsbyjs/gatsby/issues" 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /examples/fragments/src/components/articles.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { graphql, StaticQuery } from 'gatsby'; 3 | import { withPreview } from 'gatsby-source-prismic-graphql'; 4 | import { RichText } from 'prismic-reactjs'; 5 | import { ArticleFragment } from '../fragments/ArticleFragment'; 6 | 7 | const query = graphql` 8 | query { 9 | prismic { 10 | allArticles(first: 2) { 11 | edges { 12 | node { 13 | ...ArticleFragment 14 | } 15 | } 16 | } 17 | } 18 | } 19 | `; 20 | 21 | const renderArticles = data => { 22 | return ( 23 | <> 24 |

List of articles

25 |
    26 | {data.prismic.allArticles.edges.map(({ node }) => ( 27 |
  • {RichText.render(node.title)}
  • 28 | ))} 29 |
30 | 31 | ); 32 | }; 33 | 34 | export const Articles = () => { 35 | return ( 36 | <> 37 | 38 | 39 | ); 40 | }; 41 | -------------------------------------------------------------------------------- /examples/fragments/src/components/header.js: -------------------------------------------------------------------------------- 1 | import { Link } from 'gatsby'; 2 | import PropTypes from 'prop-types'; 3 | import React from 'react'; 4 | 5 | const Header = ({ siteTitle }) => ( 6 |
12 |
19 |

20 | 27 | {siteTitle} 28 | 29 |

30 |
31 |
32 | ); 33 | 34 | Header.propTypes = { 35 | siteTitle: PropTypes.string, 36 | }; 37 | 38 | Header.defaultProps = { 39 | siteTitle: ``, 40 | }; 41 | 42 | export default Header; 43 | -------------------------------------------------------------------------------- /examples/fragments/src/components/image.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { StaticQuery, graphql } from 'gatsby'; 3 | import Img from 'gatsby-image'; 4 | 5 | /* 6 | * This component is built using `gatsby-image` to automatically serve optimized 7 | * images with lazy loading and reduced file sizes. The image is loaded using a 8 | * `StaticQuery`, which allows us to load the image from directly within this 9 | * component, rather than having to pass the image data down from pages. 10 | * 11 | * For more information, see the docs: 12 | * - `gatsby-image`: https://gatsby.dev/gatsby-image 13 | * - `StaticQuery`: https://gatsby.dev/staticquery 14 | */ 15 | 16 | const Image = () => ( 17 | } 30 | /> 31 | ); 32 | export default Image; 33 | -------------------------------------------------------------------------------- /examples/fragments/src/components/layout.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Layout component that queries for data 3 | * with Gatsby's StaticQuery component 4 | * 5 | * See: https://www.gatsbyjs.org/docs/static-query/ 6 | */ 7 | 8 | import React from 'react'; 9 | import PropTypes from 'prop-types'; 10 | import { StaticQuery, graphql } from 'gatsby'; 11 | 12 | import Header from './header'; 13 | import './layout.css'; 14 | 15 | const Layout = ({ children }) => ( 16 | ( 27 | <> 28 |
29 |
37 |
{children}
38 |
39 | © {new Date().getFullYear()}, Built with 40 | {` `} 41 | Gatsby 42 |
43 |
44 | 45 | )} 46 | /> 47 | ); 48 | 49 | Layout.propTypes = { 50 | children: PropTypes.node.isRequired, 51 | }; 52 | 53 | export default Layout; 54 | -------------------------------------------------------------------------------- /examples/fragments/src/components/seo.js: -------------------------------------------------------------------------------- 1 | /** 2 | * SEO component that queries for data with 3 | * Gatsby's useStaticQuery React hook 4 | * 5 | * See: https://www.gatsbyjs.org/docs/use-static-query/ 6 | */ 7 | 8 | import React from 'react'; 9 | import PropTypes from 'prop-types'; 10 | import Helmet from 'react-helmet'; 11 | import { useStaticQuery, graphql } from 'gatsby'; 12 | 13 | function SEO({ description, lang, meta, keywords, title }) { 14 | const { site } = useStaticQuery( 15 | graphql` 16 | query { 17 | site { 18 | siteMetadata { 19 | title 20 | description 21 | author 22 | } 23 | } 24 | } 25 | ` 26 | ); 27 | 28 | const metaDescription = description || site.siteMetadata.description; 29 | 30 | return ( 31 | 0 73 | ? { 74 | name: `keywords`, 75 | content: keywords.join(`, `), 76 | } 77 | : [] 78 | ) 79 | .concat(meta)} 80 | /> 81 | ); 82 | } 83 | 84 | SEO.defaultProps = { 85 | lang: `en`, 86 | meta: [], 87 | keywords: [], 88 | }; 89 | 90 | SEO.propTypes = { 91 | description: PropTypes.string, 92 | lang: PropTypes.string, 93 | meta: PropTypes.array, 94 | keywords: PropTypes.arrayOf(PropTypes.string), 95 | title: PropTypes.string.isRequired, 96 | }; 97 | 98 | export default SEO; 99 | -------------------------------------------------------------------------------- /examples/fragments/src/fragments/ArticleFragment.js: -------------------------------------------------------------------------------- 1 | import { graphql } from 'gatsby'; 2 | 3 | export const ArticleFragment = graphql` 4 | fragment ArticleFragment on PRISMIC_Article { 5 | _meta { 6 | uid 7 | } 8 | title 9 | } 10 | `; 11 | -------------------------------------------------------------------------------- /examples/fragments/src/images/gatsby-astronaut.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/birkir/gatsby-source-prismic-graphql/5003402d62fcfe865339785524b6be95c8f0b5eb/examples/fragments/src/images/gatsby-astronaut.png -------------------------------------------------------------------------------- /examples/fragments/src/images/gatsby-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/birkir/gatsby-source-prismic-graphql/5003402d62fcfe865339785524b6be95c8f0b5eb/examples/fragments/src/images/gatsby-icon.png -------------------------------------------------------------------------------- /examples/fragments/src/pages/404.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import Layout from '../components/layout'; 4 | import SEO from '../components/seo'; 5 | 6 | const NotFoundPage = () => ( 7 | 8 | 9 |

NOT FOUND

10 |

You just hit a route that doesn't exist... the sadness.

11 |
12 | ); 13 | 14 | export default NotFoundPage; 15 | -------------------------------------------------------------------------------- /examples/fragments/src/pages/index.js: -------------------------------------------------------------------------------- 1 | import { graphql } from 'gatsby'; 2 | import React from 'react'; 3 | import { Articles } from '../components/articles'; 4 | import Layout from '../components/layout'; 5 | import { ArticleFragment } from '../fragments/ArticleFragment'; 6 | 7 | export const query = graphql` 8 | query { 9 | prismic { 10 | allArticles(first: 3) { 11 | edges { 12 | node { 13 | ...ArticleFragment 14 | } 15 | } 16 | } 17 | } 18 | } 19 | `; 20 | 21 | export default function Home(props) { 22 | return ( 23 | 24 |
25 |

Articles count: {props.data.prismic.allArticles.edges.length}

26 | 27 |
28 |
29 | ); 30 | } 31 | 32 | Home.fragments = [ArticleFragment]; 33 | -------------------------------------------------------------------------------- /examples/fragments/src/utils/linkResolver.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | linkResolver(doc) { 3 | if (doc.type === 'article') { 4 | return `/article/${doc.uid}`; 5 | } 6 | 7 | return '/'; 8 | }, 9 | }; 10 | -------------------------------------------------------------------------------- /examples/languages/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (http://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # Typescript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # dotenv environment variables file 55 | .env 56 | 57 | # gatsby files 58 | .cache/ 59 | public 60 | 61 | # Mac files 62 | .DS_Store 63 | 64 | # Yarn 65 | yarn-error.log 66 | .pnp/ 67 | .pnp.js 68 | # Yarn Integrity file 69 | .yarn-integrity 70 | -------------------------------------------------------------------------------- /examples/languages/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## [3.6.2](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.6.1...v3.6.2) (2020-04-28) 7 | 8 | **Note:** Version bump only for package @examples/languages 9 | 10 | ## [3.6.1](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.6.0...v3.6.1) (2020-04-28) 11 | 12 | **Note:** Version bump only for package @examples/languages 13 | 14 | # [3.6.0](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.4.0...v3.6.0) (2020-04-28) 15 | 16 | **Note:** Version bump only for package @examples/languages 17 | 18 | # [3.4.0](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.4.0-beta.2...v3.4.0) (2020-01-27) 19 | 20 | **Note:** Version bump only for package @examples/languages 21 | 22 | # [3.4.0-beta.2](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.4.0-beta.1...v3.4.0-beta.2) (2019-08-20) 23 | 24 | **Note:** Version bump only for package @examples/languages 25 | 26 | # [3.4.0-beta.1](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.4.0-beta.0...v3.4.0-beta.1) (2019-07-29) 27 | 28 | **Note:** Version bump only for package @examples/languages 29 | 30 | # [3.4.0-beta.0](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.3.1...v3.4.0-beta.0) (2019-07-18) 31 | 32 | ### Bug Fixes 33 | 34 | - languages example ([84f9253](https://github.com/gatsbyjs/gatsby-starter-default/commit/84f9253)) 35 | 36 | ## [3.3.1](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.3.0...v3.3.1) (2019-07-18) 37 | 38 | **Note:** Version bump only for package @examples/languages 39 | 40 | # [3.3.0](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.2.0...v3.3.0) (2019-07-09) 41 | 42 | ### Features 43 | 44 | - gatsby-image support ([f598dcd](https://github.com/gatsbyjs/gatsby-starter-default/commit/f598dcd)) 45 | 46 | # [3.2.0](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.0.0-alpha.0...v3.2.0) (2019-06-04) 47 | 48 | ### Bug Fixes 49 | 50 | - template title ([9b35c68](https://github.com/gatsbyjs/gatsby-starter-default/commit/9b35c68)) 51 | 52 | ### Features 53 | 54 | - languages ([09a1c47](https://github.com/gatsbyjs/gatsby-starter-default/commit/09a1c47)) 55 | -------------------------------------------------------------------------------- /examples/languages/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 gatsbyjs 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /examples/languages/README.md: -------------------------------------------------------------------------------- 1 | 2 |

3 | 4 | Gatsby 5 | 6 |

7 |

8 | Gatsby's default starter 9 |

10 | 11 | Kick off your project with this default boilerplate. This starter ships with the main Gatsby configuration files you might need to get up and running blazing fast with the blazing fast app generator for React. 12 | 13 | _Have another more specific idea? You may want to check out our vibrant collection of [official and community-created starters](https://www.gatsbyjs.org/docs/gatsby-starters/)._ 14 | 15 | ## 🚀 Quick start 16 | 17 | 1. **Create a Gatsby site.** 18 | 19 | Use the Gatsby CLI to create a new site, specifying the default starter. 20 | 21 | ```sh 22 | # create a new Gatsby site using the default starter 23 | gatsby new my-default-starter https://github.com/gatsbyjs/gatsby-starter-default 24 | ``` 25 | 26 | 1. **Start developing.** 27 | 28 | Navigate into your new site’s directory and start it up. 29 | 30 | ```sh 31 | cd my-default-starter/ 32 | gatsby develop 33 | ``` 34 | 35 | 1. **Open the source code and start editing!** 36 | 37 | Your site is now running at `http://localhost:8000`! 38 | 39 | _Note: You'll also see a second link: _`http://localhost:8000/___graphql`_. This is a tool you can use to experiment with querying your data. Learn more about using this tool in the [Gatsby tutorial](https://www.gatsbyjs.org/tutorial/part-five/#introducing-graphiql)._ 40 | 41 | Open the `my-default-starter` directory in your code editor of choice and edit `src/pages/index.js`. Save your changes and the browser will update in real time! 42 | 43 | ## 🧐 What's inside? 44 | 45 | A quick look at the top-level files and directories you'll see in a Gatsby project. 46 | 47 | . 48 | ├── node_modules 49 | ├── src 50 | ├── .gitignore 51 | ├── .prettierrc 52 | ├── gatsby-browser.js 53 | ├── gatsby-config.js 54 | ├── gatsby-node.js 55 | ├── gatsby-ssr.js 56 | ├── LICENSE 57 | ├── package-lock.json 58 | ├── package.json 59 | └── README.md 60 | 61 | 1. **`/node_modules`**: This directory contains all of the modules of code that your project depends on (npm packages) are automatically installed. 62 | 63 | 2. **`/src`**: This directory will contain all of the code related to what you will see on the front-end of your site (what you see in the browser) such as your site header or a page template. `src` is a convention for “source code”. 64 | 65 | 3. **`.gitignore`**: This file tells git which files it should not track / not maintain a version history for. 66 | 67 | 4. **`.prettierrc`**: This is a configuration file for [Prettier](https://prettier.io/). Prettier is a tool to help keep the formatting of your code consistent. 68 | 69 | 5. **`gatsby-browser.js`**: This file is where Gatsby expects to find any usage of the [Gatsby browser APIs](https://www.gatsbyjs.org/docs/browser-apis/) (if any). These allow customization/extension of default Gatsby settings affecting the browser. 70 | 71 | 6. **`gatsby-config.js`**: This is the main configuration file for a Gatsby site. This is where you can specify information about your site (metadata) like the site title and description, which Gatsby plugins you’d like to include, etc. (Check out the [config docs](https://www.gatsbyjs.org/docs/gatsby-config/) for more detail). 72 | 73 | 7. **`gatsby-node.js`**: This file is where Gatsby expects to find any usage of the [Gatsby Node APIs](https://www.gatsbyjs.org/docs/node-apis/) (if any). These allow customization/extension of default Gatsby settings affecting pieces of the site build process. 74 | 75 | 8. **`gatsby-ssr.js`**: This file is where Gatsby expects to find any usage of the [Gatsby server-side rendering APIs](https://www.gatsbyjs.org/docs/ssr-apis/) (if any). These allow customization of default Gatsby settings affecting server-side rendering. 76 | 77 | 9. **`LICENSE`**: Gatsby is licensed under the MIT license. 78 | 79 | 10. **`package-lock.json`** (See `package.json` below, first). This is an automatically generated file based on the exact versions of your npm dependencies that were installed for your project. **(You won’t change this file directly).** 80 | 81 | 11. **`package.json`**: A manifest file for Node.js projects, which includes things like metadata (the project’s name, author, etc). This manifest is how npm knows which packages to install for your project. 82 | 83 | 12. **`README.md`**: A text file containing useful reference information about your project. 84 | 85 | ## 🎓 Learning Gatsby 86 | 87 | Looking for more guidance? Full documentation for Gatsby lives [on the website](https://www.gatsbyjs.org/). Here are some places to start: 88 | 89 | - **For most developers, we recommend starting with our [in-depth tutorial for creating a site with Gatsby](https://www.gatsbyjs.org/tutorial/).** It starts with zero assumptions about your level of ability and walks through every step of the process. 90 | 91 | - **To dive straight into code samples, head [to our documentation](https://www.gatsbyjs.org/docs/).** In particular, check out the _Guides_, _API Reference_, and _Advanced Tutorials_ sections in the sidebar. 92 | 93 | ## 💫 Deploy 94 | 95 | [![Deploy to Netlify](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/gatsbyjs/gatsby-starter-default) 96 | 97 | 98 | -------------------------------------------------------------------------------- /examples/languages/gatsby-browser.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Implement Gatsby's Browser APIs in this file. 3 | * 4 | * See: https://www.gatsbyjs.org/docs/browser-apis/ 5 | */ 6 | 7 | // You can delete this file if you're not using it 8 | const { registerLinkResolver } = require('gatsby-source-prismic-graphql'); 9 | 10 | registerLinkResolver(require('./src/utils/linkResolver').linkResolver); 11 | -------------------------------------------------------------------------------- /examples/languages/gatsby-config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | siteMetadata: { 3 | title: `Gatsby Default Starter`, 4 | description: `Kick off your next, great Gatsby project with this default starter. This barebones starter ships with the main Gatsby configuration files you might need.`, 5 | author: `@gatsbyjs`, 6 | }, 7 | plugins: [ 8 | { 9 | resolve: `gatsby-source-prismic-graphql`, 10 | options: { 11 | repositoryName: 'ueno-starter-kit-universally-test', 12 | defaultLang: 'en-us', 13 | langs: ['en-us', 'is'], 14 | pages: [ 15 | { 16 | type: 'Homepage', 17 | match: '/:lang?/', 18 | path: '/home', 19 | component: require.resolve('./src/templates/home.js'), 20 | }, 21 | { 22 | type: 'Article', 23 | match: '/:lang?/article/:uid', 24 | path: '/article', 25 | component: require.resolve('./src/templates/article.js'), 26 | }, 27 | ], 28 | }, 29 | }, 30 | `gatsby-plugin-react-helmet`, 31 | { 32 | resolve: `gatsby-source-filesystem`, 33 | options: { 34 | name: `images`, 35 | path: `${__dirname}/src/images`, 36 | }, 37 | }, 38 | `gatsby-transformer-sharp`, 39 | `gatsby-plugin-sharp`, 40 | { 41 | resolve: `gatsby-plugin-manifest`, 42 | options: { 43 | name: `gatsby-starter-default`, 44 | short_name: `starter`, 45 | start_url: `/`, 46 | background_color: `#663399`, 47 | theme_color: `#663399`, 48 | display: `minimal-ui`, 49 | icon: `src/images/gatsby-icon.png`, // This path is relative to the root of the site. 50 | }, 51 | }, 52 | // this (optional) plugin enables Progressive Web App + Offline functionality 53 | // To learn more, visit: https://gatsby.dev/offline 54 | // 'gatsby-plugin-offline', 55 | ], 56 | }; 57 | -------------------------------------------------------------------------------- /examples/languages/gatsby-node.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Implement Gatsby's Node APIs in this file. 3 | * 4 | * See: https://www.gatsbyjs.org/docs/node-apis/ 5 | */ 6 | -------------------------------------------------------------------------------- /examples/languages/gatsby-ssr.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Implement Gatsby's SSR (Server Side Rendering) APIs in this file. 3 | * 4 | * See: https://www.gatsbyjs.org/docs/ssr-apis/ 5 | */ 6 | 7 | // You can delete this file if you're not using it 8 | -------------------------------------------------------------------------------- /examples/languages/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@examples/languages", 3 | "private": true, 4 | "version": "3.6.2", 5 | "description": "A simple starter to get up and developing quickly with Gatsby", 6 | "author": "Kyle Mathews ", 7 | "dependencies": { 8 | "@babel/polyfill": "^7.2.5", 9 | "esm": "^3.2.18", 10 | "gatsby": "^2.13.37", 11 | "gatsby-image": "^2.0.34", 12 | "gatsby-plugin-manifest": "^2.0.24", 13 | "gatsby-plugin-offline": "^2.0.25", 14 | "gatsby-plugin-react-helmet": "^3.0.10", 15 | "gatsby-plugin-sharp": "^2.2.9", 16 | "gatsby-source-filesystem": "^2.0.27", 17 | "gatsby-source-prismic-graphql": "^3.6.2", 18 | "gatsby-transformer-sharp": "^2.2.5", 19 | "prismic-reactjs": "^0.3.2", 20 | "prop-types": "^15.7.2", 21 | "react": "^16.8.4", 22 | "react-dom": "^16.8.4", 23 | "react-helmet": "^5.2.0" 24 | }, 25 | "devDependencies": { 26 | "prettier": "^1.16.4" 27 | }, 28 | "keywords": [ 29 | "gatsby" 30 | ], 31 | "license": "MIT", 32 | "scripts": { 33 | "build": "gatsby build", 34 | "develop": "gatsby develop", 35 | "format": "prettier --write src/**/*.{js,jsx}", 36 | "start": "npm run develop", 37 | "serve": "gatsby serve", 38 | "test": "echo \"Write tests! -> https://gatsby.dev/unit-testing\"" 39 | }, 40 | "eslintIgnore": [ 41 | "*.js" 42 | ], 43 | "repository": { 44 | "type": "git", 45 | "url": "https://github.com/gatsbyjs/gatsby-starter-default" 46 | }, 47 | "bugs": { 48 | "url": "https://github.com/gatsbyjs/gatsby/issues" 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /examples/languages/src/components/header.js: -------------------------------------------------------------------------------- 1 | import { Link } from 'gatsby'; 2 | import PropTypes from 'prop-types'; 3 | import React from 'react'; 4 | 5 | const Header = ({ siteTitle }) => ( 6 |
12 |
19 |

20 | 27 | {siteTitle} 28 | 29 |

30 |
31 |
32 | ); 33 | 34 | Header.propTypes = { 35 | siteTitle: PropTypes.string, 36 | }; 37 | 38 | Header.defaultProps = { 39 | siteTitle: ``, 40 | }; 41 | 42 | export default Header; 43 | -------------------------------------------------------------------------------- /examples/languages/src/components/image.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { StaticQuery, graphql } from 'gatsby'; 3 | import Img from 'gatsby-image'; 4 | 5 | /* 6 | * This component is built using `gatsby-image` to automatically serve optimized 7 | * images with lazy loading and reduced file sizes. The image is loaded using a 8 | * `StaticQuery`, which allows us to load the image from directly within this 9 | * component, rather than having to pass the image data down from pages. 10 | * 11 | * For more information, see the docs: 12 | * - `gatsby-image`: https://gatsby.dev/gatsby-image 13 | * - `StaticQuery`: https://gatsby.dev/staticquery 14 | */ 15 | 16 | const Image = () => ( 17 | } 30 | /> 31 | ); 32 | export default Image; 33 | -------------------------------------------------------------------------------- /examples/languages/src/components/layout.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Layout component that queries for data 3 | * with Gatsby's StaticQuery component 4 | * 5 | * See: https://www.gatsbyjs.org/docs/static-query/ 6 | */ 7 | 8 | import React from 'react'; 9 | import PropTypes from 'prop-types'; 10 | import { StaticQuery, graphql } from 'gatsby'; 11 | 12 | import Header from './header'; 13 | import './layout.css'; 14 | 15 | const Layout = ({ children }) => ( 16 | ( 27 | <> 28 |
29 |
37 |
{children}
38 |
39 | © {new Date().getFullYear()}, Built with 40 | {` `} 41 | Gatsby 42 |
43 |
44 | 45 | )} 46 | /> 47 | ); 48 | 49 | Layout.propTypes = { 50 | children: PropTypes.node.isRequired, 51 | }; 52 | 53 | export default Layout; 54 | -------------------------------------------------------------------------------- /examples/languages/src/components/seo.js: -------------------------------------------------------------------------------- 1 | /** 2 | * SEO component that queries for data with 3 | * Gatsby's useStaticQuery React hook 4 | * 5 | * See: https://www.gatsbyjs.org/docs/use-static-query/ 6 | */ 7 | 8 | import React from 'react'; 9 | import PropTypes from 'prop-types'; 10 | import Helmet from 'react-helmet'; 11 | import { useStaticQuery, graphql } from 'gatsby'; 12 | 13 | function SEO({ description, lang, meta, keywords, title }) { 14 | const { site } = useStaticQuery( 15 | graphql` 16 | query { 17 | site { 18 | siteMetadata { 19 | title 20 | description 21 | author 22 | } 23 | } 24 | } 25 | ` 26 | ); 27 | 28 | const metaDescription = description || site.siteMetadata.description; 29 | 30 | return ( 31 | 0 73 | ? { 74 | name: `keywords`, 75 | content: keywords.join(`, `), 76 | } 77 | : [] 78 | ) 79 | .concat(meta)} 80 | /> 81 | ); 82 | } 83 | 84 | SEO.defaultProps = { 85 | lang: `en`, 86 | meta: [], 87 | keywords: [], 88 | }; 89 | 90 | SEO.propTypes = { 91 | description: PropTypes.string, 92 | lang: PropTypes.string, 93 | meta: PropTypes.array, 94 | keywords: PropTypes.arrayOf(PropTypes.string), 95 | title: PropTypes.string.isRequired, 96 | }; 97 | 98 | export default SEO; 99 | -------------------------------------------------------------------------------- /examples/languages/src/images/gatsby-astronaut.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/birkir/gatsby-source-prismic-graphql/5003402d62fcfe865339785524b6be95c8f0b5eb/examples/languages/src/images/gatsby-astronaut.png -------------------------------------------------------------------------------- /examples/languages/src/images/gatsby-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/birkir/gatsby-source-prismic-graphql/5003402d62fcfe865339785524b6be95c8f0b5eb/examples/languages/src/images/gatsby-icon.png -------------------------------------------------------------------------------- /examples/languages/src/pages/404.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import Layout from '../components/layout'; 4 | import SEO from '../components/seo'; 5 | 6 | const NotFoundPage = () => ( 7 | 8 | 9 |

NOT FOUND

10 |

You just hit a route that doesn't exist... the sadness.

11 |
12 | ); 13 | 14 | export default NotFoundPage; 15 | -------------------------------------------------------------------------------- /examples/languages/src/templates/article.js: -------------------------------------------------------------------------------- 1 | import { graphql, Link } from 'gatsby'; 2 | import { linkResolver } from 'gatsby-source-prismic-graphql'; 3 | import { RichText } from 'prismic-reactjs'; 4 | import React from 'react'; 5 | import Layout from '../components/layout'; 6 | 7 | export const query = graphql` 8 | query ArticleQuery($uid: String) { 9 | prismic { 10 | allArticles(uid: $uid) { 11 | edges { 12 | node { 13 | _meta { 14 | uid 15 | } 16 | } 17 | } 18 | } 19 | } 20 | } 21 | `; 22 | 23 | export default function Article(props) { 24 | return ( 25 | 26 |

Article

27 | Back to index 28 |
29 | ); 30 | } 31 | -------------------------------------------------------------------------------- /examples/languages/src/templates/home.js: -------------------------------------------------------------------------------- 1 | import { Link, graphql } from 'gatsby'; 2 | import React from 'react'; 3 | import Layout from '../components/layout'; 4 | import get from 'lodash/get'; 5 | import { RichText } from 'prismic-reactjs'; 6 | 7 | export const query = graphql` 8 | query Homepage($id: String) { 9 | prismic { 10 | allHomepages(id: $id) { 11 | edges { 12 | node { 13 | _meta { 14 | id 15 | lang 16 | } 17 | column_title 18 | } 19 | } 20 | } 21 | } 22 | } 23 | `; 24 | 25 | export default function Home(props) { 26 | const title = get(props.data, 'prismic.allHomepages.edges.0.node.column_title', []); 27 | const lang = get(props.pageContext, 'alternateLanguages.0.lang', '').replace('en-us', ''); 28 | 29 | return ( 30 | 31 | {RichText.render(title)} 32 | Click here for alternative language 33 | 34 | ); 35 | } 36 | -------------------------------------------------------------------------------- /examples/languages/src/utils/linkResolver.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | linkResolver(doc) { 3 | if (doc.type === 'article') { 4 | return `/article/${doc.uid}`; 5 | } 6 | 7 | return '/'; 8 | }, 9 | }; 10 | -------------------------------------------------------------------------------- /examples/pagination/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (http://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # Typescript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # dotenv environment variables file 55 | .env 56 | 57 | # gatsby files 58 | .cache/ 59 | public 60 | 61 | # Mac files 62 | .DS_Store 63 | 64 | # Yarn 65 | yarn-error.log 66 | .pnp/ 67 | .pnp.js 68 | # Yarn Integrity file 69 | .yarn-integrity 70 | -------------------------------------------------------------------------------- /examples/pagination/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## [3.6.2](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.6.1...v3.6.2) (2020-04-28) 7 | 8 | **Note:** Version bump only for package @examples/pagination 9 | 10 | ## [3.6.1](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.6.0...v3.6.1) (2020-04-28) 11 | 12 | **Note:** Version bump only for package @examples/pagination 13 | 14 | # [3.6.0](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.4.0...v3.6.0) (2020-04-28) 15 | 16 | **Note:** Version bump only for package @examples/pagination 17 | 18 | # [3.4.0](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.4.0-beta.2...v3.4.0) (2020-01-27) 19 | 20 | **Note:** Version bump only for package @examples/pagination 21 | 22 | # [3.4.0-beta.2](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.4.0-beta.1...v3.4.0-beta.2) (2019-08-20) 23 | 24 | **Note:** Version bump only for package @examples/pagination 25 | 26 | # [3.4.0-beta.1](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.4.0-beta.0...v3.4.0-beta.1) (2019-07-29) 27 | 28 | **Note:** Version bump only for package @examples/pagination 29 | 30 | # [3.4.0-beta.0](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.3.1...v3.4.0-beta.0) (2019-07-18) 31 | 32 | ### Bug Fixes 33 | 34 | - logic problems with dynamic pagination already in example ([eb0fa26](https://github.com/gatsbyjs/gatsby-starter-default/commit/eb0fa26)) 35 | 36 | ### Features 37 | 38 | - create and expose cursor encoding helpers ([a1959ac](https://github.com/gatsbyjs/gatsby-starter-default/commit/a1959ac)) 39 | 40 | ## [3.3.1](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.3.0...v3.3.1) (2019-07-18) 41 | 42 | **Note:** Version bump only for package @examples/pagination 43 | 44 | # [3.3.0](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.2.0...v3.3.0) (2019-07-09) 45 | 46 | ### Features 47 | 48 | - gatsby-image support ([f598dcd](https://github.com/gatsbyjs/gatsby-starter-default/commit/f598dcd)) 49 | 50 | # [3.2.0](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.0.0-alpha.0...v3.2.0) (2019-06-04) 51 | 52 | **Note:** Version bump only for package @examples/pagination 53 | -------------------------------------------------------------------------------- /examples/pagination/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 gatsbyjs 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /examples/pagination/README.md: -------------------------------------------------------------------------------- 1 | 2 |

3 | 4 | Gatsby 5 | 6 |

7 |

8 | Gatsby's default starter 9 |

10 | 11 | Kick off your project with this default boilerplate. This starter ships with the main Gatsby configuration files you might need to get up and running blazing fast with the blazing fast app generator for React. 12 | 13 | _Have another more specific idea? You may want to check out our vibrant collection of [official and community-created starters](https://www.gatsbyjs.org/docs/gatsby-starters/)._ 14 | 15 | ## 🚀 Quick start 16 | 17 | 1. **Create a Gatsby site.** 18 | 19 | Use the Gatsby CLI to create a new site, specifying the default starter. 20 | 21 | ```sh 22 | # create a new Gatsby site using the default starter 23 | gatsby new my-default-starter https://github.com/gatsbyjs/gatsby-starter-default 24 | ``` 25 | 26 | 1. **Start developing.** 27 | 28 | Navigate into your new site’s directory and start it up. 29 | 30 | ```sh 31 | cd my-default-starter/ 32 | gatsby develop 33 | ``` 34 | 35 | 1. **Open the source code and start editing!** 36 | 37 | Your site is now running at `http://localhost:8000`! 38 | 39 | _Note: You'll also see a second link: _`http://localhost:8000/___graphql`_. This is a tool you can use to experiment with querying your data. Learn more about using this tool in the [Gatsby tutorial](https://www.gatsbyjs.org/tutorial/part-five/#introducing-graphiql)._ 40 | 41 | Open the `my-default-starter` directory in your code editor of choice and edit `src/pages/index.js`. Save your changes and the browser will update in real time! 42 | 43 | ## 🧐 What's inside? 44 | 45 | A quick look at the top-level files and directories you'll see in a Gatsby project. 46 | 47 | . 48 | ├── node_modules 49 | ├── src 50 | ├── .gitignore 51 | ├── .prettierrc 52 | ├── gatsby-browser.js 53 | ├── gatsby-config.js 54 | ├── gatsby-node.js 55 | ├── gatsby-ssr.js 56 | ├── LICENSE 57 | ├── package-lock.json 58 | ├── package.json 59 | └── README.md 60 | 61 | 1. **`/node_modules`**: This directory contains all of the modules of code that your project depends on (npm packages) are automatically installed. 62 | 63 | 2. **`/src`**: This directory will contain all of the code related to what you will see on the front-end of your site (what you see in the browser) such as your site header or a page template. `src` is a convention for “source code”. 64 | 65 | 3. **`.gitignore`**: This file tells git which files it should not track / not maintain a version history for. 66 | 67 | 4. **`.prettierrc`**: This is a configuration file for [Prettier](https://prettier.io/). Prettier is a tool to help keep the formatting of your code consistent. 68 | 69 | 5. **`gatsby-browser.js`**: This file is where Gatsby expects to find any usage of the [Gatsby browser APIs](https://www.gatsbyjs.org/docs/browser-apis/) (if any). These allow customization/extension of default Gatsby settings affecting the browser. 70 | 71 | 6. **`gatsby-config.js`**: This is the main configuration file for a Gatsby site. This is where you can specify information about your site (metadata) like the site title and description, which Gatsby plugins you’d like to include, etc. (Check out the [config docs](https://www.gatsbyjs.org/docs/gatsby-config/) for more detail). 72 | 73 | 7. **`gatsby-node.js`**: This file is where Gatsby expects to find any usage of the [Gatsby Node APIs](https://www.gatsbyjs.org/docs/node-apis/) (if any). These allow customization/extension of default Gatsby settings affecting pieces of the site build process. 74 | 75 | 8. **`gatsby-ssr.js`**: This file is where Gatsby expects to find any usage of the [Gatsby server-side rendering APIs](https://www.gatsbyjs.org/docs/ssr-apis/) (if any). These allow customization of default Gatsby settings affecting server-side rendering. 76 | 77 | 9. **`LICENSE`**: Gatsby is licensed under the MIT license. 78 | 79 | 10. **`package-lock.json`** (See `package.json` below, first). This is an automatically generated file based on the exact versions of your npm dependencies that were installed for your project. **(You won’t change this file directly).** 80 | 81 | 11. **`package.json`**: A manifest file for Node.js projects, which includes things like metadata (the project’s name, author, etc). This manifest is how npm knows which packages to install for your project. 82 | 83 | 12. **`README.md`**: A text file containing useful reference information about your project. 84 | 85 | ## 🎓 Learning Gatsby 86 | 87 | Looking for more guidance? Full documentation for Gatsby lives [on the website](https://www.gatsbyjs.org/). Here are some places to start: 88 | 89 | - **For most developers, we recommend starting with our [in-depth tutorial for creating a site with Gatsby](https://www.gatsbyjs.org/tutorial/).** It starts with zero assumptions about your level of ability and walks through every step of the process. 90 | 91 | - **To dive straight into code samples, head [to our documentation](https://www.gatsbyjs.org/docs/).** In particular, check out the _Guides_, _API Reference_, and _Advanced Tutorials_ sections in the sidebar. 92 | 93 | ## 💫 Deploy 94 | 95 | [![Deploy to Netlify](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/gatsbyjs/gatsby-starter-default) 96 | 97 | 98 | -------------------------------------------------------------------------------- /examples/pagination/gatsby-browser.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Implement Gatsby's Browser APIs in this file. 3 | * 4 | * See: https://www.gatsbyjs.org/docs/browser-apis/ 5 | */ 6 | 7 | // You can delete this file if you're not using it 8 | const { registerLinkResolver } = require('gatsby-source-prismic-graphql'); 9 | 10 | registerLinkResolver(require('./src/utils/linkResolver').linkResolver); 11 | -------------------------------------------------------------------------------- /examples/pagination/gatsby-config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | siteMetadata: { 3 | title: `Gatsby Default Starter`, 4 | description: `Kick off your next, great Gatsby project with this default starter. This barebones starter ships with the main Gatsby configuration files you might need.`, 5 | author: `@gatsbyjs`, 6 | }, 7 | plugins: [ 8 | { 9 | resolve: `gatsby-source-prismic-graphql`, 10 | options: { 11 | repositoryName: 'ueno-starter-kit-universally-test', 12 | pages: [ 13 | { 14 | type: 'Article', 15 | match: '/article/:uid', 16 | path: '/article', 17 | component: require.resolve('./src/templates/article.js'), 18 | }, 19 | ], 20 | }, 21 | }, 22 | `gatsby-plugin-react-helmet`, 23 | { 24 | resolve: `gatsby-source-filesystem`, 25 | options: { 26 | name: `images`, 27 | path: `${__dirname}/src/images`, 28 | }, 29 | }, 30 | `gatsby-transformer-sharp`, 31 | `gatsby-plugin-sharp`, 32 | { 33 | resolve: `gatsby-plugin-manifest`, 34 | options: { 35 | name: `gatsby-starter-default`, 36 | short_name: `starter`, 37 | start_url: `/`, 38 | background_color: `#663399`, 39 | theme_color: `#663399`, 40 | display: `minimal-ui`, 41 | icon: `src/images/gatsby-icon.png`, // This path is relative to the root of the site. 42 | }, 43 | }, 44 | // this (optional) plugin enables Progressive Web App + Offline functionality 45 | // To learn more, visit: https://gatsby.dev/offline 46 | // 'gatsby-plugin-offline', 47 | ], 48 | }; 49 | -------------------------------------------------------------------------------- /examples/pagination/gatsby-node.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Implement Gatsby's Node APIs in this file. 3 | * 4 | * See: https://www.gatsbyjs.org/docs/node-apis/ 5 | */ 6 | -------------------------------------------------------------------------------- /examples/pagination/gatsby-ssr.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Implement Gatsby's SSR (Server Side Rendering) APIs in this file. 3 | * 4 | * See: https://www.gatsbyjs.org/docs/ssr-apis/ 5 | */ 6 | 7 | // You can delete this file if you're not using it 8 | -------------------------------------------------------------------------------- /examples/pagination/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@examples/pagination", 3 | "private": true, 4 | "version": "3.6.2", 5 | "description": "A simple starter to get up and developing quickly with Gatsby", 6 | "author": "Kyle Mathews ", 7 | "dependencies": { 8 | "@babel/polyfill": "^7.2.5", 9 | "esm": "^3.2.18", 10 | "gatsby": "^2.13.37", 11 | "gatsby-image": "^2.0.34", 12 | "gatsby-plugin-manifest": "^2.0.24", 13 | "gatsby-plugin-offline": "^2.0.25", 14 | "gatsby-plugin-react-helmet": "^3.0.10", 15 | "gatsby-plugin-sharp": "^2.2.9", 16 | "gatsby-source-filesystem": "^2.0.27", 17 | "gatsby-source-prismic-graphql": "^3.6.2", 18 | "gatsby-transformer-sharp": "^2.2.5", 19 | "prismic-reactjs": "^0.3.2", 20 | "prop-types": "^15.7.2", 21 | "react": "^16.8.4", 22 | "react-dom": "^16.8.4", 23 | "react-helmet": "^5.2.0" 24 | }, 25 | "devDependencies": { 26 | "prettier": "^1.16.4" 27 | }, 28 | "keywords": [ 29 | "gatsby" 30 | ], 31 | "license": "MIT", 32 | "scripts": { 33 | "build": "gatsby build", 34 | "develop": "gatsby develop", 35 | "format": "prettier --write src/**/*.{js,jsx}", 36 | "start": "npm run develop", 37 | "serve": "gatsby serve", 38 | "test": "echo \"Write tests! -> https://gatsby.dev/unit-testing\"" 39 | }, 40 | "eslintIgnore": [ 41 | "*.js" 42 | ], 43 | "repository": { 44 | "type": "git", 45 | "url": "https://github.com/gatsbyjs/gatsby-starter-default" 46 | }, 47 | "bugs": { 48 | "url": "https://github.com/gatsbyjs/gatsby/issues" 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /examples/pagination/src/components/header.js: -------------------------------------------------------------------------------- 1 | import { Link } from 'gatsby'; 2 | import PropTypes from 'prop-types'; 3 | import React from 'react'; 4 | 5 | const Header = ({ siteTitle }) => ( 6 |
12 |
19 |

20 | 27 | {siteTitle} 28 | 29 |

30 |
31 |
32 | ); 33 | 34 | Header.propTypes = { 35 | siteTitle: PropTypes.string, 36 | }; 37 | 38 | Header.defaultProps = { 39 | siteTitle: ``, 40 | }; 41 | 42 | export default Header; 43 | -------------------------------------------------------------------------------- /examples/pagination/src/components/image.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { StaticQuery, graphql } from 'gatsby'; 3 | import Img from 'gatsby-image'; 4 | 5 | /* 6 | * This component is built using `gatsby-image` to automatically serve optimized 7 | * images with lazy loading and reduced file sizes. The image is loaded using a 8 | * `StaticQuery`, which allows us to load the image from directly within this 9 | * component, rather than having to pass the image data down from pages. 10 | * 11 | * For more information, see the docs: 12 | * - `gatsby-image`: https://gatsby.dev/gatsby-image 13 | * - `StaticQuery`: https://gatsby.dev/staticquery 14 | */ 15 | 16 | const Image = () => ( 17 | } 30 | /> 31 | ); 32 | export default Image; 33 | -------------------------------------------------------------------------------- /examples/pagination/src/components/layout.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Layout component that queries for data 3 | * with Gatsby's StaticQuery component 4 | * 5 | * See: https://www.gatsbyjs.org/docs/static-query/ 6 | */ 7 | 8 | import React from 'react'; 9 | import PropTypes from 'prop-types'; 10 | import { StaticQuery, graphql } from 'gatsby'; 11 | 12 | import Header from './header'; 13 | import './layout.css'; 14 | 15 | const Layout = ({ children }) => ( 16 | ( 27 | <> 28 |
29 |
37 |
{children}
38 |
39 | © {new Date().getFullYear()}, Built with 40 | {` `} 41 | Gatsby 42 |
43 |
44 | 45 | )} 46 | /> 47 | ); 48 | 49 | Layout.propTypes = { 50 | children: PropTypes.node.isRequired, 51 | }; 52 | 53 | export default Layout; 54 | -------------------------------------------------------------------------------- /examples/pagination/src/components/seo.js: -------------------------------------------------------------------------------- 1 | /** 2 | * SEO component that queries for data with 3 | * Gatsby's useStaticQuery React hook 4 | * 5 | * See: https://www.gatsbyjs.org/docs/use-static-query/ 6 | */ 7 | 8 | import React from 'react'; 9 | import PropTypes from 'prop-types'; 10 | import Helmet from 'react-helmet'; 11 | import { useStaticQuery, graphql } from 'gatsby'; 12 | 13 | function SEO({ description, lang, meta, keywords, title }) { 14 | const { site } = useStaticQuery( 15 | graphql` 16 | query { 17 | site { 18 | siteMetadata { 19 | title 20 | description 21 | author 22 | } 23 | } 24 | } 25 | ` 26 | ); 27 | 28 | const metaDescription = description || site.siteMetadata.description; 29 | 30 | return ( 31 | 0 73 | ? { 74 | name: `keywords`, 75 | content: keywords.join(`, `), 76 | } 77 | : [] 78 | ) 79 | .concat(meta)} 80 | /> 81 | ); 82 | } 83 | 84 | SEO.defaultProps = { 85 | lang: `en`, 86 | meta: [], 87 | keywords: [], 88 | }; 89 | 90 | SEO.propTypes = { 91 | description: PropTypes.string, 92 | lang: PropTypes.string, 93 | meta: PropTypes.array, 94 | keywords: PropTypes.arrayOf(PropTypes.string), 95 | title: PropTypes.string.isRequired, 96 | }; 97 | 98 | export default SEO; 99 | -------------------------------------------------------------------------------- /examples/pagination/src/images/gatsby-astronaut.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/birkir/gatsby-source-prismic-graphql/5003402d62fcfe865339785524b6be95c8f0b5eb/examples/pagination/src/images/gatsby-astronaut.png -------------------------------------------------------------------------------- /examples/pagination/src/images/gatsby-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/birkir/gatsby-source-prismic-graphql/5003402d62fcfe865339785524b6be95c8f0b5eb/examples/pagination/src/images/gatsby-icon.png -------------------------------------------------------------------------------- /examples/pagination/src/pages/404.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import Layout from '../components/layout'; 4 | import SEO from '../components/seo'; 5 | 6 | const NotFoundPage = () => ( 7 | 8 | 9 |

NOT FOUND

10 |

You just hit a route that doesn't exist... the sadness.

11 |
12 | ); 13 | 14 | export default NotFoundPage; 15 | -------------------------------------------------------------------------------- /examples/pagination/src/pages/index.js: -------------------------------------------------------------------------------- 1 | import { graphql, Link } from 'gatsby'; 2 | import get from 'lodash/get'; 3 | import React, { useEffect, useRef } from 'react'; 4 | import { getCursorFromDocumentIndex } from 'gatsby-source-prismic-graphql'; 5 | import Layout from '../components/layout'; 6 | 7 | export const query = graphql` 8 | query ArticleList($first: Int = 2, $last: Int, $after: String, $before: String) { 9 | prismic { 10 | allArticles(first: $first, last: $last, after: $after, before: $before) { 11 | pageInfo { 12 | hasNextPage 13 | hasPreviousPage 14 | startCursor 15 | endCursor 16 | } 17 | edges { 18 | node { 19 | _meta { 20 | uid 21 | } 22 | title 23 | } 24 | } 25 | } 26 | } 27 | } 28 | `; 29 | 30 | const Home = props => { 31 | const limit = 2; 32 | const didMountRef = useRef(false); 33 | const [page, setPage] = React.useState(-1); 34 | const [data, setData] = React.useState(props.data.prismic); 35 | 36 | if (!data) { 37 | return
no data
; 38 | } 39 | 40 | const onPreviousClick = () => setPage(page - limit); 41 | const onNextClick = () => setPage(page + limit); 42 | 43 | useEffect(() => { 44 | if (!didMountRef.current) { 45 | didMountRef.current = true; 46 | return; 47 | } 48 | 49 | props.prismic 50 | .load({ variables: { after: getCursorFromDocumentIndex(page) } }) 51 | .then(res => setData(res.data)); 52 | }, [page]); 53 | 54 | return ( 55 | 56 |

List of Articles

57 |
58 |

Dynamic Pagination

59 |

60 | This example demonstrates dynamically-generated pagination. When the Next or Previous Page 61 | buttons are clicked, the page query is called again to fetch metadata about the next or 62 | previous pages. Notice here that pagination does not cause a URL route change. 63 |

64 |
    65 | {data.allArticles.edges.map(({ node }) => ( 66 |
  • 67 | {get(node, 'title.0.text', '---')} 68 |
  • 69 | ))} 70 |
71 | 74 | 77 |
78 |
79 | ); 80 | }; 81 | 82 | export default Home; 83 | -------------------------------------------------------------------------------- /examples/pagination/src/templates/article.js: -------------------------------------------------------------------------------- 1 | import { graphql, Link } from 'gatsby'; 2 | import { linkResolver } from 'gatsby-source-prismic-graphql'; 3 | import get from 'lodash/get'; 4 | import { RichText } from 'prismic-reactjs'; 5 | import React from 'react'; 6 | import Layout from '../components/layout'; 7 | 8 | export const query = graphql` 9 | query ArticleQuery( 10 | $uid: String 11 | $paginationPreviousUid: String! 12 | $paginationPreviousLang: String! 13 | $paginationNextUid: String! 14 | $paginationNextLang: String! 15 | ) { 16 | prismic { 17 | allArticles(uid: $uid) { 18 | edges { 19 | node { 20 | _meta { 21 | uid 22 | } 23 | title 24 | body { 25 | ... on PRISMIC_ArticleBodyText { 26 | primary { 27 | text 28 | } 29 | } 30 | } 31 | } 32 | } 33 | } 34 | prevArticle: article(uid: $paginationPreviousUid, lang: $paginationPreviousLang) { 35 | title 36 | _meta { 37 | uid 38 | lang 39 | type 40 | } 41 | } 42 | nextArticle: article(uid: $paginationNextUid, lang: $paginationNextLang) { 43 | title 44 | _meta { 45 | uid 46 | lang 47 | type 48 | } 49 | } 50 | } 51 | } 52 | `; 53 | 54 | const Pagination = ({ nextArticle, prevArticle }) => ( 55 |
56 |

Simple Static Pagination

57 |

58 | This example demonstrates statically-generated pagination without additional page queries. 59 | Pagination information is retrieved directly from 60 | pageContext. 61 |

62 | {prevArticle ? ( 63 | 64 | ←Previous 65 | 66 | ) : ( 67 | '' 68 | )} 69 | {prevArticle && nextArticle && ' -- '} 70 | {nextArticle ? ( 71 | 72 | Next → 73 | 74 | ) : ( 75 | '' 76 | )} 77 |
78 | ); 79 | 80 | const EnhancedPagination = ({ nextArticle, prevArticle }) => ( 81 |
82 |

Enhanced Static Pagination

83 |

84 | This example demonstrates statically-generated pagination enhanced with more detailed 85 | information about the previous and next documents—in this case, the article title. 86 | Modifying the page query is required. 87 |

88 | {prevArticle ? ( 89 | 90 | ← {RichText.asText(prevArticle.title || [], linkResolver)} 91 | 92 | ) : ( 93 | '' 94 | )} 95 |
{prevArticle && nextArticle && ' -- '}
96 | {nextArticle ? ( 97 | 98 | {RichText.asText(nextArticle.title || [], linkResolver)} → 99 | 100 | ) : ( 101 | '' 102 | )} 103 |
104 | ); 105 | 106 | const Article = props => { 107 | const { 108 | pageContext: { paginationPreviousMeta, paginationNextMeta }, 109 | data: { 110 | prismic: { prevArticle, nextArticle }, 111 | }, 112 | } = props; 113 | 114 | const title = get(props.data, 'prismic.allArticles.edges.0.node.title', []); 115 | const slices = get(props.data, 'prismic.allArticles.edges.0.node.body', []); 116 | 117 | const body = (slices || []).map((slice, index) => ( 118 | 119 | {RichText.render(get(slice, 'primary.text', []) || [], linkResolver)} 120 | 121 | )); 122 | 123 | return ( 124 | 125 | 126 | 127 | {!!title && RichText.render(title, linkResolver)} 128 | {body} 129 | Back to index 130 | 131 | ); 132 | }; 133 | 134 | export default Article; 135 | -------------------------------------------------------------------------------- /examples/pagination/src/utils/linkResolver.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | linkResolver(doc) { 3 | if (doc.type === 'article') { 4 | return `/article/${doc.uid}`; 5 | } 6 | 7 | return '/'; 8 | }, 9 | }; 10 | -------------------------------------------------------------------------------- /examples/static-query/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (http://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # Typescript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # dotenv environment variables file 55 | .env 56 | 57 | # gatsby files 58 | .cache/ 59 | public 60 | 61 | # Mac files 62 | .DS_Store 63 | 64 | # Yarn 65 | yarn-error.log 66 | .pnp/ 67 | .pnp.js 68 | # Yarn Integrity file 69 | .yarn-integrity 70 | -------------------------------------------------------------------------------- /examples/static-query/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## [3.6.2](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.6.1...v3.6.2) (2020-04-28) 7 | 8 | **Note:** Version bump only for package @examples/static-query 9 | 10 | ## [3.6.1](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.6.0...v3.6.1) (2020-04-28) 11 | 12 | **Note:** Version bump only for package @examples/static-query 13 | 14 | # [3.6.0](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.4.0...v3.6.0) (2020-04-28) 15 | 16 | **Note:** Version bump only for package @examples/static-query 17 | 18 | # [3.4.0](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.4.0-beta.2...v3.4.0) (2020-01-27) 19 | 20 | **Note:** Version bump only for package @examples/static-query 21 | 22 | # [3.4.0-beta.2](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.4.0-beta.1...v3.4.0-beta.2) (2019-08-20) 23 | 24 | **Note:** Version bump only for package @examples/static-query 25 | 26 | # [3.4.0-beta.1](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.4.0-beta.0...v3.4.0-beta.1) (2019-07-29) 27 | 28 | **Note:** Version bump only for package @examples/static-query 29 | 30 | # [3.4.0-beta.0](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.3.1...v3.4.0-beta.0) (2019-07-18) 31 | 32 | **Note:** Version bump only for package @examples/static-query 33 | 34 | ## [3.3.1](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.3.0...v3.3.1) (2019-07-18) 35 | 36 | **Note:** Version bump only for package @examples/static-query 37 | 38 | # [3.3.0](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.2.0...v3.3.0) (2019-07-09) 39 | 40 | ### Features 41 | 42 | - gatsby-image support ([f598dcd](https://github.com/gatsbyjs/gatsby-starter-default/commit/f598dcd)) 43 | 44 | # [3.2.0](https://github.com/gatsbyjs/gatsby-starter-default/compare/v3.0.0-alpha.0...v3.2.0) (2019-06-04) 45 | 46 | ### Bug Fixes 47 | 48 | - example package name ([50ab749](https://github.com/gatsbyjs/gatsby-starter-default/commit/50ab749)) 49 | 50 | ### Features 51 | 52 | - fragments ([0bc6912](https://github.com/gatsbyjs/gatsby-starter-default/commit/0bc6912)) 53 | - static query ([6666e34](https://github.com/gatsbyjs/gatsby-starter-default/commit/6666e34)) 54 | -------------------------------------------------------------------------------- /examples/static-query/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 gatsbyjs 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /examples/static-query/README.md: -------------------------------------------------------------------------------- 1 | 2 |

3 | 4 | Gatsby 5 | 6 |

7 |

8 | Gatsby's default starter 9 |

10 | 11 | Kick off your project with this default boilerplate. This starter ships with the main Gatsby configuration files you might need to get up and running blazing fast with the blazing fast app generator for React. 12 | 13 | _Have another more specific idea? You may want to check out our vibrant collection of [official and community-created starters](https://www.gatsbyjs.org/docs/gatsby-starters/)._ 14 | 15 | ## 🚀 Quick start 16 | 17 | 1. **Create a Gatsby site.** 18 | 19 | Use the Gatsby CLI to create a new site, specifying the default starter. 20 | 21 | ```sh 22 | # create a new Gatsby site using the default starter 23 | gatsby new my-default-starter https://github.com/gatsbyjs/gatsby-starter-default 24 | ``` 25 | 26 | 1. **Start developing.** 27 | 28 | Navigate into your new site’s directory and start it up. 29 | 30 | ```sh 31 | cd my-default-starter/ 32 | gatsby develop 33 | ``` 34 | 35 | 1. **Open the source code and start editing!** 36 | 37 | Your site is now running at `http://localhost:8000`! 38 | 39 | _Note: You'll also see a second link: _`http://localhost:8000/___graphql`_. This is a tool you can use to experiment with querying your data. Learn more about using this tool in the [Gatsby tutorial](https://www.gatsbyjs.org/tutorial/part-five/#introducing-graphiql)._ 40 | 41 | Open the `my-default-starter` directory in your code editor of choice and edit `src/pages/index.js`. Save your changes and the browser will update in real time! 42 | 43 | ## 🧐 What's inside? 44 | 45 | A quick look at the top-level files and directories you'll see in a Gatsby project. 46 | 47 | . 48 | ├── node_modules 49 | ├── src 50 | ├── .gitignore 51 | ├── .prettierrc 52 | ├── gatsby-browser.js 53 | ├── gatsby-config.js 54 | ├── gatsby-node.js 55 | ├── gatsby-ssr.js 56 | ├── LICENSE 57 | ├── package-lock.json 58 | ├── package.json 59 | └── README.md 60 | 61 | 1. **`/node_modules`**: This directory contains all of the modules of code that your project depends on (npm packages) are automatically installed. 62 | 63 | 2. **`/src`**: This directory will contain all of the code related to what you will see on the front-end of your site (what you see in the browser) such as your site header or a page template. `src` is a convention for “source code”. 64 | 65 | 3. **`.gitignore`**: This file tells git which files it should not track / not maintain a version history for. 66 | 67 | 4. **`.prettierrc`**: This is a configuration file for [Prettier](https://prettier.io/). Prettier is a tool to help keep the formatting of your code consistent. 68 | 69 | 5. **`gatsby-browser.js`**: This file is where Gatsby expects to find any usage of the [Gatsby browser APIs](https://www.gatsbyjs.org/docs/browser-apis/) (if any). These allow customization/extension of default Gatsby settings affecting the browser. 70 | 71 | 6. **`gatsby-config.js`**: This is the main configuration file for a Gatsby site. This is where you can specify information about your site (metadata) like the site title and description, which Gatsby plugins you’d like to include, etc. (Check out the [config docs](https://www.gatsbyjs.org/docs/gatsby-config/) for more detail). 72 | 73 | 7. **`gatsby-node.js`**: This file is where Gatsby expects to find any usage of the [Gatsby Node APIs](https://www.gatsbyjs.org/docs/node-apis/) (if any). These allow customization/extension of default Gatsby settings affecting pieces of the site build process. 74 | 75 | 8. **`gatsby-ssr.js`**: This file is where Gatsby expects to find any usage of the [Gatsby server-side rendering APIs](https://www.gatsbyjs.org/docs/ssr-apis/) (if any). These allow customization of default Gatsby settings affecting server-side rendering. 76 | 77 | 9. **`LICENSE`**: Gatsby is licensed under the MIT license. 78 | 79 | 10. **`package-lock.json`** (See `package.json` below, first). This is an automatically generated file based on the exact versions of your npm dependencies that were installed for your project. **(You won’t change this file directly).** 80 | 81 | 11. **`package.json`**: A manifest file for Node.js projects, which includes things like metadata (the project’s name, author, etc). This manifest is how npm knows which packages to install for your project. 82 | 83 | 12. **`README.md`**: A text file containing useful reference information about your project. 84 | 85 | ## 🎓 Learning Gatsby 86 | 87 | Looking for more guidance? Full documentation for Gatsby lives [on the website](https://www.gatsbyjs.org/). Here are some places to start: 88 | 89 | - **For most developers, we recommend starting with our [in-depth tutorial for creating a site with Gatsby](https://www.gatsbyjs.org/tutorial/).** It starts with zero assumptions about your level of ability and walks through every step of the process. 90 | 91 | - **To dive straight into code samples, head [to our documentation](https://www.gatsbyjs.org/docs/).** In particular, check out the _Guides_, _API Reference_, and _Advanced Tutorials_ sections in the sidebar. 92 | 93 | ## 💫 Deploy 94 | 95 | [![Deploy to Netlify](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/gatsbyjs/gatsby-starter-default) 96 | 97 | 98 | -------------------------------------------------------------------------------- /examples/static-query/gatsby-browser.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Implement Gatsby's Browser APIs in this file. 3 | * 4 | * See: https://www.gatsbyjs.org/docs/browser-apis/ 5 | */ 6 | 7 | // You can delete this file if you're not using it 8 | const { registerLinkResolver } = require('gatsby-source-prismic-graphql'); 9 | 10 | registerLinkResolver(require('./src/utils/linkResolver').linkResolver); 11 | -------------------------------------------------------------------------------- /examples/static-query/gatsby-config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | siteMetadata: { 3 | title: `Gatsby Default Starter`, 4 | description: `Kick off your next, great Gatsby project with this default starter. This barebones starter ships with the main Gatsby configuration files you might need.`, 5 | author: `@gatsbyjs`, 6 | }, 7 | plugins: [ 8 | { 9 | resolve: `gatsby-source-prismic-graphql`, 10 | options: { 11 | repositoryName: 'ueno-starter-kit-universally-test', 12 | }, 13 | }, 14 | `gatsby-plugin-react-helmet`, 15 | { 16 | resolve: `gatsby-source-filesystem`, 17 | options: { 18 | name: `images`, 19 | path: `${__dirname}/src/images`, 20 | }, 21 | }, 22 | `gatsby-transformer-sharp`, 23 | `gatsby-plugin-sharp`, 24 | { 25 | resolve: `gatsby-plugin-manifest`, 26 | options: { 27 | name: `gatsby-starter-default`, 28 | short_name: `starter`, 29 | start_url: `/`, 30 | background_color: `#663399`, 31 | theme_color: `#663399`, 32 | display: `minimal-ui`, 33 | icon: `src/images/gatsby-icon.png`, // This path is relative to the root of the site. 34 | }, 35 | }, 36 | // this (optional) plugin enables Progressive Web App + Offline functionality 37 | // To learn more, visit: https://gatsby.dev/offline 38 | // 'gatsby-plugin-offline', 39 | ], 40 | }; 41 | -------------------------------------------------------------------------------- /examples/static-query/gatsby-node.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Implement Gatsby's Node APIs in this file. 3 | * 4 | * See: https://www.gatsbyjs.org/docs/node-apis/ 5 | */ 6 | -------------------------------------------------------------------------------- /examples/static-query/gatsby-ssr.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Implement Gatsby's SSR (Server Side Rendering) APIs in this file. 3 | * 4 | * See: https://www.gatsbyjs.org/docs/ssr-apis/ 5 | */ 6 | 7 | // You can delete this file if you're not using it 8 | -------------------------------------------------------------------------------- /examples/static-query/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@examples/static-query", 3 | "private": true, 4 | "version": "3.6.2", 5 | "description": "A simple starter to get up and developing quickly with Gatsby", 6 | "author": "Kyle Mathews ", 7 | "dependencies": { 8 | "@babel/polyfill": "^7.2.5", 9 | "esm": "^3.2.18", 10 | "gatsby": "^2.13.37", 11 | "gatsby-image": "^2.0.34", 12 | "gatsby-plugin-manifest": "^2.0.24", 13 | "gatsby-plugin-offline": "^2.0.25", 14 | "gatsby-plugin-react-helmet": "^3.0.10", 15 | "gatsby-plugin-sharp": "^2.2.9", 16 | "gatsby-source-filesystem": "^2.0.27", 17 | "gatsby-source-prismic-graphql": "^3.6.2", 18 | "gatsby-transformer-sharp": "^2.2.5", 19 | "prismic-reactjs": "^0.3.2", 20 | "prop-types": "^15.7.2", 21 | "react": "^16.8.4", 22 | "react-dom": "^16.8.4", 23 | "react-helmet": "^5.2.0" 24 | }, 25 | "devDependencies": { 26 | "prettier": "^1.16.4" 27 | }, 28 | "keywords": [ 29 | "gatsby" 30 | ], 31 | "license": "MIT", 32 | "scripts": { 33 | "build": "gatsby build", 34 | "develop": "gatsby develop", 35 | "format": "prettier --write src/**/*.{js,jsx}", 36 | "start": "npm run develop", 37 | "serve": "gatsby serve", 38 | "test": "echo \"Write tests! -> https://gatsby.dev/unit-testing\"" 39 | }, 40 | "eslintIgnore": [ 41 | "*.js" 42 | ], 43 | "repository": { 44 | "type": "git", 45 | "url": "https://github.com/gatsbyjs/gatsby-starter-default" 46 | }, 47 | "bugs": { 48 | "url": "https://github.com/gatsbyjs/gatsby/issues" 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /examples/static-query/src/components/articles.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { graphql, StaticQuery } from 'gatsby'; 3 | import { withPreview } from 'gatsby-source-prismic-graphql'; 4 | import { RichText } from 'prismic-reactjs'; 5 | import Img from 'gatsby-image'; 6 | 7 | const Image = ({ source = {}, property, ...props }) => { 8 | const sourceSharp = source[`${property}Sharp`]; 9 | if (sourceSharp && sourceSharp.childImageSharp) { 10 | return ; 11 | } else if (source[property] && source[property].url) { 12 | return ; 13 | } 14 | return null; 15 | }; 16 | 17 | const query = graphql` 18 | query { 19 | prismic { 20 | allArticles(first: 2) { 21 | edges { 22 | node { 23 | _meta { 24 | uid 25 | } 26 | title 27 | image 28 | imageSharp { 29 | childImageSharp { 30 | fixed { 31 | ...GatsbyImageSharpFixed 32 | } 33 | } 34 | } 35 | } 36 | } 37 | } 38 | } 39 | } 40 | `; 41 | 42 | const renderArticles = data => { 43 | return ( 44 | <> 45 |

List of articles

46 |
    47 | {data.prismic.allArticles.edges.map(({ node }) => ( 48 |
  • 49 | {RichText.render(node.title)} 50 | 51 |
  • 52 | ))} 53 |
54 | 55 | ); 56 | }; 57 | 58 | export const Articles = () => { 59 | return ( 60 | <> 61 | 62 | 63 | ); 64 | }; 65 | -------------------------------------------------------------------------------- /examples/static-query/src/components/header.js: -------------------------------------------------------------------------------- 1 | import { Link } from 'gatsby'; 2 | import PropTypes from 'prop-types'; 3 | import React from 'react'; 4 | 5 | const Header = ({ siteTitle }) => ( 6 |
12 |
19 |

20 | 27 | {siteTitle} 28 | 29 |

30 |
31 |
32 | ); 33 | 34 | Header.propTypes = { 35 | siteTitle: PropTypes.string, 36 | }; 37 | 38 | Header.defaultProps = { 39 | siteTitle: ``, 40 | }; 41 | 42 | export default Header; 43 | -------------------------------------------------------------------------------- /examples/static-query/src/components/image.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { StaticQuery, graphql } from 'gatsby'; 3 | import Img from 'gatsby-image'; 4 | 5 | /* 6 | * This component is built using `gatsby-image` to automatically serve optimized 7 | * images with lazy loading and reduced file sizes. The image is loaded using a 8 | * `StaticQuery`, which allows us to load the image from directly within this 9 | * component, rather than having to pass the image data down from pages. 10 | * 11 | * For more information, see the docs: 12 | * - `gatsby-image`: https://gatsby.dev/gatsby-image 13 | * - `StaticQuery`: https://gatsby.dev/staticquery 14 | */ 15 | 16 | const Image = () => ( 17 | } 30 | /> 31 | ); 32 | export default Image; 33 | -------------------------------------------------------------------------------- /examples/static-query/src/components/layout.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Layout component that queries for data 3 | * with Gatsby's StaticQuery component 4 | * 5 | * See: https://www.gatsbyjs.org/docs/static-query/ 6 | */ 7 | 8 | import React from 'react'; 9 | import PropTypes from 'prop-types'; 10 | import { StaticQuery, graphql } from 'gatsby'; 11 | 12 | import Header from './header'; 13 | import './layout.css'; 14 | 15 | const Layout = ({ children }) => ( 16 | ( 27 | <> 28 |
29 |
37 |
{children}
38 |
39 | © {new Date().getFullYear()}, Built with 40 | {` `} 41 | Gatsby 42 |
43 |
44 | 45 | )} 46 | /> 47 | ); 48 | 49 | Layout.propTypes = { 50 | children: PropTypes.node.isRequired, 51 | }; 52 | 53 | export default Layout; 54 | -------------------------------------------------------------------------------- /examples/static-query/src/components/seo.js: -------------------------------------------------------------------------------- 1 | /** 2 | * SEO component that queries for data with 3 | * Gatsby's useStaticQuery React hook 4 | * 5 | * See: https://www.gatsbyjs.org/docs/use-static-query/ 6 | */ 7 | 8 | import React from 'react'; 9 | import PropTypes from 'prop-types'; 10 | import Helmet from 'react-helmet'; 11 | import { useStaticQuery, graphql } from 'gatsby'; 12 | 13 | function SEO({ description, lang, meta, keywords, title }) { 14 | const { site } = useStaticQuery( 15 | graphql` 16 | query { 17 | site { 18 | siteMetadata { 19 | title 20 | description 21 | author 22 | } 23 | } 24 | } 25 | ` 26 | ); 27 | 28 | const metaDescription = description || site.siteMetadata.description; 29 | 30 | return ( 31 | 0 73 | ? { 74 | name: `keywords`, 75 | content: keywords.join(`, `), 76 | } 77 | : [] 78 | ) 79 | .concat(meta)} 80 | /> 81 | ); 82 | } 83 | 84 | SEO.defaultProps = { 85 | lang: `en`, 86 | meta: [], 87 | keywords: [], 88 | }; 89 | 90 | SEO.propTypes = { 91 | description: PropTypes.string, 92 | lang: PropTypes.string, 93 | meta: PropTypes.array, 94 | keywords: PropTypes.arrayOf(PropTypes.string), 95 | title: PropTypes.string.isRequired, 96 | }; 97 | 98 | export default SEO; 99 | -------------------------------------------------------------------------------- /examples/static-query/src/images/gatsby-astronaut.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/birkir/gatsby-source-prismic-graphql/5003402d62fcfe865339785524b6be95c8f0b5eb/examples/static-query/src/images/gatsby-astronaut.png -------------------------------------------------------------------------------- /examples/static-query/src/images/gatsby-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/birkir/gatsby-source-prismic-graphql/5003402d62fcfe865339785524b6be95c8f0b5eb/examples/static-query/src/images/gatsby-icon.png -------------------------------------------------------------------------------- /examples/static-query/src/pages/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | // import { Articles } from '../components/articles'; 3 | // import Layout from '../components/layout'; 4 | 5 | export default function Home(props) { 6 | return ( 7 | // 8 |
9 |

Hello

10 | {/* */} 11 |
12 | //
13 | ); 14 | } 15 | -------------------------------------------------------------------------------- /examples/static-query/src/utils/linkResolver.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | linkResolver(doc) { 3 | if (doc.type === 'article') { 4 | return `/article/${doc.uid}`; 5 | } 6 | 7 | return '/'; 8 | }, 9 | }; 10 | -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "npmClient": "yarn", 3 | "useWorkspaces": true, 4 | "packages": ["packages/*"], 5 | "version": "3.6.2", 6 | "command": { 7 | "publish": { 8 | "conventionalCommits": true 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "name": "root", 4 | "workspaces": { 5 | "packages": [ 6 | "packages/*", 7 | "examples/*" 8 | ] 9 | }, 10 | "scripts": { 11 | "setup": "lerna bootstrap; yarn run link; yarn build", 12 | "link": "lerna exec --no-private -- yarn link", 13 | "unlink": "lerna exec --no-private -- yarn unlink", 14 | "clean": "lerna run clean", 15 | "start": "lerna run start --ignore \"@examples/*\" --stream", 16 | "build": "lerna run build --ignore \"@examples/*\"", 17 | "release": "lerna version --force-publish", 18 | "prettier": "prettier --write '**/*.{json,md,js,jsx,ts,tsx}'", 19 | "test": "lerna run build --scope \"@examples/*\"", 20 | "test:prettier": "prettier --list-different '**/*.{json,md,js,jsx,ts,tsx}'" 21 | }, 22 | "husky": { 23 | "hooks": { 24 | "commit-msg": "commitlint -E HUSKY_GIT_PARAMS", 25 | "pre-commit": "lint-staged" 26 | } 27 | }, 28 | "commitlint": { 29 | "extends": [ 30 | "@commitlint/config-conventional" 31 | ] 32 | }, 33 | "lint-staged": { 34 | "*.{ts,tsx,js,json,md}": [ 35 | "prettier --write", 36 | "git add" 37 | ] 38 | }, 39 | "prettier": { 40 | "singleQuote": true, 41 | "trailingComma": "es5", 42 | "printWidth": 100 43 | }, 44 | "devDependencies": { 45 | "@commitlint/cli": "^7.5.2", 46 | "@commitlint/config-conventional": "^7.5.0", 47 | "husky": "^1.3.1", 48 | "lerna": "^3.13.1", 49 | "lint-staged": "^8.1.5", 50 | "prettier": "^1.16.4", 51 | "rimraf": "^2.6.3", 52 | "tslint": "^5.14.0", 53 | "tslint-config-prettier": "^1.18.0", 54 | "typescript": "^3.3.3333" 55 | }, 56 | "dependencies": { 57 | "gatsby": "^2.13.37", 58 | "react": "^16.8.4", 59 | "react-dom": "^16.8.4" 60 | }, 61 | "version": "3.4.0" 62 | } 63 | -------------------------------------------------------------------------------- /packages/gatsby-source-prismic-graphql/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "@babel/preset-env", 4 | "@babel/react", 5 | "@babel/preset-typescript" 6 | ], 7 | "plugins": [ 8 | ["@babel/plugin-transform-runtime", 9 | { 10 | "corejs": false, 11 | "helpers": true, 12 | "regenerator": true, 13 | "useESModules": false 14 | }], 15 | "@babel/proposal-class-properties", 16 | "@babel/proposal-object-rest-spread" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /packages/gatsby-source-prismic-graphql/.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | end_of_line = lf 7 | indent_size = 2 8 | indent_style = space 9 | insert_final_newline = true 10 | trim_trailing_whitespace = true -------------------------------------------------------------------------------- /packages/gatsby-source-prismic-graphql/.gitignore: -------------------------------------------------------------------------------- 1 | *.js 2 | ./utils/*.js 3 | ./interfaces/*.js 4 | types 5 | -------------------------------------------------------------------------------- /packages/gatsby-source-prismic-graphql/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## [3.6.2](https://github.com/birkir/gatsby-source-prismic-graphql/compare/v3.6.1...v3.6.2) (2020-04-28) 7 | 8 | **Note:** Version bump only for package gatsby-source-prismic-graphql 9 | 10 | ## [3.6.1](https://github.com/birkir/gatsby-source-prismic-graphql/compare/v3.6.0...v3.6.1) (2020-04-28) 11 | 12 | **Note:** Version bump only for package gatsby-source-prismic-graphql 13 | 14 | # [3.6.0](https://github.com/birkir/gatsby-source-prismic-graphql/compare/v3.4.0...v3.6.0) (2020-04-28) 15 | 16 | ### Bug Fixes 17 | 18 | - bump dep version to fix ERROR [#11321](https://github.com/birkir/gatsby-source-prismic-graphql/issues/11321) ([9500260](https://github.com/birkir/gatsby-source-prismic-graphql/commit/9500260c0cc81600e1b013b7e115275293ed0e89)) 19 | - fix post review ([9ecc671](https://github.com/birkir/gatsby-source-prismic-graphql/commit/9ecc6711116c05b4002c859ac77beeebe2164e73)) 20 | - fixing type & updating path-to-regexp to use new match function ([eff64d8](https://github.com/birkir/gatsby-source-prismic-graphql/commit/eff64d824438690b7c73ced8f923b5c2f661412d)) 21 | - handle pages with unicode characters ([fa698d5](https://github.com/birkir/gatsby-source-prismic-graphql/commit/fa698d56de2b539f237b18debad6752a92a3524c)) 22 | - multi-lang previews ([e4baba7](https://github.com/birkir/gatsby-source-prismic-graphql/commit/e4baba7bc2c5295bdbb9d20f083891dd127165b1)) 23 | - rollback code to older typescript version ([3cbb1f1](https://github.com/birkir/gatsby-source-prismic-graphql/commit/3cbb1f1d62c7fa97ca44d69e1d205423be50d118)) 24 | - sanitize accessToken option ([6cb96bf](https://github.com/birkir/gatsby-source-prismic-graphql/commit/6cb96bf37f6b258ebda817c06c6a5ab0c3dbc178)) 25 | - test if page exists to display preview real url ([8705eb9](https://github.com/birkir/gatsby-source-prismic-graphql/commit/8705eb99352fda6aab41a684a25d9f16ef86e836)) 26 | - unescape createRemoteFileNode url ([018efe2](https://github.com/birkir/gatsby-source-prismic-graphql/commit/018efe287d25c1750cfb1e69564a3ca670e693b1)) 27 | - unpublish preview for Multi-language ([9ec4f89](https://github.com/birkir/gatsby-source-prismic-graphql/commit/9ec4f896b64f79bae3415419deb671a6db6dff3e)) 28 | - update function doc ([0bb6b35](https://github.com/birkir/gatsby-source-prismic-graphql/commit/0bb6b3550766313624c751fb2369207471301d3c)) 29 | 30 | ### Features 31 | 32 | - additional query size optimization ([8fcec72](https://github.com/birkir/gatsby-source-prismic-graphql/commit/8fcec72add1b3d4606ec8be27e51cce4a8f81156)) 33 | - extraPageFields option for better filtering ([66ac7ba](https://github.com/birkir/gatsby-source-prismic-graphql/commit/66ac7baa8309eb6a97633aa38a2d44f923ffc2c5)) 34 | - optimize query size ([57e2940](https://github.com/birkir/gatsby-source-prismic-graphql/commit/57e2940342f724ef21bc951b987a409fbc2d9d82)) 35 | 36 | # [3.4.0](https://github.com/birkir/gatsby-source-prismic-graphql/compare/v3.4.0-beta.2...v3.4.0) (2020-01-27) 37 | 38 | ### Features 39 | 40 | - add filter explanation to README ([4ff8a62](https://github.com/birkir/gatsby-source-prismic-graphql/commit/4ff8a62)) 41 | - add optional filter to page options ([8bb76aa](https://github.com/birkir/gatsby-source-prismic-graphql/commit/8bb76aa)) 42 | - support short language codes in generated paths ([cf559d6](https://github.com/birkir/gatsby-source-prismic-graphql/commit/cf559d6)) 43 | 44 | # [3.4.0-beta.2](https://github.com/birkir/gatsby-source-prismic-graphql/compare/v3.4.0-beta.1...v3.4.0-beta.2) (2019-08-20) 45 | 46 | ### Bug Fixes 47 | 48 | - remove/delete traverse ([927230d](https://github.com/birkir/gatsby-source-prismic-graphql/commit/927230d)) 49 | 50 | # [3.4.0-beta.1](https://github.com/birkir/gatsby-source-prismic-graphql/compare/v3.4.0-beta.0...v3.4.0-beta.1) (2019-07-29) 51 | 52 | ### Bug Fixes 53 | 54 | - bump prismic-javascript dep to fix timeout connection issues ([36f04f2](https://github.com/birkir/gatsby-source-prismic-graphql/commit/36f04f2)) 55 | - check if proptypes can be added to StaticQuery ([f05a5e6](https://github.com/birkir/gatsby-source-prismic-graphql/commit/f05a5e6)) 56 | 57 | # [3.4.0-beta.0](https://github.com/birkir/gatsby-source-prismic-graphql/compare/v3.3.1...v3.4.0-beta.0) (2019-07-18) 58 | 59 | ### Bug Fixes 60 | 61 | - improve pagination context var names; pass context for previews ([166321c](https://github.com/birkir/gatsby-source-prismic-graphql/commit/166321c)) 62 | - multi-locale path-generation logic, enhanced typing ([bbe2aa5](https://github.com/birkir/gatsby-source-prismic-graphql/commit/bbe2aa5)) 63 | - multi-locale support compatible with pagination ([bffeea2](https://github.com/birkir/gatsby-source-prismic-graphql/commit/bffeea2)) 64 | - sortBy works for all document types ([d861c9d](https://github.com/birkir/gatsby-source-prismic-graphql/commit/d861c9d)) 65 | - support previews in other than defaultLang ([e621a76](https://github.com/birkir/gatsby-source-prismic-graphql/commit/e621a76)) 66 | 67 | ### Features 68 | 69 | - add direct support for referencing next and prev pages ([a3c06db](https://github.com/birkir/gatsby-source-prismic-graphql/commit/a3c06db)) 70 | - add support for passing sortBy for pages ([aa893b4](https://github.com/birkir/gatsby-source-prismic-graphql/commit/aa893b4)) 71 | - create and expose cursor encoding helpers ([a1959ac](https://github.com/birkir/gatsby-source-prismic-graphql/commit/a1959ac)) 72 | - enable backwards pagination by providing lastPageEndCursor ([2f0fe1b](https://github.com/birkir/gatsby-source-prismic-graphql/commit/2f0fe1b)) 73 | 74 | ## [3.3.1](https://github.com/birkir/gatsby-source-prismic-graphql/compare/v3.3.0...v3.3.1) (2019-07-18) 75 | 76 | ### Bug Fixes 77 | 78 | - typo in README.md ([f4e5390](https://github.com/birkir/gatsby-source-prismic-graphql/commit/f4e5390)) 79 | 80 | # [3.3.0](https://github.com/birkir/gatsby-source-prismic-graphql/compare/v3.2.0...v3.3.0) (2019-07-09) 81 | 82 | ### Bug Fixes 83 | 84 | - prettier formatting in unrelated file so tests pass ([a56f66e](https://github.com/birkir/gatsby-source-prismic-graphql/commit/a56f66e)) 85 | - work around 20-page limit for Prismic queries ([861aedf](https://github.com/birkir/gatsby-source-prismic-graphql/commit/861aedf)) 86 | 87 | ### Features 88 | 89 | - gatsby-image support ([f598dcd](https://github.com/birkir/gatsby-source-prismic-graphql/commit/f598dcd)) 90 | 91 | # [3.2.0](https://github.com/birkir/gatsby-source-prismic-graphql/compare/v3.0.0-alpha.0...v3.2.0) (2019-06-04) 92 | 93 | ### Bug Fixes 94 | 95 | - add apollo-boost dependency ([c4334c8](https://github.com/birkir/gatsby-source-prismic-graphql/commit/c4334c8)) 96 | - dependency and load variables ([e826e5f](https://github.com/birkir/gatsby-source-prismic-graphql/commit/e826e5f)) 97 | - ensure location is in props ([82eb8f0](https://github.com/birkir/gatsby-source-prismic-graphql/commit/82eb8f0)) 98 | - prettier ([68ce94c](https://github.com/birkir/gatsby-source-prismic-graphql/commit/68ce94c)) 99 | - prettier ([fbc4395](https://github.com/birkir/gatsby-source-prismic-graphql/commit/fbc4395)) 100 | - preview page with no pages option ([d271ca0](https://github.com/birkir/gatsby-source-prismic-graphql/commit/d271ca0)) 101 | - ssr strip whitespace fetch ([3f843c2](https://github.com/birkir/gatsby-source-prismic-graphql/commit/3f843c2)) 102 | - test deploy ([11bb7b5](https://github.com/birkir/gatsby-source-prismic-graphql/commit/11bb7b5)) 103 | - update graphql source plugin ([3b9bab0](https://github.com/birkir/gatsby-source-prismic-graphql/commit/3b9bab0)) 104 | 105 | ### Features 106 | 107 | - fragments ([34f9c78](https://github.com/birkir/gatsby-source-prismic-graphql/commit/34f9c78)) 108 | - fragments ([0bc6912](https://github.com/birkir/gatsby-source-prismic-graphql/commit/0bc6912)) 109 | - languages ([09a1c47](https://github.com/birkir/gatsby-source-prismic-graphql/commit/09a1c47)) 110 | - static query ([6666e34](https://github.com/birkir/gatsby-source-prismic-graphql/commit/6666e34)) 111 | 112 | # 3.0.0-alpha.0 (2019-03-19) 113 | 114 | Initial pre-release 115 | -------------------------------------------------------------------------------- /packages/gatsby-source-prismic-graphql/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": false, 3 | "name": "gatsby-source-prismic-graphql", 4 | "description": "Source data from Prismic with GraphQL", 5 | "license": "MIT", 6 | "author": "Birkir Gudjonsson ", 7 | "homepage": "https://github.com/birkir/gatsby-source-prismic-graphql#readme", 8 | "repository": { 9 | "type": "git", 10 | "url": "git+https://github.com/birkir/gatsby-source-prismic-graphql.git" 11 | }, 12 | "bugs": { 13 | "url": "https://github.com/birkir/gatsby-source-prismic-graphql/issues" 14 | }, 15 | "version": "3.6.2", 16 | "main": "index.js", 17 | "files": [ 18 | "*.js", 19 | "components", 20 | "interfaces", 21 | "types", 22 | "utils" 23 | ], 24 | "scripts": { 25 | "build": "tsc --emitDeclarationOnly && babel src --out-dir ./ --extensions '.ts,.tsx'", 26 | "clean": "rimraf {interfaces,types,components,utils,*.js}", 27 | "prepare": "yarn clean && cross-env NODE_ENV=production yarn build", 28 | "start": "babel src --out-dir ./ --extensions '.ts,.tsx' --watch" 29 | }, 30 | "types": "./types/index.d.ts", 31 | "dependencies": { 32 | "apollo-boost": "^0.3.1", 33 | "apollo-link-context": "^1.0.17", 34 | "gatsby-image": "^2.2.4", 35 | "gatsby-source-filesystem": "^2.1.2", 36 | "gatsby-source-graphql": "^2.1.32", 37 | "gatsby-source-graphql-universal": "^3.3.0", 38 | "path-to-regexp": "^6.0.0", 39 | "prismic-javascript": "^2.1.1", 40 | "querystring": "^0.2.0", 41 | "traverse": "^0.6.6", 42 | "url-pattern": "^1.0.3" 43 | }, 44 | "peerDependencies": { 45 | "gatsby": "^2.13.37", 46 | "react": "^16.0.0" 47 | }, 48 | "devDependencies": { 49 | "@babel/cli": "7.2.3", 50 | "@babel/core": "7.3.3", 51 | "@babel/plugin-proposal-class-properties": "7.3.3", 52 | "@babel/plugin-proposal-object-rest-spread": "7.3.2", 53 | "@babel/plugin-transform-runtime": "7.2.0", 54 | "@babel/preset-env": "7.3.1", 55 | "@babel/preset-react": "7.0.0", 56 | "@babel/preset-typescript": "7.3.3", 57 | "@babel/runtime": "7.3.1", 58 | "@types/lodash": "4.14.121", 59 | "@types/node": "11.9.4", 60 | "@types/node-fetch": "2.1.6", 61 | "@types/react": "16.8.4", 62 | "@types/styled-components": "^4.1.12", 63 | "@types/traverse": "^0.6.32", 64 | "cross-env": "^5.2.0", 65 | "gatsby": "^2.13.37", 66 | "prettier": "^1.16.4" 67 | }, 68 | "keywords": [ 69 | "gatsby", 70 | "gatsby-plugin", 71 | "graphql", 72 | "preview", 73 | "prismic" 74 | ] 75 | } 76 | -------------------------------------------------------------------------------- /packages/gatsby-source-prismic-graphql/src/components/PreviewPage.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Prismic from 'prismic-javascript'; 3 | import { pathToRegexp, Key } from 'path-to-regexp'; 4 | import { linkResolver, getCookies, getPagePreviewPath } from '../utils'; 5 | import { parseQueryString } from '../utils/parseQueryString'; 6 | import { Page } from '../interfaces/PluginOptions'; 7 | 8 | interface Variation { 9 | id: string; 10 | label: string; 11 | ref: string; 12 | } 13 | 14 | export default class PreviewPage extends React.Component { 15 | public componentDidMount() { 16 | this.preview(); 17 | } 18 | 19 | get config() { 20 | return this.props.prismic.options; 21 | } 22 | 23 | public async preview() { 24 | const { location } = this.props; 25 | const qs = parseQueryString(String(location.search).substr(1)); 26 | const token = qs.get('token'); 27 | const experiment = qs.get('experiment'); 28 | const documentId = qs.get('documentId'); 29 | 30 | // Expiration date of cookie 31 | const now = new Date(); 32 | now.setHours(now.getHours() + 1); 33 | 34 | const api = await Prismic.getApi(`https://${this.config.repositoryName}.cdn.prismic.io/api/v2`); 35 | 36 | if (token) { 37 | await api.previewSession(token, linkResolver, '/'); 38 | document.cookie = `${Prismic.previewCookie}=${token}; expires=${now.toUTCString()}; path=/`; 39 | 40 | if (!documentId) { 41 | return this.redirect(); 42 | } 43 | 44 | const doc = await api.getByID(documentId); 45 | 46 | return this.redirect(doc); 47 | } else if (experiment) { 48 | const runningVariations: Variation[] = []; 49 | 50 | if (api.experiments.running && api.experiments.running.length) { 51 | runningVariations.concat( 52 | ...api.experiments.running.map(experiment => experiment.data.variations) 53 | ); 54 | } 55 | 56 | if (experiment && runningVariations.length) { 57 | const matchedVariation = runningVariations.find( 58 | variation => variation.label.toLowerCase().replace(' ', '-') === experiment 59 | ); 60 | 61 | if (matchedVariation) { 62 | document.cookie = `${Prismic.experimentCookie}=${ 63 | matchedVariation.ref 64 | }; expires=${now.toUTCString()}; path=/`; 65 | this.redirect(); 66 | } 67 | } 68 | } else if (documentId) { 69 | const cookies = getCookies(); 70 | const doc = await api.getByID(documentId); 71 | const preview = cookies.has(Prismic.previewCookie) || cookies.has(Prismic.experimentCookie); 72 | this.redirect(preview && doc); 73 | } 74 | } 75 | 76 | public redirect = async (doc?: any) => { 77 | if (!doc) { 78 | (window as any).location = '/'; 79 | return; 80 | } 81 | 82 | const link: string = linkResolver(doc); 83 | 84 | const pathWithQS = (this.config.pages || []) 85 | .map((page: Page) => { 86 | const keys: Key[] = []; 87 | const re: RegExp = pathToRegexp(page.match, keys); 88 | const match = re.exec(link); 89 | const delimiter = (str: string) => (str.indexOf('?') === -1 ? '?' : '&'); 90 | if (match) { 91 | return match.slice(1).reduce((acc: string, value: string, i: number) => { 92 | if (keys[i] && value !== undefined) 93 | return acc + `${delimiter(acc)}${keys[i].name}=${value}`; 94 | else return acc; 95 | }, getPagePreviewPath(page)); 96 | } 97 | return null; 98 | }) 99 | .find((n: any) => !!n); 100 | 101 | const pageExists = this.props.pageContext.prismicAllPagePaths.indexOf(link) !== -1; 102 | 103 | if (!pageExists && pathWithQS) { 104 | const newUrl = `${window.location.protocol}//${window.location.host}${pathWithQS}`; 105 | window.location.replace(newUrl); 106 | } else { 107 | window.location.replace(link as any); 108 | } 109 | }; 110 | 111 | public render() { 112 | return null; 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /packages/gatsby-source-prismic-graphql/src/components/WrapPage.tsx: -------------------------------------------------------------------------------- 1 | import { getIsolatedQuery } from 'gatsby-source-graphql-universal'; 2 | 3 | import pick from 'lodash/pick'; 4 | import get from 'lodash/get'; 5 | import { pathToRegexp, match as matchRegex, Key } from 'path-to-regexp'; 6 | 7 | import Prismic from 'prismic-javascript'; 8 | import React from 'react'; 9 | import traverse from 'traverse'; 10 | import { fieldName, getCookies, typeName } from '../utils'; 11 | import { createLoadingScreen } from '../utils/createLoadingScreen'; 12 | import { getApolloClient } from '../utils/getApolloClient'; 13 | import { parseQueryString, parseQueryStringAsJson } from '../utils/parseQueryString'; 14 | 15 | const queryOrSource = (obj: any) => { 16 | if (typeof obj === 'string') { 17 | return obj.replace(/\s+/g, ' '); 18 | } else if (obj.source) { 19 | return String(obj.source).replace(/\s+/g, ' '); 20 | } 21 | return null; 22 | }; 23 | 24 | const stripSharp = (query: any) => { 25 | return traverse(query).map(function(x) { 26 | if ( 27 | typeof x === 'object' && 28 | x.kind == 'Name' && 29 | this.parent && 30 | this.parent.node.kind === 'Field' && 31 | x.value.match(/Sharp$/) && 32 | !x.value.match(/.+childImageSharp$/) 33 | ) { 34 | this.parent.delete(); 35 | } 36 | }); 37 | }; 38 | 39 | interface WrapPageState { 40 | data: any; 41 | loading: boolean; 42 | error: Error | null; 43 | } 44 | 45 | export class WrapPage extends React.PureComponent { 46 | state: WrapPageState = { 47 | data: this.props.data, 48 | loading: false, 49 | error: null, 50 | }; 51 | 52 | keys = ['uid', 'id', 'lang']; 53 | 54 | get params() { 55 | const params: any = { ...this.props.pageContext }; 56 | 57 | const keys: Key[] = []; 58 | const re = pathToRegexp(get(this.props.pageContext, 'matchPath', ''), keys); 59 | const match = re.exec(get(this.props, 'location.pathname', '')); 60 | 61 | const matchFn = matchRegex(get(this.props.pageContext, 'matchPath', ''), { 62 | decode: decodeURIComponent, 63 | }); 64 | 65 | const pathParams = (() => { 66 | const res = matchFn(get(this.props, 'location.pathname', '')); 67 | return res ? res.params : {}; 68 | })(); 69 | 70 | const qsParams = (() => { 71 | const qsValue = String(get(this.props, 'location.search', '?')).substr(1); 72 | return parseQueryStringAsJson(qsValue); 73 | })(); 74 | 75 | return Object.assign(params, qsParams, pathParams); 76 | } 77 | 78 | getQuery() { 79 | const child = this.props.children as any; 80 | let query = queryOrSource(get(this.props.pageContext, 'rootQuery')) || ''; 81 | 82 | if (child && child.type) { 83 | if (child.type.query) { 84 | query = queryOrSource(child.type.query) || ''; 85 | } 86 | 87 | if (child.type.fragments && Array.isArray(child.type.fragments)) { 88 | child.type.fragments.forEach((fragment: any) => { 89 | query += queryOrSource(fragment); 90 | }); 91 | } 92 | } 93 | 94 | return query; 95 | } 96 | 97 | componentDidMount() { 98 | const { pageContext, options } = this.props; 99 | const cookies = getCookies(); 100 | const hasCookie = cookies.has(Prismic.experimentCookie) || cookies.has(Prismic.previewCookie); 101 | 102 | if (pageContext.rootQuery && options.previews !== false && hasCookie) { 103 | const closeLoading = createLoadingScreen(); 104 | this.setState({ loading: true }); 105 | this.load() 106 | .then(res => { 107 | this.setState({ 108 | loading: false, 109 | error: null, 110 | data: { ...this.state.data, prismic: res.data }, 111 | }); 112 | closeLoading(); 113 | }) 114 | .catch(error => { 115 | this.setState({ loading: false, error }); 116 | console.error(error); 117 | closeLoading(); 118 | }); 119 | } 120 | } 121 | 122 | load = ({ variables = {}, query, fragments = [], ...rest }: any = {}) => { 123 | if (!query) { 124 | query = this.getQuery(); 125 | } else { 126 | query = queryOrSource(query); 127 | } 128 | 129 | fragments.forEach((fragment: any) => { 130 | query += queryOrSource(fragment); 131 | }); 132 | 133 | const keys = [...(this.props.options.passContextKeys || []), ...this.keys]; 134 | variables = { ...pick(this.params, keys), ...variables }; 135 | 136 | return getApolloClient(this.props.options).then(client => { 137 | return client.query({ 138 | query: stripSharp(getIsolatedQuery(query, fieldName, typeName)), 139 | fetchPolicy: 'no-cache', 140 | variables, 141 | ...rest, 142 | }); 143 | }); 144 | }; 145 | 146 | render() { 147 | const props = this.props as { children: any, options: any, [key: string]: any} 148 | 149 | // we need to pass the parent props to the child 150 | // but we don't want to pass the prismic options or the children props 151 | // so exclude those and take everything else 152 | const { children, options, ...elProps } = props 153 | 154 | return React.cloneElement(children, { 155 | ...elProps, 156 | ...children.props, 157 | prismic: { 158 | options: this.props.options, 159 | loading: this.state.loading, 160 | error: this.state.error, 161 | load: this.load, 162 | }, 163 | data: this.state.data, 164 | }); 165 | } 166 | } 167 | -------------------------------------------------------------------------------- /packages/gatsby-source-prismic-graphql/src/components/withPreview.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { WrapPage } from './WrapPage'; 3 | 4 | export const withPreview = (render: Function, query: any, fragments: any = []) => { 5 | if (typeof window === 'undefined') { 6 | return render; 7 | } 8 | 9 | if (!render) { 10 | return null; 11 | } 12 | 13 | const RenderComponent = ({ data }: any) => render(data); 14 | const rootQuery = `${query.source}${fragments 15 | .map((fragment: any) => (fragment && fragment.source ? fragment.source : '')) 16 | .join(' ')}`; 17 | 18 | return (data: any) => ( 19 | 24 | 25 | 26 | ); 27 | }; 28 | -------------------------------------------------------------------------------- /packages/gatsby-source-prismic-graphql/src/gatsby-browser.tsx: -------------------------------------------------------------------------------- 1 | import { StaticQuery } from 'gatsby'; 2 | import PropTypes from 'prop-types'; 3 | import React from 'react'; 4 | import { WrapPage } from './components/WrapPage'; 5 | 6 | // Fixes proptypes warning for StaticQuery 7 | if (StaticQuery && typeof StaticQuery === 'object' && (StaticQuery as any).propTypes) { 8 | (StaticQuery as any).propTypes.query = PropTypes.oneOfType([ 9 | PropTypes.string, 10 | PropTypes.shape({ 11 | id: PropTypes.string, 12 | source: PropTypes.string, 13 | }), 14 | ]); 15 | } 16 | 17 | interface WrapPageArgs { 18 | element: any; 19 | props: any; 20 | } 21 | 22 | export const wrapPageElement = ({ element, props }: WrapPageArgs, options: any) => { 23 | if (props.pageContext.rootQuery || props.pageContext.prismicPreviewPage) { 24 | return ( 25 | 26 | {element} 27 | 28 | ); 29 | } 30 | 31 | return element; 32 | }; 33 | -------------------------------------------------------------------------------- /packages/gatsby-source-prismic-graphql/src/gatsby-node.ts: -------------------------------------------------------------------------------- 1 | import path from 'path'; 2 | import { getRootQuery } from 'gatsby-source-graphql-universal/getRootQuery'; 3 | import { onCreateWebpackConfig, sourceNodes } from 'gatsby-source-graphql-universal/gatsby-node'; 4 | import { flatten, fieldName, PrismicLink, typeName, getPagePreviewPath } from './utils'; 5 | import { Page, PluginOptions } from './interfaces/PluginOptions'; 6 | import { createRemoteFileNode } from 'gatsby-source-filesystem'; 7 | import { pathToRegexp, compile as compilePath, Key } from 'path-to-regexp'; 8 | import querystring from 'querystring'; 9 | 10 | interface Edge { 11 | cursor: string; 12 | node: any; 13 | endCursor: string; 14 | } 15 | 16 | exports.onCreateWebpackConfig = onCreateWebpackConfig; 17 | 18 | let accessToken: string | null | undefined; 19 | exports.onPreInit = (_: any, options: PluginOptions) => { 20 | accessToken = options.accessToken; 21 | if (!options.previews) { 22 | delete options.accessToken; 23 | } 24 | }; 25 | 26 | exports.onCreatePage = ({ page, actions }: any) => { 27 | const rootQuery = getRootQuery(page.componentPath); 28 | page.context = page.context || {}; 29 | if (rootQuery) { 30 | page.context.rootQuery = rootQuery; 31 | actions.createPage(page); 32 | } 33 | }; 34 | 35 | exports.sourceNodes = (ref: any, options: PluginOptions) => { 36 | const opts = { 37 | fieldName, 38 | typeName, 39 | createLink: () => 40 | PrismicLink({ 41 | uri: `https://${options.repositoryName}.prismic.io/graphql`, 42 | credentials: 'same-origin', 43 | accessToken: accessToken as any, 44 | customRef: options.prismicRef as any, 45 | }), 46 | ...options, 47 | }; 48 | 49 | return sourceNodes(ref, opts); 50 | }; 51 | 52 | function createGeneralPreviewPage( 53 | createPage: Function, 54 | allPaths: string[], 55 | options: PluginOptions 56 | ): void { 57 | const previewPath: string = options.previewPath || '/preview'; 58 | createPage({ 59 | path: previewPath.replace(/^\//, ''), 60 | component: path.resolve(path.join(__dirname, 'components', 'PreviewPage.js')), 61 | context: { 62 | prismicPreviewPage: true, 63 | prismicAllPagePaths: allPaths, 64 | }, 65 | }); 66 | } 67 | 68 | function createDocumentPreviewPage(createPage: Function, options: PluginOptions, page: Page): void { 69 | const rootQuery = getRootQuery(page.component); 70 | createPage({ 71 | path: getPagePreviewPath(page), 72 | component: page.component, 73 | context: { 74 | rootQuery, 75 | id: '', 76 | uid: '', 77 | lang: options.defaultLang, 78 | paginationPreviousUid: '', 79 | paginationPreviousLang: '', 80 | paginationNextUid: '', 81 | paginationNextLang: '', 82 | }, 83 | }); 84 | } 85 | 86 | /** 87 | * Create URL paths interpolating `:uid` and `:lang` or `:lang?` with actual values. 88 | * @param pageOptions - Returned paths are based on the `match` property of the `pageOptions` object. 89 | * @param node - Document node metadata provide the `lang` and `uid` values for the returned path. 90 | * @param options - The plugin's global options. 91 | * @param options.defaultLang - `defaultLang` as declared in `PluginOptions`. If `lang` segment is 92 | * marked optional (`:lang?`) in the page `match` and `defaultLang` matches the 93 | * document's actual language, the language segment of the path will be omitted in the returned path. 94 | * @param options.shortenUrlLangs - When truthy, the lang used for the path will be limited to 2 characters. 95 | * @return The path for the document's URL with `lang` and `uid` interpolated as necessary. 96 | */ 97 | function createDocumentPath( 98 | pageOptions: Page, 99 | node: any, 100 | { defaultLang, shortenUrlLangs }: PluginOptions 101 | ): string { 102 | const pathKeys: Key[] = []; 103 | const pathTemplate: string = pageOptions.match; 104 | pathToRegexp(pathTemplate, pathKeys); 105 | const langKey = pathKeys.find(key => key.name === 'lang'); 106 | const isLangOptional: boolean = !!(langKey && langKey.modifier === '?'); 107 | const toPath: Function = compilePath(pathTemplate); 108 | 109 | const documentLang: string = node._meta.lang; 110 | const isDocumentLangDefault: boolean = documentLang === defaultLang; 111 | const shouldExcludeLangInPath: boolean = isLangOptional && isDocumentLangDefault; 112 | const displayedLang: string = shortenUrlLangs ? documentLang.slice(0, 2) : documentLang; 113 | const lang: string | null = shouldExcludeLangInPath ? null : displayedLang; 114 | 115 | const params = { ...node._meta, lang }; 116 | const path: string = decodeURI(toPath(params)); 117 | return path === '' ? '/' : path; 118 | } 119 | 120 | function createDocumentPages( 121 | createPage: Function, 122 | edges: Edge[], 123 | options: PluginOptions, 124 | page: Page 125 | ): string[] { 126 | const paths: string[] = []; 127 | 128 | // Cycle through each document returned from query... 129 | edges.forEach(({ cursor, node }: Edge, index: number) => { 130 | const previousNode = edges[index - 1] && edges[index - 1].node; 131 | const nextNode = edges[index + 1] && edges[index + 1].node; 132 | const path = createDocumentPath(page, node, options); 133 | paths.push(path); 134 | 135 | // ...and create the page 136 | createPage({ 137 | path, 138 | component: page.component, 139 | context: { 140 | rootQuery: getRootQuery(page.component), 141 | ...node._meta, 142 | cursor, 143 | paginationPreviousMeta: previousNode ? previousNode._meta : null, 144 | paginationPreviousUid: previousNode ? previousNode._meta.uid : '', 145 | paginationPreviousLang: previousNode ? previousNode._meta.lang : '', 146 | paginationNextMeta: nextNode ? nextNode._meta : null, 147 | paginationNextUid: nextNode ? nextNode._meta.uid : '', 148 | paginationNextLang: nextNode ? nextNode._meta.lang : '', 149 | // pagination helpers for overcoming backwards pagination issues cause by Prismic's 20-document query limit 150 | lastQueryChunkEndCursor: edges[index - 1] ? edges[index - 1].endCursor : '', 151 | }, 152 | }); 153 | }); 154 | 155 | return paths; 156 | } 157 | 158 | const getDocumentsQuery = ({ 159 | documentType, 160 | sortType, 161 | extraPageFields, 162 | }: { 163 | documentType: string; 164 | sortType: string; 165 | extraPageFields: string; 166 | }): string => ` 167 | query AllPagesQuery ($after: String, $lang: String, $sortBy: ${sortType}) { 168 | prismic { 169 | ${documentType} ( 170 | first: 20 171 | after: $after 172 | sortBy: $sortBy 173 | lang: $lang 174 | ) { 175 | totalCount 176 | pageInfo { 177 | hasNextPage 178 | endCursor 179 | } 180 | edges { 181 | cursor 182 | node { 183 | ${extraPageFields} 184 | _meta { 185 | id 186 | lang 187 | uid 188 | type 189 | alternateLanguages { 190 | id 191 | lang 192 | type 193 | uid 194 | } 195 | } 196 | } 197 | } 198 | } 199 | } 200 | } 201 | `; 202 | 203 | exports.createPages = async ({ graphql, actions: { createPage } }: any, options: PluginOptions) => { 204 | /** 205 | * Helper that recursively queries GraphQL to collect all documents for the given 206 | * page type. 207 | * Prismic GraphQL queries only return up to 20 results per query 208 | */ 209 | async function getPrismicEdges( 210 | page: Page, 211 | lang?: string, 212 | endCursor: string = '', 213 | documents: Edge[] = [] 214 | ): Promise { 215 | // Format page.type so that the graphql query doesn't complain. 216 | const pageTypeUnderscored = page.type.toLowerCase().split(' ').join('_'); 217 | const pageTypeFormatted = pageTypeUnderscored.charAt(0).toUpperCase() + pageTypeUnderscored.slice(1); 218 | // Prepare and execute query 219 | const documentType: string = `all${pageTypeFormatted}s`; 220 | const sortType: string = `PRISMIC_Sort${pageTypeFormatted}`; 221 | const extraPageFields = options.extraPageFields || ''; 222 | const query: string = getDocumentsQuery({ documentType, sortType, extraPageFields }); 223 | const { data, errors } = await graphql(query, { 224 | after: endCursor, 225 | lang: lang || null, 226 | sortBy: page.sortBy, 227 | }); 228 | 229 | if (errors && errors.length) { 230 | throw errors[0]; 231 | } 232 | 233 | const response = data.prismic[documentType]; 234 | const edges = page.filter ? response.edges.filter(page.filter) : response.edges; 235 | 236 | // Add last end cursor to all edges to enable pagination context when creating pages 237 | edges.forEach((edge: any) => (edge.endCursor = endCursor)); 238 | 239 | // Stage documents for page creation 240 | documents = [...documents, ...edges]; 241 | 242 | if (response.pageInfo.hasNextPage) { 243 | const newEndCursor: string = response.pageInfo.endCursor; 244 | return await getPrismicEdges(page, lang, newEndCursor, documents); 245 | } else { 246 | return Promise.resolve(documents); 247 | } 248 | } 249 | 250 | async function createPagesForType(page: Page, lang?: string): Promise { 251 | const edges = await getPrismicEdges(page, lang); 252 | createDocumentPreviewPage(createPage, options, page); 253 | return createDocumentPages(createPage, edges, options, page); 254 | } 255 | 256 | // Create pageCreator promises for each page/language combination 257 | const pages: Page[] = options.pages || []; 258 | const pageCreators = flatten( 259 | pages.map((page: Page) => { 260 | const langs = page.langs || options.langs || (options.defaultLang && [options.defaultLang]); 261 | if (langs) { 262 | return langs.map((lang: string) => createPagesForType(page, lang)); 263 | } else { 264 | return [createPagesForType(page)]; 265 | } 266 | }) 267 | ); 268 | 269 | // Run all pageCreators simultaneously 270 | const allPaths = flatten(await Promise.all(pageCreators)); 271 | 272 | createGeneralPreviewPage(createPage, allPaths, options); 273 | }; 274 | 275 | exports.createResolvers = ( 276 | { actions, cache, createNodeId, createResolvers, store, reporter }: any, 277 | { sharpKeys = [/image|photo|picture/] }: PluginOptions 278 | ) => { 279 | const { createNode } = actions; 280 | 281 | const state = store.getState(); 282 | const [prismicSchema = {}] = state.schemaCustomization.thirdPartySchemas; 283 | const typeMap = prismicSchema._typeMap; 284 | const resolvers: { [key: string]: any } = {}; 285 | 286 | for (const typeName in typeMap) { 287 | const typeEntry = typeMap[typeName]; 288 | const typeFields = (typeEntry && typeEntry.getFields && typeEntry.getFields()) || {}; 289 | const typeResolver: { [key: string]: any } = {}; 290 | for (const fieldName in typeFields) { 291 | const field = typeFields[fieldName]; 292 | if ( 293 | field.type === typeMap.PRISMIC_Json && 294 | sharpKeys.some((re: RegExp | string) => 295 | re instanceof RegExp ? re.test(fieldName) : re === fieldName 296 | ) 297 | ) { 298 | typeResolver[`${fieldName}Sharp`] = { 299 | type: 'File', 300 | args: { 301 | crop: { type: typeMap.String }, 302 | }, 303 | resolve(source: any, args: any) { 304 | const obj = (source && source[fieldName]) || {}; 305 | const url = args.crop ? obj[args.crop] && obj[args.crop].url : obj.url; 306 | 307 | if (url) { 308 | return createRemoteFileNode({ 309 | url: querystring.unescape(url).replace(/\?.*$/g, ''), 310 | store, 311 | cache, 312 | createNode, 313 | createNodeId, 314 | reporter, 315 | }); 316 | } 317 | return null; 318 | }, 319 | }; 320 | } 321 | } 322 | if (Object.keys(typeResolver).length) { 323 | resolvers[typeName] = typeResolver; 324 | } 325 | } 326 | 327 | if (Object.keys(resolvers).length) { 328 | createResolvers(resolvers); 329 | } 330 | }; 331 | -------------------------------------------------------------------------------- /packages/gatsby-source-prismic-graphql/src/gatsby-ssr.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { PluginOptions } from './interfaces/PluginOptions'; 3 | 4 | interface OnRenderBodyArgs { 5 | setHeadComponents(args: React.ReactElement[]): void; 6 | } 7 | 8 | exports.onRenderBody = ({ setHeadComponents }: OnRenderBodyArgs, options: PluginOptions) => { 9 | const components = [ 10 |