1
0
Fork 0
freesewing/sites/shared/components/yaml.mjs

16 lines
459 B
JavaScript
Raw Normal View History

2022-01-28 16:57:07 +01:00
import React from 'react'
2023-02-05 16:49:36 +01:00
import { Highlight } from 'shared/components/mdx/highlight.mjs'
2022-01-28 16:57:07 +01:00
import hljs from 'highlight.js/lib/common'
import yaml from 'js-yaml'
export const Yaml = (props) => {
2022-01-28 16:57:07 +01:00
let code
if (props.json) code = yaml.dump(JSON.parse(props.json))
else if (props.js) code = yaml.dump(props.js)
else code = props.children
return (
<Highlight {...props} language="yaml" raw={hljs.highlight(code, { language: 'yaml' }).value} />
)
2022-01-28 16:57:07 +01:00
}