Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbe1edc3

Browse files
fix(site): fix language detection for Dockerfile (#12188)
1 parent41647ca commitbe1edc3

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

‎site/src/modules/templates/TemplateFiles/TemplateFiles.tsx

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,6 @@ import { TemplateFileTree } from "./TemplateFileTree";
99
import{Link}from"react-router-dom";
1010
importEditOutlinedfrom"@mui/icons-material/EditOutlined";
1111

12-
constlanguageByExtension: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-
};
2312
interfaceTemplateFilesProps{
2413
currentFiles:TemplateVersionFiles;
2514
/**
@@ -135,9 +124,7 @@ export const TemplateFiles: FC<TemplateFilesProps> = ({
135124
</div>
136125
</header>
137126
<SyntaxHighlighter
138-
language={
139-
languageByExtension[filename.split(".").pop()??""]
140-
}
127+
language={getLanguage(filename)}
141128
value={info.value}
142129
compareWith={info.previousValue}
143130
editorProps={{
@@ -159,6 +146,27 @@ export const TemplateFiles: FC<TemplateFilesProps> = ({
159146
);
160147
};
161148

149+
constlanguageByExtension: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+
constgetLanguage=(filename:string)=>{
162+
// Dockerfile can be like images/Dockerfile or Dockerfile.java
163+
if(filename.includes("Dockerfile")){
164+
return"dockerfile";
165+
}
166+
constextension=filename.split(".").pop();
167+
returnlanguageByExtension[extension??""];
168+
};
169+
162170
constnumberOfLines=(content:string)=>{
163171
returncontent.split("\n").length;
164172
};

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp