-
Notifications
You must be signed in to change notification settings - Fork 21
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
Add sandboxes to repo #6
Add sandboxes to repo #6
Conversation
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.
- would be nice to start using async/await in all these examples
- would be nice of this is matching the code style that all other projects have for JS, prettier + xo
sandbox-templates/react-markdown-with-create-react-app/src/index.js
Outdated
Show resolved
Hide resolved
sandbox-templates/react-markdown-with-create-react-app/src/App.js
Outdated
Show resolved
Hide resolved
Co-authored-by: Titus <[email protected]>
Is prettier set up in this repo? Here’s the config if not: https://github.com/unifiedjs/collective/blob/b6d6fc9ae19643a7a982f4fc0f3dc11b9be9eb1a/package.json#L25-L39. And I typically have |
Stackblitz can also be enabled with just a link right? In that case, 👍, better to not favor one particular vendor! |
e2f4d44
to
f35e86d
Compare
| remark only (for markdown to markdown) | [codesandbox](https://codesandbox.io/s/github/remarkjs/.github/tree/main/sandbox-templates/remark-with-parcel) | [stackblitz](https://stackblitz.com/github/remarkjs/.github-remark/tree/main/sandbox-templates/remark-with-parcel) | | ||
| remark and rehype (for markdown to html) | [codesandbox](https://codesandbox.io/s/github/remarkjs/.github/tree/main/sandbox-templates/remark-rehype-with-parcel) | [stackblitz](https://stackblitz.com/github/remarkjs/.github-remark/tree/main/sandbox-templates/remark-rehype-with-parcel) | | ||
| react-markdown | [codesandbox](https://codesandbox.io/s/github/remarkjs/.github/tree/main/sandbox-templates/react-markdown-with-create-react-app) | [stackblitz](https://stackblitz.com/github/remarkjs/.github-remark/tree/main/sandbox-templates/react-markdown-with-create-react-app) | |
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.
temporary links until merged
- https://codesandbox.io/s/github/ChristianMurphy/.github-remark/tree/sandbox-starters-in-repo/sandbox-templates/remark-with-parcel
- https://stackblitz.com/github/ChristianMurphy/.github-remark/tree/sandbox-starters-in-repo/sandbox-templates/remark-with-parcel
- https://codesandbox.io/s/github/ChristianMurphy/.github-remark/tree/sandbox-starters-in-repo/sandbox-templates/remark-rehype-with-parcel
- https://stackblitz.com/github/ChristianMurphy/.github-remark/tree/sandbox-starters-in-repo/sandbox-templates/remark-rehype-with-parcel
Added prettier and xo. |
sandbox-templates/react-markdown-with-create-react-app/src/app.js
Outdated
Show resolved
Hide resolved
build fails! |
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.
one nit.
Did you see my earlier comment on maybe using async/await?
XO warnings resolved |
Co-authored-by: Titus <[email protected]>
Parcel doesn't support top level await yet parcel-bundler/parcel#4028 |
Examples in remark packages now use a |
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.
fine!
sandbox-templates/react-markdown-with-create-react-app/package.json
Outdated
Show resolved
Hide resolved
updated to use an async main function |
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.
Good to have a top-level place to catch errors. I think it’s weird to not have it, but have it wrapping the await, so that it catches some errors but not others. How about this for the samples?
} | ||
} | ||
|
||
main() |
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.
main() | |
main().catch((errror) => { | |
document.querySelector('#error').textContent = String(error) | |
}) |
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.
Main itself has a try catch block for error catching.
I'm not sure there are any errors left from main for this to catch.
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.
The function body is currently wrapped in a try/catch. I’m assuming that people are going to change the function body and introduce errors outside the try/catch, resulting in uncaught exceptions
try { | ||
const file = await unified() | ||
.use(remarkParse) | ||
// Add any remark plugins here | ||
.use(remarkRehype) | ||
// Add any rehype plugins here | ||
.use(rehypeStringify) | ||
.process(sourceMarkdown) | ||
|
||
document.querySelector('#result').contentWindow.document.body.innerHTML = | ||
String(file) | ||
} catch (error) { | ||
document.querySelector('#error').textContent = error | ||
} |
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.
try { | |
const file = await unified() | |
.use(remarkParse) | |
// Add any remark plugins here | |
.use(remarkRehype) | |
// Add any rehype plugins here | |
.use(rehypeStringify) | |
.process(sourceMarkdown) | |
document.querySelector('#result').contentWindow.document.body.innerHTML = | |
String(file) | |
} catch (error) { | |
document.querySelector('#error').textContent = error | |
} | |
const file = await unified() | |
.use(remarkParse) | |
// Add any remark plugins here | |
.use(remarkRehype) | |
// Add any rehype plugins here | |
.use(rehypeStringify) | |
.process(sourceMarkdown) | |
document.querySelector('#result').contentWindow.document.body.innerHTML = | |
String(file) |
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.
🤷♂️ try {} catch {}
reads cleaner than .then
and .catch
chaining. It would feel weird to make the example less clear 🤔
Hi! This was closed. Team: If this was merged, please describe when this is likely to be released. Otherwise, please add one of the |
Initial checklist
Description of changes
related to mdx-js/.github#16
this applies the same approach, moving sandbox examples into the repository for easier maintenance and versioning.