Created
September 12, 2016 02:58
-
-
Save wochap/f413e609168f70403c86ebdcd5287afc to your computer and use it in GitHub Desktop.
vue components
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> | |
<pre> | |
<code class="hljs" :class="hljsCode.language">{{{ hljsCode.value }}}</code> | |
</pre> | |
</template> | |
<script> | |
import hljs from 'highlight.js' | |
hljs.configure({ | |
tabReplace: ' ' | |
}) | |
export default { | |
props: [ | |
{ | |
name: 'code', | |
type: String, | |
default () { | |
return '' | |
} | |
} | |
], | |
computed: { | |
hljsCode () { | |
return hljs.highlightAuto(this.code) | |
} | |
} | |
} | |
</script> | |
<style lang="scss"> | |
// main.scss | |
// @import "~highlight.js/styles/atom-one-light.css"; | |
</style> |
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> | |
<article class="markdown-body" v-html="markdown | marked"></article> | |
</template> | |
<script> | |
import hljs from 'highlight.js' | |
import marked from 'marked' | |
export default { | |
props: [ | |
{ | |
name: 'markdown', | |
type: String, | |
default () { | |
return '' | |
} | |
} | |
], | |
filters: { | |
marked (code) { | |
return marked(code, { | |
langPrefix: 'hljs ', | |
highlight (code) { | |
return hljs.highlightAuto(code).value | |
} | |
}) | |
} | |
} | |
} | |
</script> | |
<style lang="scss"> | |
// main.scss | |
// @import "~github-markdown-css"; | |
.markdown-body { | |
padding-top: 2rem; | |
padding-bottom: 2rem; | |
} | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment