React-markdown: Feature request: Support yaml headers

Created on 6 Apr 2018  Â·  10Comments  Â·  Source: remarkjs/react-markdown

I found that it can't parse 'Github's Style Markdown' like this:
---
title: 2018-04-07
date: 2018-04-07 00:23:24
categories: some
---

🙋 typquestion

Most helpful comment

Hi, is there any progress on this one?

It would be good if yaml metadata could somehow end up as props or if there was the option to ignore it (i.e. not render)

All 10 comments

What do you expect this to render?

This looks like hugo post/content file metadata.

@rexxars I expect that the r-md can parse format in that context as metas.
origin:
image
result:
image

I want such rendered markdown format.
do you have solve this problem? or have anywhere can I get 'Github's Style?

Hi, is there any progress on this one?

It would be good if yaml metadata could somehow end up as props or if there was the option to ignore it (i.e. not render)

Would it be possible to implement this as a plugin? If so, I'd give it a try.

how I would want this to work… given the metadata in the above example…
```
const [title, setTitle] = useState("")
const [date, setDate] = useState("")
const [categories, setCategories] = useState([])

const metadataParser = (metadata) => {
metadata.title && setTitle(metadata.title)
metadata.date && setDate(Date.parse(metadata.date))
metadata.categories && setCategories(metadata.categories)
}

return (

{title}

{categories && categories.map((cat) => )}



)

More than likely, with the v5 branch. Have not looked into it.

I believe that if the "transforms plugin" PR pans out (https://github.com/rexxars/react-markdown/pull/305) this will not be necessary, vis a vis the remark-metadata plugin (https://github.com/temando/remark-metadata).

You should be able to do this with a plugin indeed.

Was this page helpful?
0 / 5 - 0 ratings