This is a project for displaying more beautiful and elegant code block in website based in Vue 3 and Prism.js.
git clone https://github.com/321paranoiawhy/Vue3-Prism
# alias
npm run s # npm run service
# alias
npm run b # npm run build
npm run lib
Reference:
npm i vue3-prism
In main.js
:
// main.js
import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import Vue3Prism from 'vue3-prism/lib/Vue3Prism.common.js'
import "vue3-prism/lib/Vue3Prism.css"
createApp(App).use(store).use(router).use(Vue3Prism).mount('#app')
As long as you have registered globally, then you can use Vue3Prism
anywhere you want. It may just like this:
<!-- HelloWorld.vue -->
<template>
<!-- just pass source code in -->
<Vue3Prism
source="function bubbleSortFromStartToEnd(array) {
const { length } = array;
for (let i = 0; i < length - 1; i++) {
for (let j = 0; j < length - i - 1; j++) {
if (array[j] > array[j + 1]) {
[array[j], array[j + 1]] = [array[j + 1], array[j]];
}
}
}
return array;
}"
></Vue3Prism>
</template>
<script>
export default {
name: "HelloWorld",
};
</script>
Reference:
To be continued...
Reference: