Hey everyone,
So I’ve been trying to experiment with the new Custom Embeds SDK and I’m trying to gain some clarity on how to go about using it.
I’ve gone over the docs, did a couple experiments using the Studio editor and IDE and here are my questions that the docs could not answer:
Importing a function that implements any of the SDKs methods:
So, the SDK is a backend module. Based on my experiments, it seems you’re needing to call these methods in frontend code. So, you would obviously need to use a webMethod and export it. Yet, the docs do not mention that nor do the code examples reflect this. So, is this the proper use? Or am I missing something?
Duplicated embeds on publishing site
When you publish your site, each time you publish you create a new embed. So you end up with essentially the same embed being created over and over, albeit a new instance with a its own id. Is this intended? Should I be running a check to see if the embed has already been created somehow?
I think that is pretty much all I have at the moment. Hopefully I can gain some insight on this new SDK. Thank you in advance for your time!
This video from @thewixwiz might interest you - https://www.youtube.com/watch?v=wx_vuc-bsPo&t=1s
Generally speaking, anything that runs in the backend will either need triggering by:
- Another backend function
- Something on the frontend (e.g. a button click)
The docs tend to give the foundations, and allow you to build upon it.
If you’re simply calling this in the onReady - these seems like expected behaviour. Once the embed has been created, it’s been created for the site. Subsequent calls to the function will create new embeds.
You’ll likely want updateCustomEmbed()
if you’re looking to make changes to an existing embed.
The best example of how I imagine this would be used, is a custom admin dashboard that allows site contributors to create and then subsequentlly update embeds on a site in an easy to use interface
1 Like
Alright I have a couple more questions. I’m not sure if it’s preferred that I make a new post for these but here goes @noahlovell:
-
Is it possible to link to a js file and set it as the script src? I’ve tested this by linking a js file from GH with a simple console message and while the script tag is showing up in the live sites html, nothing seems to be happening. I figured I’d at least get an error message in the logs regarding it.
-
Is part of the idea of this api to allow devs to create a means to create embeds via a custom dashboard page or maybe an admin page within a site?