mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-27 05:28:41 +00:00
feat: support github: links
This commit is contained in:
parent
d8843e6057
commit
d7b82edae3
@ -104,10 +104,18 @@ export const loadGithubSamples = async (path, nameFn) => {
|
|||||||
|
|
||||||
export const samples = async (sampleMap, baseUrl = sampleMap._base || '') => {
|
export const samples = async (sampleMap, baseUrl = sampleMap._base || '') => {
|
||||||
if (typeof sampleMap === 'string') {
|
if (typeof sampleMap === 'string') {
|
||||||
|
if (sampleMap.startsWith('github:')) {
|
||||||
|
const [_, path] = sampleMap.split('github:');
|
||||||
|
sampleMap = `https://raw.githubusercontent.com/${path}/strudel.json`;
|
||||||
|
}
|
||||||
const base = sampleMap.split('/').slice(0, -1).join('/');
|
const base = sampleMap.split('/').slice(0, -1).join('/');
|
||||||
return fetch(sampleMap)
|
return fetch(sampleMap)
|
||||||
.then((res) => res.json())
|
.then((res) => res.json())
|
||||||
.then((json) => samples(json, baseUrl || json._base || base));
|
.then((json) => samples(json, baseUrl || json._base || base))
|
||||||
|
.catch((error) => {
|
||||||
|
console.error(error);
|
||||||
|
throw new Error(`error loading "${sampleMap}"`);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
sampleCache.current = {
|
sampleCache.current = {
|
||||||
...sampleCache.current,
|
...sampleCache.current,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user