MCPcopy Create free account
hub / github.com/UI5/webcomponents / loadGist

Function loadGist

packages/website/src/components/Editor/githubAPI.js:60–94  ·  view source on GitHub ↗
(gistId)

Source from the content-addressed store, hash-verified

58 * Load and convert gist files to playground format
59 */
60export const loadGist = async (gistId) => {
61 try {
62 console.log(`loading gist: ${gistId}`);
63 const response = await fetch(`${NETLIFY_BASE_URL}/github-get-gist?id=${gistId}`, {
64 method: 'GET',
65 headers: {
66 'Content-Type': 'application/json'
67 }
68 });
69
70 if (!response.ok) {
71 throw new Error(`failed to load gist: ${response.status}`);
72 }
73
74 const gist = await response.json();
75 console.log(`gist loaded: ${gist.description}`, Object.keys(gist.files));
76
77 // convert gist files to playground format
78 const playgroundFiles = {};
79 Object.keys(gist.files).forEach(filename => {
80 const gistFile = gist.files[filename];
81 playgroundFiles[filename] = {
82 name: filename,
83 content: gistFile.content,
84 hidden: filename === 'playground-support.js'
85 };
86 });
87
88 console.log('converted playground files:', Object.keys(playgroundFiles));
89 return playgroundFiles;
90 } catch (error) {
91 console.error('failed to load gist:', error);
92 throw error;
93 }
94};

Callers 1

loadGistProjectFunction · 0.90

Calls 1

fetchFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…