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

Allow static subset of jsx + some raw props #1

Closed
wants to merge 1 commit into from

Conversation

RichiCoder1
Copy link

A variation on this plugin that manually walks the tree an converts "static" attributes and objects to the props object. Downside of this is you can't pass in the things like javascript variables (does MDX even support that?) but to enable that, we'd also need to a plugin for the HAST -> JSX that can handle those cases in a robust way.

@RichiCoder1
Copy link
Author

For context, new output with the updated test.md looks like:

{
  "type": "root",
  "children": [
    {
      "type": "code",
      "lang": "jsx",
      "meta": "live startLine=1 forgivingString='string' title=\"test\" minHeight={100} style={{border: '1px solid red'}}",
      "value": "<Box>hello, world</Box>",
      "position": {
        "start": {
          "line": 1,
          "column": 1,
          "offset": 0
        },
        "end": {
          "line": 3,
          "column": 4,
          "offset": 141
        },
        "indent": [
          1,
          1
        ]
      },
      "props": {
        "live": true,
        "startLine": 1,
        "forgivingString": "string",
        "title": "test",
        "minHeight": 100,
        "style": {
          "border": "1px solid red"
        }
      }
    }
  ],
  "position": {
    "start": {
      "line": 1,
      "column": 1,
      "offset": 0
    },
    "end": {
      "line": 4,
      "column": 1,
      "offset": 143
    }
  }
}

@shawnbot
Copy link
Owner

Thanks for this, but I'm not looking for contributions at this point. This is very much a proof of concept for mdx-js/mdx#702, and after working through the static "evaluation" method I think that inserting the JSX props as-is (with support for key=valuekey="value" conversion, for backwards compatibility) would be better.

@shawnbot shawnbot closed this Aug 19, 2019
@RichiCoder1 RichiCoder1 deleted the static-subset branch August 19, 2019 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants