Skip to content

Commit

Permalink
fix: get token color
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz committed Nov 21, 2024
1 parent 298b7e0 commit 2ed1f8e
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions composables/shiki.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@ export function useHighlightColor(
if (code == null) return ''
const theme = `vitesse-${isDark.value ? 'dark' : 'light'}`
const result = highlight(code, theme)
let idx = 0
if (code.startsWith('"')) {
idx = 1
}
return result.tokens[0][idx].color
const token = result.tokens[0]
const idx = code.startsWith('"') && token.length > 1 ? 1 : 0
return token[idx].color
})
}

0 comments on commit 2ed1f8e

Please sign in to comment.