├── .env.GATSBY_CONCURRENT_DOWNLOAD
├── .gitattributes
├── .gitignore
├── .prettierrc.js
├── .vscode
└── launch.json
├── LICENSE
├── README.md
├── WordPress
└── plugins
│ ├── wp-gatsby.0.4.17.zip
│ └── wp-graphql-0.13.1.zip
├── gatsby-config.js
├── gatsby-node.js
├── package.json
├── src
├── assets
│ ├── images
│ │ └── test.png
│ ├── style.css
│ └── svg
│ │ └── gatsby.inline.svg
├── components
│ ├── header.js
│ ├── layout.js
│ ├── menu.js
│ └── template-parts
│ │ └── blog-post.js
├── fragments.js
├── pages
│ └── 404.js
├── templates
│ ├── index.js
│ └── single
│ │ ├── Page.js
│ │ └── Post.js
└── utils
│ └── get-url-path.js
└── yarn.lock
/.env.GATSBY_CONCURRENT_DOWNLOAD:
--------------------------------------------------------------------------------
1 | GATSBY_CONCURRENT_DOWNLOAD=200
2 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | WordPress/GraphQL
2 |
3 | # Logs
4 | logs
5 | *.log
6 | npm-debug.log*
7 | yarn-debug.log*
8 | yarn-error.log*
9 |
10 | # Runtime data
11 | pids
12 | *.pid
13 | *.seed
14 | *.pid.lock
15 |
16 | # Directory for instrumented libs generated by jscoverage/JSCover
17 | lib-cov
18 |
19 | # Coverage directory used by tools like istanbul
20 | coverage
21 |
22 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
23 | .grunt
24 |
25 | # Bower dependency directory (https://bower.io/)
26 | bower_components
27 |
28 | # node-waf configuration
29 | .lock-wscript
30 |
31 | # Compiled binary addons (http://nodejs.org/api/addons.html)
32 | build/Release
33 |
34 | # Dependency directories
35 | node_modules/
36 | jspm_packages/
37 |
38 | # Typescript v1 declaration files
39 | typings/
40 |
41 | # Optional npm cache directory
42 | .npm
43 |
44 | # Optional eslint cache
45 | .eslintcache
46 |
47 | # Optional REPL history
48 | .node_repl_history
49 |
50 | # Output of 'npm pack'
51 | *.tgz
52 |
53 | # Yarn Integrity file
54 | .yarn-integrity
55 |
56 | # dotenv environment variables file
57 | .env
58 |
59 | .cache/
60 | public
61 | yarn-error.log
62 | .DS_Store
63 | .env.*
64 | !.env.GATSBY_CONCURRENT_DOWNLOAD
65 | .DS_Store
66 |
67 | .wordpress-cache
68 |
--------------------------------------------------------------------------------
/.prettierrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | endOfLine: "lf",
3 | semi: false,
4 | singleQuote: false,
5 | tabWidth: 2,
6 | trailingComma: "es5",
7 | overrides: [
8 | {
9 | // This file uses semicolons. It's needed here because `documentation`
10 | // package (used to parse jsdoc and provide content for API reference pages)
11 | // behaviour is inconsistent when not using semicolons after
12 | // object declarations.
13 | files: ["**/api-node-helpers-docs.js"],
14 | options: {
15 | semi: true,
16 | },
17 | },
18 | ],
19 | }
20 |
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "0.2.0",
3 | "configurations": [
4 | {
5 | "name": "Gatsby develop",
6 | "type": "node",
7 | "request": "launch",
8 | "protocol": "inspector",
9 | "program": "${workspaceRoot}/node_modules/gatsby/dist/bin/gatsby",
10 | "args": ["develop"],
11 | "stopOnEntry": false,
12 | "runtimeArgs": ["--nolazy"],
13 | "sourceMaps": false
14 | },
15 | {
16 | "name": "Gatsby build",
17 | "type": "node",
18 | "request": "launch",
19 | "protocol": "inspector",
20 | "program": "${workspaceRoot}/node_modules/gatsby/dist/bin/gatsby",
21 | "args": ["build"],
22 | "stopOnEntry": false,
23 | "runtimeArgs": ["--nolazy"],
24 | "sourceMaps": false
25 | }
26 | ]
27 | }
28 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 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 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # [ARCHIVED] gatsby-source-wordpress V4 (alpha) starter
2 |
3 | This starter has been archived. Please visit the [source plugin quick start](https://github.com/gatsbyjs/gatsby-source-wordpress-experimental/blob/master/docs/getting-started.md#quick-start) to find an official Gatsby WP starter.
4 |
5 | This starter uses an early alpha version of the upcoming `gatsby-source-wordpress@v4`. You can find rough documentation for that package [here](https://github.com/gatsbyjs/gatsby-source-wordpress-experimental).
6 |
7 | ## Installation
8 |
9 | Follow along at the [alpha docs installation guide](https://github.com/gatsbyjs/gatsby-source-wordpress-experimental/blob/master/docs/getting-started.md#quick-start).
10 |
11 | ## Known issues
12 |
13 | - This starter doesn't build it's Styled components properly
14 | - The paginated blog on the homepage isn't offsetting posts properly
15 | - Probably other things :p
16 |
17 | ## Links
18 |
19 | - [gatsby-source-wordpress-experimental](https://github.com/gatsbyjs/gatsby-source-wordpress-experimental)
20 | - [wpgatsby](https://github.com/gatsbyjs/wp-gatsby)
21 |
--------------------------------------------------------------------------------
/WordPress/plugins/wp-gatsby.0.4.17.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TylerBarnes/using-gatsby-source-wordpress-experimental/3aea0042f0005878c601d458c1e4a70048a86c70/WordPress/plugins/wp-gatsby.0.4.17.zip
--------------------------------------------------------------------------------
/WordPress/plugins/wp-graphql-0.13.1.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TylerBarnes/using-gatsby-source-wordpress-experimental/3aea0042f0005878c601d458c1e4a70048a86c70/WordPress/plugins/wp-graphql-0.13.1.zip
--------------------------------------------------------------------------------
/gatsby-config.js:
--------------------------------------------------------------------------------
1 | require("dotenv").config({
2 | path: `.env.GATSBY_CONCURRENT_DOWNLOAD`,
3 | })
4 |
5 | // require .env.development or .env.production
6 | require("dotenv").config({
7 | path: `.env.${process.env.NODE_ENV}`,
8 | })
9 |
10 | module.exports = {
11 | plugins: [
12 | `gatsby-plugin-sharp`,
13 | {
14 | resolve: `gatsby-source-filesystem`,
15 | options: {
16 | name: `images`,
17 | path: `${__dirname}/src/assets/images`,
18 | },
19 | },
20 | {
21 | resolve: `gatsby-source-wordpress-experimental`,
22 | options: {
23 | url:
24 | process.env.WPGRAPHQL_URL ||
25 | `https://dev-gatsby-source-wordpress-v4.pantheonsite.io/graphql`,
26 | verbose: true,
27 | develop: {
28 | hardCacheMediaFiles: true,
29 | },
30 | debug: {
31 | graphql: {
32 | writeQueriesToDisk: true,
33 | },
34 | },
35 | type: {
36 | Post: {
37 | limit:
38 | process.env.NODE_ENV === `development`
39 | ? // Lets just pull 50 posts in development to make it easy on ourselves.
40 | 50
41 | : // and we don't actually need more than 5000 in production for this particular site
42 | 5000,
43 | },
44 | },
45 | },
46 | },
47 | `gatsby-plugin-chakra-ui`,
48 | `gatsby-transformer-sharp`,
49 | {
50 | resolve: "gatsby-plugin-react-svg",
51 | options: {
52 | rule: {
53 | include: /\.inline\.svg$/, // See below to configure properly
54 | },
55 | },
56 | },
57 | `gatsby-plugin-netlify-cache`,
58 | ],
59 | }
60 |
--------------------------------------------------------------------------------
/gatsby-node.js:
--------------------------------------------------------------------------------
1 | const { resolve } = require(`path`)
2 | const path = require(`path`)
3 | const glob = require(`glob`)
4 | const chunk = require(`lodash/chunk`)
5 | const { dd } = require(`dumper.js`)
6 |
7 | const getTemplates = () => {
8 | const sitePath = path.resolve(`./`)
9 | return glob.sync(`./src/templates/**/*.js`, { cwd: sitePath })
10 | }
11 |
12 | //
13 | // @todo move this to gatsby-theme-wordpress
14 | exports.createPages = async ({ actions, graphql, reporter }) => {
15 | const templates = getTemplates()
16 |
17 | const {
18 | data: {
19 | allWpContentNode: { nodes: contentNodes },
20 | },
21 | } = await graphql(/* GraphQL */ `
22 | query ALL_CONTENT_NODES {
23 | allWpContentNode(
24 | sort: { fields: modifiedGmt, order: DESC }
25 | filter: { nodeType: { ne: "MediaItem" } }
26 | ) {
27 | nodes {
28 | nodeType
29 | uri
30 | id
31 | }
32 | }
33 | }
34 | `)
35 |
36 | const contentTypeTemplateDirectory = `./src/templates/single/`
37 | const contentTypeTemplates = templates.filter((path) =>
38 | path.includes(contentTypeTemplateDirectory)
39 | )
40 |
41 | await Promise.all(
42 | contentNodes.map(async (node, i) => {
43 | const { nodeType, uri, id } = node
44 | // this is a super super basic template hierarchy
45 | // this doesn't reflect what our hierarchy will look like.
46 | // this is for testing/demo purposes
47 | const templatePath = `${contentTypeTemplateDirectory}${nodeType}.js`
48 |
49 | const contentTypeTemplate = contentTypeTemplates.find(
50 | (path) => path === templatePath
51 | )
52 |
53 | if (!contentTypeTemplate) {
54 | return
55 | }
56 |
57 | await actions.createPage({
58 | component: resolve(contentTypeTemplate),
59 | path: uri,
60 | context: {
61 | id,
62 | nextPage: (contentNodes[i + 1] || {}).id,
63 | previousPage: (contentNodes[i - 1] || {}).id,
64 | },
65 | })
66 | })
67 | )
68 |
69 | // create the homepage
70 | const {
71 | data: { allWpPost },
72 | } = await graphql(/* GraphQL */ `
73 | {
74 | allWpPost(sort: { fields: modifiedGmt, order: DESC }) {
75 | nodes {
76 | uri
77 | id
78 | }
79 | }
80 | }
81 | `)
82 |
83 | const perPage = 10
84 | const chunkedContentNodes = chunk(allWpPost.nodes, perPage)
85 |
86 | await Promise.all(
87 | chunkedContentNodes.map(async (nodesChunk, index) => {
88 | const firstNode = nodesChunk[0]
89 | const page = index + 1
90 | const offset = perPage * index
91 |
92 | await actions.createPage({
93 | component: resolve(`./src/templates/index.js`),
94 | path: page === 1 ? `/blog/` : `/blog/${page}/`,
95 | context: {
96 | firstId: firstNode.id,
97 | page: page,
98 | offset: offset,
99 | totalPages: chunkedContentNodes.length,
100 | perPage,
101 | },
102 | })
103 | })
104 | )
105 | }
106 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "using-gatsby-source-wordpress-experimental",
3 | "description": "Gatsby example site using gatsby-source-wordpress@next",
4 | "license": "MIT",
5 | "version": "0.0.1",
6 | "author": {
7 | "name": "Tyler",
8 | "email": "tyler@gatsbyjs.com"
9 | },
10 | "scripts": {
11 | "develop": "gatsby develop",
12 | "clean": "gatsby clean",
13 | "build": "gatsby build",
14 | "clean-develop": "gatsby clean && gatsby develop",
15 | "clean-build": "gatsby clean && gatsby build",
16 | "start": "npm run develop",
17 | "serve": "gatsby serve"
18 | },
19 | "dependencies": {
20 | "@chakra-ui/core": "^0.8.0",
21 | "@emotion/core": "^10.0.35",
22 | "@emotion/styled": "^10.0.27",
23 | "add": "^2.0.6",
24 | "dotenv": "^8.2.0",
25 | "emotion-theming": "^10.0.27",
26 | "gatsby": "^2.24.37",
27 | "gatsby-image": "^2.4.20",
28 | "gatsby-plugin-chakra-ui": "^0.1.4",
29 | "gatsby-plugin-netlify-cache": "^1.2.0",
30 | "gatsby-plugin-react-svg": "^3.0.0",
31 | "gatsby-plugin-sharp": "^2.6.38",
32 | "gatsby-source-filesystem": "^2.3.32",
33 | "gatsby-source-wordpress-experimental": "^1.5.3",
34 | "gatsby-transformer-sharp": "2.5.16",
35 | "gatsby-wordpress-experimental-inline-images": "^0.0.3",
36 | "react": "^16.13.1",
37 | "react-dom": "^16.13.1",
38 | "react-paginate": "^6.5.0",
39 | "yarn": "^1.22.10"
40 | },
41 | "devDependencies": {
42 | "prettier": "^2.1.2"
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/assets/images/test.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TylerBarnes/using-gatsby-source-wordpress-experimental/3aea0042f0005878c601d458c1e4a70048a86c70/src/assets/images/test.png
--------------------------------------------------------------------------------
/src/assets/style.css:
--------------------------------------------------------------------------------
1 | .pagination {
2 | width: 100%;
3 | display: grid;
4 | grid-auto-flow: column;
5 | justify-items: center;
6 | align-items: center;
7 | }
8 | .pagination li {
9 | list-style: none;
10 | display: inline-block;
11 | }
12 |
13 | .pagination li:not(.next):not(.previous) a {
14 | padding: 15px;
15 | display: block;
16 | }
17 |
18 | .pagination .next {
19 | justify-self: end;
20 | }
21 |
22 | .pagination .previous {
23 | justify-self: start;
24 | }
25 |
--------------------------------------------------------------------------------
/src/assets/svg/gatsby.inline.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/components/header.js:
--------------------------------------------------------------------------------
1 | import React from "react"
2 | import { Heading, Box, Grid } from "@chakra-ui/core"
3 | import { Link } from "gatsby"
4 | import GatsbyLogo from "../assets/svg/gatsby.inline.svg"
5 |
6 | export default () => (
7 |