By Nick DeJesus
@dayhaysoos
Resilient Coders
Please go make a theme
They can be:
Themes don't have to be about the rendering UI. You can create a theme strictly for data.
The magic happens with gatsby-node.js
gatsby-node.js
gatsby-node.js
exports.sourceNodes = ({actions}) => {
API CALL MADE HERE
actions.createNode(DATA FROM API CALL)
}
exports.createSchemaCustomization = ({actions}) => {
CREATE GRAPHQL DATA TYPES
}
npm publish <ENTER> <ENTER> <ENTER>
gatsby-config.js
yarn add the-thing-i-published
module.exports = {
plugins: ['the-thing-i-published']
}
UI Parent theme > gatsby-node.js
exports.createPages = ({actions}) => {
const { createPage } = actions
const itemQuery = await graphql(`
{
allItem {
nodes {
description
}
}
}
`)
const items = itemQuery.data.allItem.nodes
// FOR EACH ITEM CREATE A PAGE
items.forEach(item => createPage(item))
}
You can even combine themes and make that a theme on its own!
Anything inside the "src" directory can be shadowed
You can shadow a component, add props to it and extend it as well
Pragmas tell the compiler how to handle the contents of a file
const element = <h1 className="greeting">Hello, world!</h1>
const element = React.createElement(
"h1",
{ className: "greeting" },
"Hello, world!"
)
/** @jsx jsx */
import { jsx } from "theme-ui"
<button sx={{color: 'primary'}}>Some Button</button>
// theme.js
const theme = {
colors: {
primary: 'blue'
}
}
M O N O R E P O
Starter
Discord:
https://discord.gg/5Ts2Pkr