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

Implement first pass of MDXs #507

Closed
wants to merge 2 commits into from
Closed

Implement first pass of MDXs #507

wants to merge 2 commits into from

Conversation

johno
Copy link
Member

@johno johno commented Apr 10, 2019

This implements the basic idea of MDXs. Though
we still need to figure out how to best handle
the layout mechanism.

cc/ @ChristopherBiscardi, @jxnblk, @timneutkens


Related #454

This implements the basic idea of MDXs. Though
we still need to figure out how to best handle
the layout mechanism.

cc/ @ChristopherBiscardi, @jxnblk, @timneutkens

---

Related #454
@vercel
Copy link

vercel bot commented Apr 10, 2019

This pull request is automatically deployed with Now.
To access deployments, click Details below or on the icon next to each push.

`const MDXSLayout = ${
layout
? layout.value
.replace(/^export\s+default\s+/, '')
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should prolly make this a shared util.

)

const defaultExport = `
const MDXSWrapper = props => [
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we could actually make this the MDXLayout?

```sh
npm install --save remark-mdxs
```

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From a usage standpoint, is the thinking that you would use something like a separate webpack loader rule that only parses .mdxs files while handling .mdx files like any other?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's the idea 👍

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems like it will turn out to be kind of unfortunate. It means we can't delineate between MDX content and MDXS content when fetching from remote sources that use text/markdown content types (mdx still doesn't have it's own entry in the mime-db and even if it did, we're going to want compat with markdown types from headless CMSs anyway).

Since every MDXs document is technically a valid MDX document, I'd much rather see a const export used to specify intent to be MDXs content.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, that's a good point 🤔. I'd mostly been thinking about local fs. How do you think intent for MDXs should be expressed?

Something like?:

export const MDXS = true

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah this is the approach I landed on as well. I think that the "first MDX file" in an MDXs document can be used as the "global exports" (compared to exports defined in subsequent "files"), so you'd end up with something like this where the first MDX doesn't have any content, but is just imports/exports.

// global export
export const MDXS = true
---
// file-local export
export const slideLayout = SomeComponent
# some slide
---
# another slide

packages/mdx/index.js Outdated Show resolved Hide resolved
const remove = require('unist-util-remove')
const {toJSX} = require('@mdx-js/mdx/mdx-hast-to-jsx')

module.exports = function({delimiter = 'hr'}) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, I'm using thematicBreak in @mdx-deck/mdx-plugin but with the way the delimiter is used below will either hr or thematicBreak work?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As is it won't work because we're operating on MDXHAST (since it's acting as a custom compiler for MDX). But it might make sense to make MDXS more standalone and not use mdx core and remark-mdx directly instead. That would allow us to operate on the MDXAST.

Copy link
Contributor

@karlhorky karlhorky Dec 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding these architectural things, if remark-mdxs (or a different implementation of MDXs) were to be implemented today, do either of you (or @ChristianMurphy or @wooorm) have any recommendations for trying to make a new MDXs PR for MDX v2? Eg. either how / where the PR should be submitted, whether MDXs should be "more standalone" like described above, etc?

@EricCote or @ProchaLu (or both) may take a shot at implementing something like this in the next weeks, see the link below. The first idea was to take the implementation in this PR and upgrade it to use MDX v2 APIs.

@vercel vercel bot temporarily deployed to staging April 10, 2019 21:43 Inactive
@johno johno mentioned this pull request Apr 16, 2019
31 tasks
@polarathene
Copy link

I'm not too familiar with the PR, but are you proposing to use --- for indicating the split between separate MDX docs? Isn't that meant to be treated as an


?

Does a user have to swap any markdown usage there directly for


markup to use this feature?

@johno johno added the 💎 v2 Issues related to v2 label Aug 22, 2019
@ChristianMurphy ChristianMurphy added 🗄 area/interface This affects the public interface 🧒 semver/minor This is backwards-compatible change 🙉 open/needs-info This needs some more info labels Dec 29, 2019
@johno
Copy link
Member Author

johno commented Jul 22, 2020

Going to close this for now, will likely reopen after MDX v2 ships.

@johno johno closed this Jul 22, 2020
@johno johno deleted the mdx-s branch July 22, 2020 19:20
@wooorm wooorm added 🤷 no/invalid This cannot be acted upon and removed 💎 v2 Issues related to v2 🙉 open/needs-info This needs some more info labels Jul 23, 2020
@karlhorky
Copy link
Contributor

@johno @ChristopherBiscardi @ChristianMurphy is there any work being done on slide decks / presentation decks now that v2 has shipped?

I only saw the comments and discussion from @benjaminpreiss in #454 and #2134

Would be amazing to have first-class support for slide decks from MDX! For now, mdx-deck, next-mdx-deck and MDXP are not ideal to work with...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🗄 area/interface This affects the public interface 🤷 no/invalid This cannot be acted upon 🧒 semver/minor This is backwards-compatible change
Development

Successfully merging this pull request may close these issues.

7 participants