Skip to content

Instantly share code, notes, and snippets.

@brunosabot
Created February 27, 2022 12:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brunosabot/cbfecba9765c20c48a25815df7cb2578 to your computer and use it in GitHub Desktop.
Save brunosabot/cbfecba9765c20c48a25815df7cb2578 to your computer and use it in GitHub Desktop.
async function loadAndTransformGist(parent: IAST, item: IAST): Promise<IAST> {
if (item.value === undefined) return item;
const gist = item.value.substring(5).trim();
const [data, jsonData] = await loadGist(gist);
if (data.length === 1) {
return getGistAST(jsonData.files[0], data[0]);
}
return {
type: parent.type,
children: data.map((file, index) =>
getGistAST(jsonData.files[index], file)
),
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment