question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to create multiple copies of the site base off an API

See original GitHub issue

Summary

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

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:closed
  • Created 5 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
james-lukensowcommented, Mar 5, 2019

@josefaidt @DSchau

Thanks for all your help, really appreciate it!

1reaction
DSchaucommented, Mar 5, 2019

@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!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found