issue/#504

This commit is contained in:
furkanb
2023-02-11 01:47:03 +03:00
parent 4f91aeb80b
commit 04960b7fdb
4 changed files with 16 additions and 2 deletions
+5
View File
@@ -1254,6 +1254,11 @@
"type": "string",
"default": "",
"description": "An optional post script that can be used after new content creation."
},
"defaultFileName": {
"type": "string",
"default": "index",
"description": "Default file name to use when creating new content."
}
},
"additionalProperties": false,
+1 -1
View File
@@ -359,7 +359,7 @@ export class ArticleHelper {
return;
} else {
await mkdirAsync(newFolder);
newFilePath = join(newFolder, `index.${fileExtension || contentType.fileType || fileType}`);
newFilePath = join(newFolder, `${contentType.defaultFileName ?? `index`}.${fileExtension || contentType.fileType || fileType}`);
}
} else {
let newFileName = `${sanitizedName}.${fileExtension || contentType?.fileType || fileType}`;
+1
View File
@@ -47,6 +47,7 @@ export interface ContentType {
fileType?: "md" | "mdx" | string;
previewPath?: string | null;
pageBundle?: boolean;
defaultFileName?: string;
template?: string;
postScript?: string;
}
+9 -1
View File
@@ -18,8 +18,16 @@ const FileItem: React.FunctionComponent<IFileItemProps> = ({ name, folderName, p
Messenger.send(CommandToCode.openInEditor, path);
};
/*
File names which would not give any info about the content.
by themselves, e.g.: index | +page | etc…
Ideally we should have access to the `defaultFileName`
property of the contentType here to check.
*/
const vagueFileNamesList = ['index', '+page']
const itemName = useMemo(() => {
if (folderName && name.includes("index.")) {
if (folderName && vagueFileNamesList.some(vagueFileName => name.includes(vagueFileName + '.'))) {
return folderName;
}