Source plugin for pulling a shop or brand's data into Gatsby from the Kushy API.
Add your shop or brand to the configuration file and Gatsby will import your profile data, menu, and all your reviews and photos into GraphQL.
Great for creating a website or landing page for a dispensary or brand.
- Demo
- Example site source code
npm install --save gatsby-source-kushy
- Add the plugin to
gatsby-config.js
:
{
resolve: 'gatsby-source-kushy',
options: {
// Access the shops or brands section?
section: 'shops',
// The slug of your shop/brand
slug: 'chronic-pain-relief-center',
// This helps the source plugin use the Kushy API to find your shop
// e.g. http://api.kushy.net/v1/<section>/?filter[slug]=<slug>
// See Kushy API docs for more info on querying shop data
},
},
gatsby develop
- Use the GraphiQL browser to query Kushy data
The plugin creates an endpoint called KushyPost
and allKushyPost
. You query KushyPost
for individual posts and filter by an ID or slug. And you query allKushyPost
for all imported posts.
All the parameters from the API are plugged into GraphQL, so if an API endpoint has a avatar
property, you can query GraphQL for it.
{
allKushyPost{
edges {
node {
id
name
featured_img
avatar
location {
latitude
longitude
address
state
city
postal_code
country
}
rating
featured
verified
}
}
}
}
{
allKushyReview {
edges {
node{
id
status
post_id
user_id
rating
useful
dank
funny
review
created_at {
date
}
updated_at {
date
}
includes {
user {
id
name
username
avatar
}
}
}
}
}
}
{
allKushyMenu {
edges {
node{
id
product {
id
name
slug
categories
avatar
featured_img
}
pricing {
pricing_type
list_price
sale_price
half_gram
one_gram
two_grams
eighth_ounce
quarter_ounce
half_ounce
ounce
quarter_pound
half_pound
pound
}
cannabinoids {
thc
cbd
cbn
}
}
}
}
}
{
allKushyPhoto {
edges {
node {
id
image
caption
user_id
post_id
featured
created_at{
date
timezone
}
updated_at{
date
timezone
}
}
}
}
}
- [✅] - Allow users to add a config for section and ID to load a specific shop/brand.
- [✅] - Add endpoint for shop/brand menu (
KushyMenu
/allKushyMenu
) - [] - Add endpoint for shop/brand photos (
KushyPhotos
/allKushyPhotos
) - [✅] - Add endpoint for shop/brand reviews (
KushyReviews
/allKushyReviews
)
- [] - Create async function to load all pages from API, currently only loads first (see: getPages())
- [] - Create helper function to download all loaded media into cache (see: downloadMediaFiles())