Skip to content

Commit 4b21000

Browse files
committed
fix: normalize import path
1 parent c2c6a7a commit 4b21000

File tree

1 file changed

+14
-2
lines changed
  • docs/.vitepress/components/demo-block/src

1 file changed

+14
-2
lines changed

docs/.vitepress/components/demo-block/src/index.vue

+14-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,20 @@ function updateImportPaths(code: string): string {
3333
magicString.replaceAll('../../lib/utils', '@/libs/utils')
3434
3535
return magicString.toString()
36-
}
37-
const { copy, copied } = useClipboard({ source: decodeURIComponent(props.code) })
36+
};
37+
38+
const normalizeImportPath = computed(() => {
39+
try {
40+
const decodeHighlightedCode = decodeURIComponent(props.code)
41+
const updatedCode = updateImportPaths(decodeHighlightedCode)
42+
return updatedCode
43+
}
44+
catch (error) {
45+
console.error('Error decoding code:', error)
46+
return props.code
47+
}
48+
})
49+
const { copy, copied } = useClipboard({ source: normalizeImportPath.value })
3850
const [value, toggle] = useToggle()
3951
const refreshKey = ref(0)
4052
function handleRefreshComponent() {

0 commit comments

Comments
 (0)