mirror of
https://github.com/estruyf/vscode-front-matter.git
synced 2026-08-08 09:53:20 +02:00
issue/#504
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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}`;
|
||||
|
||||
@@ -47,6 +47,7 @@ export interface ContentType {
|
||||
fileType?: "md" | "mdx" | string;
|
||||
previewPath?: string | null;
|
||||
pageBundle?: boolean;
|
||||
defaultFileName?: string;
|
||||
template?: string;
|
||||
postScript?: string;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user