Skip to content

Commit 3942e7e

Browse files
Changed code block conditionals as it was pre-loading the boolean into the code before rendering the code
1 parent 5537b76 commit 3942e7e

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/plugin/CodeBlock.vue

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,16 @@
7272
:style="preTagStyles"
7373
>
7474
<code
75+
v-if="prismPlugin"
7576
:class="`language-${props.lang} ${browserWindow ? 'v-code-block--code-browser' : ''} ${highlightjs ? 'hljs' : ''}`"
7677
:style="codeTagStyles"
77-
v-html="!prismPlugin ? renderedCode : false"
78-
v-text="prismPlugin ? computedCode : false"
78+
v-text="computedCode"
79+
></code>
80+
<code
81+
v-else
82+
:class="`language-${props.lang} ${browserWindow ? 'v-code-block--code-browser' : ''} ${highlightjs ? 'hljs' : ''}`"
83+
:style="codeTagStyles"
84+
v-html="renderedCode"
7985
></code>
8086
</pre>
8187
</div>
@@ -203,7 +209,7 @@ const props = defineProps({
203209
prismjs: {
204210
type: Boolean,
205211
required: false,
206-
default: true,
212+
default: false,
207213
},
208214
prismPlugin: {
209215
type: Boolean,
@@ -399,6 +405,10 @@ onMounted(() => {
399405
400406
// -------------------------------------------------- Methods //
401407
function checkLibrary(): void {
408+
if (!props.prismjs && !props.highlightjs) {
409+
throw new Error('[vue3-code-block]: You must set either the prismjs or highlightjs props.');
410+
}
411+
402412
if (props.prismjs && props.highlightjs) {
403413
throw new Error('[vue3-code-block]: You cannot have both prismjs and highlightjs props set at the same time.');
404414
}

0 commit comments

Comments
 (0)