Hacker Newsnew | past | comments | ask | show | jobs | submit | dtedesco1's commentslogin

> taking care of all the hairy details around `<CustomComponent>...</...>`

Precisely! Thank you.

Can you share more about what you have in mind for frontmatter? I don’t really understand the need/use cases yet.


Sorry to have missed your comment.

Basically:

    ---
    import foo, bar, baz
    ---
    # Markdown
    
     * Goes
     * <https://here.com>
eg: https://docs.github.com/en/contributing/writing-for-github-d... ... https://jekyllrb.com/docs/front-matter/ ... and google search for "rst yaml frontmatter"

If you take an `*.mdx` file and run it through a typical markdown renderer, you'd get something like... well... lemme give the counter-example: if you had the "dashes" delimiting your "frontmatter" from the document, you'd get something like:

    <hr>import foo, bar, baz<hr>\n<h1>Markdown</h1><ul><li>...etc...
...the critical part being to relatively unambiguously demarcate "junk" from "content" in the markdown ecosystem. In the far future when this project is but a forgotten memory of time, people can still just straight up render the markdown and "obviously" delete the stuff between the <hr's> up at the top.

The contrarian is that there's ambiguity as to when your `*.mdx` "import junk" stops and when the actual content starts. Do you stop parsing [for imports] after the first blank line? Do you stop parsing when you get a syntax error? Do you only parse lines that begin with [import ...]? What about [from ... import ...]?

More google searches: `http header demarcation rfc`, and eg: https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/...

...strong recommendation: demarcate "headers" from content (a-la HTTP). Your format effectively becomes `---\n $PROG_LANG_GOES_HERE ---\n $CONTENT_HERE`, and you slide 1000% into "pure HTTP":

    GET /foo.mdx

    Content-Type: application/mdx
    Date: 2020-10-10 01:02:34

    ---
    import SomeComponent
    ---
    <SomeComponent>My Header</SomeComponent>

     * Some
     * Content


Bingo!


Thanks for calling out. I’ve opened [an issue to look into this](https://github.com/dtedesco1/nextjs-markdown-boilerplate/iss...).


Awesome work. Very snappy and crisp. For this project, I’m still stuck in React hell though because I want to use React components XD


This is great! Thanks for sharing.


I actually previously used Jekyll! Built this largely because I want full React component functionality sometimes. Also I think Jelyll gave me some issues with routing that I didn’t like.


These are great for adding more flavor to md -> html, but I want to be able to use React components sometimes, not just JS/CSS.


You’re getting close. The biggest thing is that I want to be able to use React components sometimes and anywhere on the page. If you just want md -> html, there are of course much better options.


Intriguing. Does it render React components when you want to add them?


Ha! I would love that.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: