open-vault/website/components/before-after-diagram/server.js
Bryce Kalow 45dfa2dd02
web: migrate to web platform- packages (#12118)
* migrate usages of nextjs-scripts to platform packages

* Updates hashi packages
2021-07-27 18:43:40 -04:00

32 lines
1.1 KiB
JavaScript

import md from '@hashicorp/platform-markdown-utils/markdown-to-html'
import mdInline from '@hashicorp/platform-markdown-utils/markdown-to-inline-html'
export default async function processBeforeAfterDiagramProps(props) {
const { beforeHeadline, beforeContent, afterHeadline, afterContent } = props
// Transform headline markdown to HTML, for inline bold / italic support
props.beforeHeadline = await mdInline(beforeHeadline)
props.afterHeadline = await mdInline(afterHeadline)
// Transform content markdown to HTML, using custom type classes
const contentOptions = {
contentPlugins: {
pluginOptions: {
typography: {
map: {
h1: 'g-type-label',
h2: 'g-type-label',
h3: 'g-type-label',
h4: 'g-type-label',
h5: 'g-type-label',
h6: 'g-type-label',
p: 'g-type-body-small',
li: 'g-type-body-small',
},
},
},
},
}
props.beforeContent = await md(beforeContent, contentOptions)
props.afterContent = await md(afterContent, contentOptions)
return props
}