-
Notifications
You must be signed in to change notification settings - Fork 49
feat(docs): add node snippets locally #689
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Deploy Preview for openpayments-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
const gitRoot = execSync('git rev-parse --show-toplevel').toString().trim(); | ||
const snippetsPath = path.join(gitRoot, 'snippets'); | ||
const getChunk = async () => { | ||
if (source.startsWith('http')) { | ||
const data = await fetch(source).then((response) => response.text()); | ||
return data; | ||
} | ||
const data = await fs.readFile(path.join(snippetsPath, l, source), {encoding: "utf8"}) | ||
return data | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taken from @raducristianpopa's ChunkedSnippetExperimental
#653.
if (source.startsWith('http')) { | ||
const data = await fetch(source).then((response) => response.text()); | ||
return data; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now, still allowing the http
path to be fetched from the source
. This is to support the PHP snippets in the meantime, which will be done in a separate PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it looks good 😂
Description of changes
Moving all of the NodeJS snippets from https://github.com/interledger/open-payments-snippets to
snippets/node
, and updating theChunkedSnippet
component to use the local files, based off of #653.Fixes #668 | OPE-239
Required
Conditional