This repository has been archived by the owner on May 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from pvpg/master
Migration to gatsby-source-prismic
- Loading branch information
Showing
30 changed files
with
38,314 additions
and
8,939 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"env": { | ||
"browser": true, | ||
"es6": true | ||
}, | ||
"extends": [ | ||
"plugin:react/recommended", | ||
"airbnb" | ||
], | ||
"globals": { | ||
"Atomics": "readonly", | ||
"SharedArrayBuffer": "readonly" | ||
}, | ||
"parserOptions": { | ||
"ecmaFeatures": { | ||
"jsx": true | ||
}, | ||
"ecmaVersion": 2018, | ||
"sourceType": "module" | ||
}, | ||
"plugins": [ | ||
"react" | ||
], | ||
"rules": { | ||
"no-underscore-dangle": "off", | ||
"no-use-before-define": "off", | ||
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }], | ||
"react/no-array-index-key": "off", | ||
"react/prop-types": "off", | ||
"semi": ["error", "never"], | ||
"react/destructuring-assignment": "off", | ||
"jsx-a11y/click-events-have-key-events":"off", | ||
"jsx-a11y/no-static-element-interactions":"off", | ||
"react/no-access-state-in-setstate":"off" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"endOfLine": "lf", | ||
"semi": false, | ||
"singleQuote": false, | ||
"singleQuote": true, | ||
"tabWidth": 2, | ||
"trailingComma": "es5" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
const { registerLinkResolver } = require('gatsby-source-prismic-graphql'); | ||
const { linkResolver } = require('./src/utils/linkResolver'); | ||
|
||
registerLinkResolver(linkResolver); | ||
import * as React from 'react' | ||
import { PreviewStoreProvider } from 'gatsby-source-prismic' | ||
|
||
const wrapRootElement = ({ element }) => ( | ||
<PreviewStoreProvider>{element}</PreviewStoreProvider> | ||
) | ||
|
||
export default wrapRootElement |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,63 @@ | ||
const { apiEndpoint } = require('./prismic-configuration'); | ||
var repo = /([^\/]+)\.prismic\.io/.exec(apiEndpoint); | ||
const { prismicRepo, releaseID, accessToken } = require('./prismic-configuration') | ||
const linkResolver = require('./src/utils/linkResolver') | ||
|
||
const repoName = process.env.PRISMIC_REPO_NAME || prismicRepo | ||
const apiKey = process.env.PRISMIC_API_KEY || accessToken | ||
const prismicReleaseID = process.env.PRISMIC_RELEASE_ID || releaseID | ||
|
||
const authorSchema = require('./custom_types/author.json') | ||
const blogHomeSchema = require('./custom_types/blog_home.json') | ||
const blogPostSchema = require('./custom_types/blog_post.json') | ||
const homepageSchema = require('./custom_types/homepage.json') | ||
const landingPageSchema = require('./custom_types/landing_page.json') | ||
const layoutSchema = require('./custom_types/layout.json') | ||
const productSchema = require('./custom_types/product.json') | ||
const productsSchema = require('./custom_types/products.json') | ||
|
||
const gastbySourcePrismicConfig = { | ||
resolve: 'gatsby-source-prismic', | ||
options: { | ||
repositoryName: repoName, | ||
accessToken: apiKey, | ||
releaseID: prismicReleaseID, | ||
prismicToolbar: true, | ||
linkResolver: () => linkResolver, | ||
schemas: { | ||
author: authorSchema, | ||
blog_home: blogHomeSchema, | ||
blog_post: blogPostSchema, | ||
homepage: homepageSchema, | ||
landing_page: landingPageSchema, | ||
layout: layoutSchema, | ||
product: productSchema, | ||
products: productsSchema, | ||
}, | ||
}, | ||
} | ||
|
||
module.exports = { | ||
siteMetadata: { | ||
title: `Coffee Shop Demo`, | ||
description: `Gatsby + Prismic!`, | ||
author: `@raulg`, | ||
title: 'Coffee Shop Demo', | ||
description: 'Gatsby + Prismic!', | ||
}, | ||
flags: { | ||
DEV_SSR: false, | ||
}, | ||
plugins: [ | ||
`gatsby-plugin-react-helmet`, | ||
{ | ||
resolve: `gatsby-source-prismic-graphql`, | ||
options: { | ||
repositoryName: repo[1], | ||
path: '/preview', | ||
previews: true, | ||
//accessToken: '...', | ||
pages: [{ | ||
type: 'Product', | ||
match: '/products/:uid', | ||
path: '/product', | ||
component: require.resolve('./src/templates/product.js') | ||
},{ | ||
type: 'Blog_post', | ||
match: '/blog/:uid', | ||
path: '/blogpost', | ||
component: require.resolve('./src/templates/blogPost.js') | ||
}] | ||
} | ||
}, | ||
`gatsby-plugin-sass`, | ||
gastbySourcePrismicConfig, | ||
'gatsby-plugin-react-helmet', | ||
'gatsby-plugin-sass', | ||
{ | ||
resolve: `gatsby-plugin-manifest`, | ||
resolve: 'gatsby-plugin-manifest', | ||
options: { | ||
name: `gatsby-starter-default`, | ||
short_name: `starter`, | ||
start_url: `/`, | ||
background_color: `#663399`, | ||
theme_color: `#663399`, | ||
display: `minimal-ui`, | ||
icon: `src/images/gatsby-icon.png`, // This path is relative to the root of the site. | ||
name: 'gatsby-starter-default', | ||
short_name: 'starter', | ||
start_url: '/', | ||
background_color: '#663399', | ||
theme_color: '#663399', | ||
display: 'minimal-ui', | ||
icon: 'src/images/coffee.png', // This path is relative to the root of the site. | ||
}, | ||
}, | ||
// this (optional) plugin enables Progressive Web App + Offline functionality | ||
// To learn more, visit: https://gatsby.dev/offline | ||
// 'gatsby-plugin-offline', | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const path = require('path') | ||
|
||
exports.createPages = async ({ graphql, actions }) => { | ||
const { createPage } = actions | ||
|
||
const pages = await graphql(` | ||
{ | ||
allPrismicProduct { | ||
nodes { | ||
uid | ||
type | ||
url | ||
} | ||
} | ||
allPrismicBlogPost { | ||
nodes { | ||
uid | ||
type | ||
url | ||
} | ||
} | ||
} | ||
`) | ||
|
||
pages.data.allPrismicProduct.nodes.forEach((page) => { | ||
createPage({ | ||
path: page.url, | ||
component: path.resolve(__dirname, 'src/templates/ourProduct.js'), | ||
context: { ...page }, | ||
}) | ||
}) | ||
|
||
pages.data.allPrismicBlogPost.nodes.forEach((page) => { | ||
createPage({ | ||
path: page.url, | ||
component: path.resolve(__dirname, 'src/templates/blogPost.js'), | ||
context: { ...page }, | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import * as React from 'react' | ||
import { PreviewStoreProvider } from 'gatsby-source-prismic' | ||
|
||
const wrapRootElement = ({ element }) => ( | ||
<PreviewStoreProvider>{element}</PreviewStoreProvider> | ||
) | ||
|
||
export default wrapRootElement |
Oops, something went wrong.