Skip to content

Instantly share code, notes, and snippets.

@rexxars
Created February 14, 2018 11:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rexxars/06523a8fae0d52a9df0aebe9b00c4943 to your computer and use it in GitHub Desktop.
Save rexxars/06523a8fae0d52a9df0aebe9b00c4943 to your computer and use it in GitHub Desktop.
Temporary "block content to vue"
<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