Skip to content
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

The ultimate docs codeblock #464

Closed
johno opened this issue Mar 12, 2019 · 2 comments
Closed

The ultimate docs codeblock #464

johno opened this issue Mar 12, 2019 · 2 comments
Labels
📚 area/docs This affects documentation

Comments

@johno
Copy link
Member

johno commented Mar 12, 2019

It'd be useful to build a powerful codeblock. The existing codeblock in MDX docs needs features like syntax highlighting, file name support, language labelling, live code editing, cut and paste, etc.

There are a wide array of different code block usages in the docs that could be more welcoming and include more information.

It should use the metastring for configuring different features and use the codeblock language to determine language type.

Implementation

This should likely be built as its own library because it could be usable by other folks/projects.

The language can be either JSX or MDX (for now) and uses the standard MD language feature of code fences.

    ```js
    I'm JS
    ```
Metastring Default Description
repl false Add the live code editor
title None Add a title above the rendered code
copy false Add icon to copy contents to the clipboard

Usage

    ```mdx repl=true title=posts/my-post.mdx
    I'm JS
    ```

Caveats

For the repl we can use react-live, but we will need to be able to strip out import and export statements in MDX files (via plugins).

Examples

@johno johno added the 📚 area/docs This affects documentation label Mar 12, 2019
@shawnbot
Copy link

Huge thumbs up from me on this one. I'd also (or alternatively) love it if the metastring could either support quoted values (I've had success using parse-pairs in code-blocks before MDX was a thing) or, better yet, any valid JSX props expression:

```mdx numericProp={1} booleanProp someOtherProp="a string"

In that case, couldn't you insert the metastring into the JSX as-is?

<MDXTag name="code" numericProp={1} booleanProp someOtherProp="a string">

@johno
Copy link
Member Author

johno commented Jul 31, 2019

We've begun work on this component in Theme UI, so I'm going to close this.

Related: system-ui/theme-ui#212

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📚 area/docs This affects documentation
Development

No branches or pull requests

2 participants