diff --git a/app/components/RuleStateItem.vue b/app/components/RuleStateItem.vue
index 055bc2a..4b0c563 100644
--- a/app/components/RuleStateItem.vue
+++ b/app/components/RuleStateItem.vue
@@ -5,7 +5,6 @@ import { filtersConfigs } from '~/composables/state'
import { payload } from '~/composables/payload'
import { useRouter } from '#app/composables/router'
import type { RuleConfigState } from '~~/shared/types'
-import { Shiki } from '~/composables/shiki'
const props = defineProps<{
state: RuleConfigState
diff --git a/app/components/Shiki.ts b/app/components/Shiki.ts
new file mode 100644
index 0000000..4b344a8
--- /dev/null
+++ b/app/components/Shiki.ts
@@ -0,0 +1,36 @@
+// @unocss-include
+export default defineComponent({
+ name: 'Shiki',
+ props: {
+ code: {
+ type: String,
+ required: true,
+ },
+ lang: {
+ type: String,
+ required: true,
+ },
+ },
+ setup(props) {
+ const highlighted = computed(() => {
+ if (!shiki.value)
+ return sanitizeHtml(props.code)
+ return shiki.value.codeToHtml(props.code, {
+ lang: props.lang,
+ theme: isDark.value ? 'vitesse-dark' : 'vitesse-light',
+ transformers: [
+ {
+ pre(node) {
+ node.properties.style = ''
+ },
+ },
+ ],
+ })
+ })
+
+ return () => h('div', {
+ class: 'filter-hue-rotate-90',
+ innerHTML: highlighted.value,
+ })
+ },
+})
diff --git a/app/composables/shiki.ts b/app/composables/shiki.ts
index 934cd09..4d7ffef 100644
--- a/app/composables/shiki.ts
+++ b/app/composables/shiki.ts
@@ -1,7 +1,7 @@
import type { HighlighterCore } from 'shiki/core'
import { getHighlighterCore } from 'shiki/core'
-const shiki = shallowRef()
+export const shiki = shallowRef()
getHighlighterCore({
themes: [
@@ -24,44 +24,12 @@ export function useHighlightedGlob(code: () => string) {
return sanitizeHtml(code())
return shiki.value.codeToHtml(code(), {
lang: 'glob',
- theme: isDark ? 'vitesse-dark' : 'vitesse-light',
+ theme: isDark.value ? 'vitesse-dark' : 'vitesse-light',
structure: 'inline',
})
})
}
-export const Shiki = defineComponent({
- props: {
- code: {
- type: String,
- required: true,
- },
- lang: {
- type: String,
- required: true,
- },
- },
- setup(props) {
- const highlighted = computed(() => {
- if (!shiki.value)
- return sanitizeHtml(props.code)
- return shiki.value.codeToHtml(props.code, {
- lang: props.lang,
- theme: isDark ? 'vitesse-dark' : 'vitesse-light',
- transformers: [
- {
- pre(node) {
- node.properties.style = ''
- },
- },
- ],
- })
- })
-
- return () => h('div', { innerHTML: highlighted.value })
- },
-})
-
-function sanitizeHtml(html: string) {
+export function sanitizeHtml(html: string) {
return html.replace(//g, '>')
}