@@ -13,14 +13,17 @@ const props = defineProps<{
13
13
14
14
const activeFile = ref <FileTree >()
15
15
16
- const cacheCodes = ref <Map <string , string >>(new Map < string , string > ())
17
- const activeCode = computed (() => cacheCodes .value .get (activeFile .value ?.path ?? ' ' ))
16
+ const cacheCodes = ref <Map <string , { raw : string , html : string } >>(new Map ())
17
+ const activeFileMeta = computed (() => cacheCodes .value .get (activeFile .value ?.path ?? ' ' ))
18
18
19
19
onBeforeMount (async () => {
20
20
for (const file of (props .item .files ?? [])) {
21
21
const raw = await file .raw ()
22
22
const highlighted = highlight (raw , ' vue' )
23
- cacheCodes .value .set (file .target || file .path .split (` ${props .item .name }/ ` )[1 ], highlighted )
23
+ cacheCodes .value .set (file .target || file .path .split (` ${props .item .name }/ ` )[1 ], {
24
+ raw ,
25
+ html: highlighted ,
26
+ })
24
27
}
25
28
})
26
29
</script >
@@ -35,10 +38,10 @@ onBeforeMount(async () => {
35
38
<File class =" size-4" />
36
39
{{ activeFile?.path }}
37
40
<div class =" ml-auto flex items-center gap-2" >
38
- <BlockCopyCodeButton :code =" activeCode " />
41
+ <BlockCopyCodeButton :code =" activeFileMeta?.raw " />
39
42
</div >
40
43
</div >
41
- <div :key =" activeFile?.path" data-line-codeblock class =" relative flex-1 overflow-hidden after:absolute after:inset-y-0 after:left-0 after:w-10 after:bg-zinc-950 [& _.line:before]:sticky [& _.line:before]:left-2 [& _.line:before]:z-10 [& _.line:before]:translate-y-[-1px] [& _.line:before]:pr-1 [& _pre]:h-[--height] [& _pre]:overflow-auto [& _pre]:!bg-transparent [& _pre]:pb-20 [& _pre]:pt-4 [& _pre]:font-mono [& _pre]:text-sm [& _pre]:leading-relaxed" v-html =" activeCode " />
44
+ <div :key =" activeFile?.path" data-line-codeblock class =" relative flex-1 overflow-hidden after:absolute after:inset-y-0 after:left-0 after:w-10 after:bg-zinc-950 [& _.line:before]:sticky [& _.line:before]:left-2 [& _.line:before]:z-10 [& _.line:before]:translate-y-[-1px] [& _.line:before]:pr-1 [& _pre]:h-[--height] [& _pre]:overflow-auto [& _pre]:!bg-transparent [& _pre]:pb-20 [& _pre]:pt-4 [& _pre]:font-mono [& _pre]:text-sm [& _pre]:leading-relaxed" v-html =" activeFileMeta?.html " />
42
45
</div >
43
46
</div >
44
47
</template >
0 commit comments