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

Commite7b0181

Browse files
feat(site): add support to .sh and .tpl files (#9674)
1 parente0e6d7c commite7b0181

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

‎site/src/components/TemplateFiles/TemplateFiles.tsx‎

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@ import { SyntaxHighlighter } from "components/SyntaxHighlighter/SyntaxHighlighte
66
import{UseTabResult}from"hooks/useTab";
77
import{FC}from"react";
88
import{combineClasses}from"utils/combineClasses";
9-
import{TemplateVersionFiles}from"utils/templateVersion";
9+
import{AllowedExtension,TemplateVersionFiles}from"utils/templateVersion";
10+
importInsertDriveFileOutlinedfrom"@mui/icons-material/InsertDriveFileOutlined";
1011

11-
consticonByExtension:Record<string,JSX.Element>={
12+
consticonByExtension:Record<AllowedExtension,JSX.Element>={
1213
tf:<TerraformIcon/>,
1314
md:<MarkdownIcon/>,
1415
mkd:<MarkdownIcon/>,
1516
Dockerfile:<DockerIcon/>,
17+
protobuf:<InsertDriveFileOutlined/>,
18+
sh:<InsertDriveFileOutlined/>,
19+
tpl:<InsertDriveFileOutlined/>,
1620
};
1721

1822
constgetExtension=(filename:string)=>{
@@ -24,11 +28,14 @@ const getExtension = (filename: string) => {
2428
returnfilename;
2529
};
2630

27-
constlanguageByExtension:Record<string,string>={
31+
constlanguageByExtension:Record<AllowedExtension,string>={
2832
tf:"hcl",
2933
md:"markdown",
3034
mkd:"markdown",
3135
Dockerfile:"dockerfile",
36+
sh:"bash",
37+
tpl:"tpl",
38+
protobuf:"protobuf",
3239
};
3340

3441
exportconstTemplateFiles:FC<{
@@ -47,7 +54,7 @@ export const TemplateFiles: FC<{
4754
<divclassName={styles.tabs}>
4855
{filenames.map((filename,index)=>{
4956
consttabValue=index.toString();
50-
constextension=getExtension(filename);
57+
constextension=getExtension(filename)asAllowedExtension;
5158
consticon=iconByExtension[extension];
5259
consthasDiff=
5360
previousFiles&&
@@ -76,7 +83,11 @@ export const TemplateFiles: FC<{
7683
<SyntaxHighlighter
7784
value={currentFile}
7885
compareWith={previousFile}
79-
language={languageByExtension[getExtension(selectedFilename)]}
86+
language={
87+
languageByExtension[
88+
getExtension(selectedFilename)asAllowedExtension
89+
]
90+
}
8091
/>
8192
</div>
8293
);

‎site/src/pages/TemplateVersionPage/TemplateVersionPageView.stories.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ const defaultArgs: TemplateVersionPageViewProps = {
4040
currentFiles:{
4141
"README.md":readmeContent,
4242
"main.tf":`{}`,
43+
"some.tpl":`{{.Name}}`,
44+
"some.sh":`echo "Hello world"`,
4345
},
4446
},
4547
};

‎site/src/utils/templateVersion.ts‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,17 @@ export const getTemplateVersionFiles = async (
2323
returnfiles;
2424
};
2525

26-
exportconstallowedExtensions=["tf","md","Dockerfile","protobuf"];
26+
exportconstallowedExtensions=[
27+
"tf",
28+
"md",
29+
"mkd",
30+
"Dockerfile",
31+
"protobuf",
32+
"sh",
33+
"tpl",
34+
]asconst;
35+
36+
exporttypeAllowedExtension=(typeofallowedExtensions)[number];
2737

2838
exportconstisAllowedFile=(name:string)=>{
2939
returnallowedExtensions.some((ext)=>name.endsWith(ext));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp