Last active
November 21, 2020 22:54
-
-
Save daaru00/0598eefa0d4357a8f7b73556622dd031 to your computer and use it in GitHub Desktop.
Storyblok rich text render component
This file contains 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 id="app"> | |
<!-- get page data --> | |
<vs-rich-text :document="doc" /> | |
</div> | |
</template> |
This file contains 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
import RichText from '~/components/layout/RichText' | |
Vue.component('vs-rich-text', RichText) | |
new Vue({ el: '#app' }) |
This file contains 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> | |
<!-- eslint-disable-next-line vue/no-v-html --> | |
<p v-html="rawHTML" /> | |
</template> | |
<script> | |
import StoryblokClient from 'storyblok-js-client' | |
const sb = new StoryblokClient({}) | |
export default { | |
props: { | |
document: { | |
type: Object, | |
default: () => ({}) | |
} | |
}, | |
computed: { | |
rawHTML () { | |
if (!this.document.content) { | |
return '' | |
} | |
return sb.richTextResolver.render(this.document) | |
} | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment