Skip to content

Commit d155743

Browse files
committed
Cope with array of lang grammars
1 parent 544afa1 commit d155743

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

.vitepress/theme/components/cds-playground/highlighter.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import languages from '../../../languages'
44
const highlighter = await createHighlighter({
55
themes: ['github-dark', 'github-light'],
66
langs: ['javascript', 'js', 'sql', 'typescript', 'vue', ...languages],
7-
langAlias: Object.fromEntries( languages.map(l => l.aliases?.map(alias => [alias, l.name])) )
7+
langAlias: Object.fromEntries(languages.flatMap(l => {
8+
if (!l || typeof l !== 'object' || !Array.isArray(l.aliases) || !l.name) return []
9+
return l.aliases.map(alias => [alias, l.name])
10+
}))
811
})
912

1013
export default highlighter

0 commit comments

Comments
 (0)