feat: can now load samples via url

This commit is contained in:
Felix Roos 2022-11-02 12:29:34 +01:00
parent 240a8930ef
commit cf7c734778

View File

@ -102,7 +102,13 @@ export const loadGithubSamples = async (path, nameFn) => {
*
*/
export const samples = (sampleMap, baseUrl = sampleMap._base || '') => {
export const samples = async (sampleMap, baseUrl = sampleMap._base || '') => {
if (typeof sampleMap === 'string') {
const base = sampleMap.split('/').slice(0, -1).join('/');
return fetch(sampleMap)
.then((res) => res.json())
.then((json) => samples(json, json._base || base));
}
sampleCache.current = {
...sampleCache.current,
...Object.fromEntries(