#539 - fix file prefix

This commit is contained in:
Elio Struyf
2023-03-16 09:51:57 +01:00
parent b48008eb41
commit 42c44ca3a5
3 changed files with 11 additions and 4 deletions
+1
View File
@@ -36,6 +36,7 @@
- [#521](https://github.com/estruyf/vscode-front-matter/issues/521): Fix empty snippets dashboard placeholder
- [#526](https://github.com/estruyf/vscode-front-matter/issues/526): Fix card content menu
- [#531](https://github.com/estruyf/vscode-front-matter/issues/531): Fix prettier update which caused data views to not render list items
- [#539](https://github.com/estruyf/vscode-front-matter/issues/539): Fix the override of the default file prefix on content creation
## [8.3.0] - 2023-02-14 - [Release notes](https://beta.frontmatter.codes/updates/v8.3.0)
+1 -1
View File
@@ -226,7 +226,7 @@ export class Article {
let filePrefix = Settings.get<string>(SETTING_TEMPLATES_PREFIX);
const contentType = ArticleHelper.getContentType(article.data);
filePrefix = ArticleHelper.getFilePrefix(editor.document.uri.fsPath, contentType);
filePrefix = ArticleHelper.getFilePrefix(filePrefix, editor.document.uri.fsPath, contentType);
const titleField = 'title';
const articleTitle: string = article.data[titleField];
+9 -3
View File
@@ -383,7 +383,7 @@ export class ArticleHelper {
const fileType = Settings.get<string>(SETTING_CONTENT_DEFAULT_FILETYPE);
let prefix = Settings.get<string>(SETTING_TEMPLATES_PREFIX);
prefix = ArticleHelper.getFilePrefix(folderPath, contentType);
prefix = ArticleHelper.getFilePrefix(prefix, folderPath, contentType);
// Name of the file or folder to create
let sanitizedName = ArticleHelper.sanitize(titleValue);
@@ -436,8 +436,14 @@ export class ArticleHelper {
* @param contentType
* @returns
*/
public static getFilePrefix(filePath?: string, contentType?: ContentType): string | undefined {
let prefix = undefined;
public static getFilePrefix(
prefix: string | null | undefined,
filePath?: string,
contentType?: ContentType
): string | undefined {
if (!prefix) {
prefix = undefined;
}
// Retrieve the file prefix from the folder
if (filePath) {