File tree Expand file tree Collapse file tree 3 files changed +25
-5
lines changed
Expand file tree Collapse file tree 3 files changed +25
-5
lines changed Original file line number Diff line number Diff line change 44 class =" my-class"
55 id =" my-id"
66 :code =" code"
7- language =" py "
7+ language =" python "
88 code-class =" codeClass"
99 :lines-highlighted =" [1, 2]"
1010 :words-highlighted =" ['log']"
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import type {
44 MaybeRefOrGetter ,
55 PropType
66} from 'vue' ;
7+ import { AllLanguagesSupported } from '../utils' ;
78
89// Props goes here
910export const codeBlockProps = ( ) =>
@@ -23,7 +24,7 @@ export const codeBlockProps = () =>
2324 required : true
2425 } ,
2526 language : {
26- type : String as PropType < string > ,
27+ type : String as PropType < AllLanguagesSupported > ,
2728 required : false ,
2829 default : 'markup'
2930 } ,
Original file line number Diff line number Diff line change 11import 'prismjs/themes/prism.min.css' ;
2- // import 'prismjs/themes/prism-con.min.css';
32import { Prism } from './prism-langs' ;
3+ // import 'prismjs/themes/prism-con.min.css';
4+
5+ export type AllLanguagesSupported =
6+ 'markup' |
7+ 'jsx' |
8+ 'tsx' |
9+ 'swift' |
10+ 'kotlin' |
11+ 'objectivec' |
12+ 'js-extras' |
13+ 'reason' |
14+ 'rust' |
15+ 'graphql' |
16+ 'yaml' |
17+ 'go' |
18+ 'cpp' |
19+ 'markdown' |
20+ 'python' |
21+ 'json' ;
22+
423
524export function highlightedCode ( code : string , language : string ) {
625 if ( code === null || code === undefined ) {
@@ -12,10 +31,10 @@ export function highlightedCode(code: string, language: string) {
1231 }
1332
1433 // Check if the language is registered, fallback to 'markup' if not found
15- const prismLanguage = Prism . languages [ language ] || Prism . languages . markup ;
34+ const prismLanguage = Prism . languages [ language ] ;
1635
17- console . log ( "Prism component for language '" + language + "' was not found." ) ;
1836 if ( ! prismLanguage ) {
37+ console . log ( "Prism component for language '" + language + "' was not found." ) ;
1938 throw new Error (
2039 `Prism component for language "${ language } " was not found. Report this issue at https://github.com/hetari/vuejs-code-block`
2140 ) ;
You can’t perform that action at this time.
0 commit comments