@@ -2,27 +2,28 @@ import { motion, useReducedMotion } from "motion/react";
2
2
import React from "react" ;
3
3
import ReactDOM from "react-dom" ;
4
4
5
+ import { useAppContext } from "@contexts/AppContext" ;
5
6
import { useEscapeKey } from "@hooks/useEscapeKey" ;
6
7
import { SnippetType } from "@types" ;
7
- import { slugify } from "@utils/slugify" ;
8
8
9
9
import Button from "./Button" ;
10
10
import CodePreview from "./CodePreview" ;
11
11
import { CloseIcon } from "./Icons" ;
12
12
13
13
type Props = {
14
14
snippet : SnippetType ;
15
- language : string ;
15
+ extension : string ;
16
16
handleCloseModal : ( ) => void ;
17
17
} ;
18
18
19
19
const SnippetModal : React . FC < Props > = ( {
20
20
snippet,
21
- language ,
21
+ extension ,
22
22
handleCloseModal,
23
23
} ) => {
24
24
const modalRoot = document . getElementById ( "modal-root" ) ;
25
25
26
+ const { language, subLanguage } = useAppContext ( ) ;
26
27
const shouldReduceMotion = useReducedMotion ( ) ;
27
28
28
29
useEscapeKey ( handleCloseModal ) ;
@@ -49,7 +50,7 @@ const SnippetModal: React.FC<Props> = ({
49
50
key = "modal-content"
50
51
className = "modal | flow"
51
52
data-flow-space = "lg"
52
- layoutId = { `${ language } -${ snippet . title } ` }
53
+ layoutId = { `${ extension } -${ snippet . title } ` }
53
54
transition = { {
54
55
ease : [ 0 , 0.75 , 0.25 , 1 ] ,
55
56
duration : shouldReduceMotion ? 0 : 0.3 ,
@@ -62,7 +63,14 @@ const SnippetModal: React.FC<Props> = ({
62
63
</ Button >
63
64
</ div >
64
65
< div className = "modal__body | flow" >
65
- < CodePreview language = { slugify ( language ) } code = { snippet . code } />
66
+ { /* TODO: update the language name and remove all-sub-languages */ }
67
+ < CodePreview
68
+ languageName = {
69
+ subLanguage === "all-sub-languages" ? language . name : subLanguage
70
+ }
71
+ extension = { extension }
72
+ code = { snippet . code }
73
+ />
66
74
< p >
67
75
< b > Description: </ b >
68
76
{ snippet . description }
0 commit comments