Skip to content

Instantly share code, notes, and snippets.

@joshuacox
Created May 30, 2022 16:17
Show Gist options
  • Save joshuacox/d2635f63797907a64a4194ac8f4f44a9 to your computer and use it in GitHub Desktop.
Save joshuacox/d2635f63797907a64a4194ac8f4f44a9 to your computer and use it in GitHub Desktop.
building a theme
#!/bin/bash
# This follows the building a theme tutorial and sets up everything for you
# https://www.gatsbyjs.com/tutorial/building-a-theme/
set -eux
TMP=$(mktemp -d)
cd $TMP
mkdir authoring-themes-tutorial
cd authoring-themes-tutorial
mkdir gatsby-theme-events site
cat > package.json << EOF
{
"private": true,
"workspaces": ["gatsby-theme-events", "site"]
}
EOF
cat > gatsby-theme-events/package.json << EOF
{
"name": "gatsby-theme-events",
"version": "1.0.0",
"main": "index.js",
"license": "MIT"
}
EOF
cat > gatsby-theme-events/index.js << EOF
// This file is intentionally empty — because the main field is pointing to index.js
EOF
cat > site/package.json << EOF
{
"private": true,
"name": "site",
"version": "1.0.0",
"license": "MIT",
"scripts": {
"build": "gatsby build",
"develop": "gatsby develop",
"clean": "gatsby clean"
}
}
EOF
yarn workspace site add gatsby react react-dom "gatsby-theme-events@*"
yarn workspace gatsby-theme-events add -P gatsby react react-dom
yarn workspaces info
cat > site/gatsby-config.js << EOF
module.exports = {
plugins: [
{
resolve: "gatsby-theme-events",
options: {},
},
],
}
EOF
mkdir gatsby-theme-events/data
cat > gatsby-theme-events/data/events.yml << EOF
- name: React Rally
location: Salt Lake City, UT
start_date: 2019-08-22
end_date: 2019-08-23
url: https://www.reactrally.com/
- name: DinosaurJS
location: Denver, CO
start_date: 2019-06-20
end_date: 2019-06-21
url: https://dinosaurjs.org/
- name: JSHeroes
location: Cluj-Napoca, Romania
start_date: 2020-04-23
end_date: 2020-04-24
url: https://jsheroes.io/
- name: The Lead Developer
location: Austin, TX
start_date: 2019-11-08
end_date: 2019-11-08
url: https://austin2019.theleaddeveloper.com/
EOF
yarn workspace gatsby-theme-events add gatsby-source-filesystem gatsby-transformer-yaml
cat > gatsby-theme-events/gatsby-config.js << EOF
module.exports = {
plugins: [
{
resolve: "gatsby-source-filesystem",
options: {
path: "data",
},
},
{
resolve: "gatsby-transformer-yaml",
options: {
typeName: "Event",
},
},
],
}
EOF
pwd
yarn workspace site develop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment