@@ -9,17 +9,6 @@ import { TemplateFileTree } from "./TemplateFileTree";
9
9
import { Link } from "react-router-dom" ;
10
10
import EditOutlined from "@mui/icons-material/EditOutlined" ;
11
11
12
- const languageByExtension :Record < string , string > = {
13
- tf :"hcl" ,
14
- hcl :"hcl" ,
15
- md :"markdown" ,
16
- mkd :"markdown" ,
17
- Dockerfile :"dockerfile" ,
18
- sh :"shell" ,
19
- tpl :"tpl" ,
20
- protobuf :"protobuf" ,
21
- nix :"dockerfile" ,
22
- } ;
23
12
interface TemplateFilesProps {
24
13
currentFiles :TemplateVersionFiles ;
25
14
/**
@@ -135,9 +124,7 @@ export const TemplateFiles: FC<TemplateFilesProps> = ({
135
124
</ div >
136
125
</ header >
137
126
< SyntaxHighlighter
138
- language = {
139
- languageByExtension [ filename . split ( "." ) . pop ( ) ?? "" ]
140
- }
127
+ language = { getLanguage ( filename ) }
141
128
value = { info . value }
142
129
compareWith = { info . previousValue }
143
130
editorProps = { {
@@ -159,6 +146,27 @@ export const TemplateFiles: FC<TemplateFilesProps> = ({
159
146
) ;
160
147
} ;
161
148
149
+ const languageByExtension :Record < string , string > = {
150
+ tf :"hcl" ,
151
+ hcl :"hcl" ,
152
+ md :"markdown" ,
153
+ mkd :"markdown" ,
154
+ sh :"shell" ,
155
+ tpl :"tpl" ,
156
+ protobuf :"protobuf" ,
157
+ nix :"dockerfile" ,
158
+ json :"json" ,
159
+ } ;
160
+
161
+ const getLanguage = ( filename :string ) => {
162
+ // Dockerfile can be like images/Dockerfile or Dockerfile.java
163
+ if ( filename . includes ( "Dockerfile" ) ) {
164
+ return "dockerfile" ;
165
+ }
166
+ const extension = filename . split ( "." ) . pop ( ) ;
167
+ return languageByExtension [ extension ?? "" ] ;
168
+ } ;
169
+
162
170
const numberOfLines = ( content :string ) => {
163
171
return content . split ( "\n" ) . length ;
164
172
} ;