How to create multiple copies of the site base off an API
See original GitHub issueSummary
So, have a very strange request here. We are looking for a way to create copies of the site that are all powered by an API. I’m not concerned with consuming an API (that is fairly straight forward), but where I’m getting stuck is how would I build multiple versions of the site.
Example API Response:
[
{
"siteName": "Master Site",
"slug": null
},
{
"siteName": "User Site 1",
"slug": "/user-site-1"
},
{
"siteName": "User Site 2",
"slug": "/user-site-2"
}
]
Not sure if this is the idea structure, but we could end up with something like this:
/public
- index.html
- js
/sites
- /user-site-1
- index.html -js
- /user-site-2
- index.html -js
- /user-site-1
I’m guessing we would want to somehow interject this into the gatsby-node file, but again, never completed anything like this before, so not sure it’s 100% doable.
Thanks,
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
RESTful way to create multiple items in one request
I think a Batch API (from Google, Facebook, etc - @PuneetArora) is more useful when grouping several unrelated requests together. Creating a request...
Read more >How to Use an API: Just the Basics 2022 | TechnologyAdvice
Ever wonder what an API is or how to use one? APIs allow one program to request data from another. Learn more about...
Read more >Create Modern SharePoint Sites using REST - Microsoft Learn
The base URL for the REST commands is _api/SPSiteManager . Create a modern site. Using the following REST API you can create both...
Read more >Introduction to web APIs - Learn web development | MDN
At this point, you should have a good idea of what APIs are, how they work, and what you can do with them...
Read more >Creating an API | Postman Learning Center
Use a collection as a starting point for your API. Select a collection in your workspace you want to use and add a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@josefaidt @DSchau
Thanks for all your help, really appreciate it!
@josefaidt completely agree.
@whnunlife I’d recommend checking out Gatsby Themes.
In this example, you’d define a base Gatsby theme that establishes the data layer and visual theme (or feel free to structure as a parent/child theme), and then you’d re-use this theme whenever you’d like a site with a similar look and feel.
Without themes–you could do this too, but it’d be a bit more involved and would likely use
pathPrefix
and (multiple) custom builds and copy steps. It’s doable, but not quite as clean.Going to close this as answered (and thanks @josefaidt for the assistance here!), but please feel free to reply if we could shed some light on anything else.
Additionally, I’ll offer a pair programming session if that’s helpful and you’d like a little extra assistance!