Created
February 14, 2018 11:33
-
-
Save rexxars/06523a8fae0d52a9df0aebe9b00c4943 to your computer and use it in GitHub Desktop.
Temporary "block content to vue"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div v-html="renderHtml(content)"></div> | |
</template> | |
<script> | |
const blocksToHtml = require("@sanity/block-content-to-html") | |
const h = blocksToHtml.h | |
const serializers = { | |
types: { | |
code: props => | |
h("pre", { className: props.node.language }, h("code", props.node.code)) | |
} | |
} | |
export default { | |
name: "BlockToHtml", | |
props: ["content"], | |
methods: { | |
renderHtml(item) { | |
return blocksToHtml({ | |
blocks: item, | |
serializers: serializers | |
}) | |
} | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment