mirror of
https://github.com/estruyf/vscode-front-matter.git
synced 2026-08-12 03:43:01 +02:00
#425 - support added for placeholders in the page folders path
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
|
||||
### 🎨 Enhancements
|
||||
|
||||
- [#425](https://github.com/estruyf/vscode-front-matter/issues/425): Added support for placeholders in the content paths
|
||||
- [#473](https://github.com/estruyf/vscode-front-matter/issues/473): Allow setting the SEO title name with the `frontMatter.taxonomy.seoTitleField` setting
|
||||
- [#474](https://github.com/estruyf/vscode-front-matter/issues/474): Allow to define the file prefix on content types
|
||||
- [#484](https://github.com/estruyf/vscode-front-matter/issues/484): Support for overriding scripts per environment type
|
||||
|
||||
+22
-13
@@ -4,6 +4,7 @@ import {
|
||||
SETTING_CONTENT_PAGE_FOLDERS,
|
||||
SETTING_CONTENT_STATIC_FOLDER,
|
||||
SETTING_CONTENT_SUPPORTED_FILETYPES,
|
||||
SETTING_DATE_FORMAT,
|
||||
TelemetryEvent
|
||||
} from './../constants';
|
||||
import { commands, Uri, workspace, window } from 'vscode';
|
||||
@@ -12,7 +13,7 @@ import { ContentFolder, FileInfo, FolderInfo } from '../models';
|
||||
import uniqBy = require('lodash.uniqby');
|
||||
import { Template } from './Template';
|
||||
import { Notifications } from '../helpers/Notifications';
|
||||
import { Logger, Settings } from '../helpers';
|
||||
import { Logger, processKnownPlaceholders, Settings } from '../helpers';
|
||||
import { existsSync } from 'fs';
|
||||
import { format } from 'date-fns';
|
||||
import { Dashboard } from './Dashboard';
|
||||
@@ -343,18 +344,26 @@ export class Folders {
|
||||
folder.title = basename(folder.path);
|
||||
}
|
||||
|
||||
const folderPath = Folders.absWsFolder(folder, wsFolder);
|
||||
if (!existsSync(folderPath)) {
|
||||
Notifications.errorShowOnce(
|
||||
`Folder "${folder.title} (${folder.path})" does not exist. Please remove it from the settings.`,
|
||||
'Remove folder'
|
||||
).then((answer) => {
|
||||
if (answer === 'Remove folder') {
|
||||
const folders = Folders.get();
|
||||
Folders.update(folders.filter((f) => f.path !== folder.path));
|
||||
}
|
||||
});
|
||||
return null;
|
||||
let folderPath: string | undefined = Folders.absWsFolder(folder, wsFolder);
|
||||
if (folderPath.includes(`{{`) && folderPath.includes(`}}`)) {
|
||||
const dateFormat = Settings.get(SETTING_DATE_FORMAT) as string;
|
||||
folderPath = processKnownPlaceholders(folderPath, undefined, dateFormat);
|
||||
} else {
|
||||
if (folderPath && !existsSync(folderPath)) {
|
||||
Notifications.errorShowOnce(
|
||||
`Folder "${folder.title} (${folder.path})" does not exist. Please remove it from the settings.`,
|
||||
'Remove folder',
|
||||
'Create folder'
|
||||
).then((answer) => {
|
||||
if (answer === 'Remove folder') {
|
||||
const folders = Folders.get();
|
||||
Folders.update(folders.filter((f) => f.path !== folder.path));
|
||||
} else if (answer === 'Create folder') {
|
||||
mkdirAsync(folderPath as string, { recursive: true });
|
||||
}
|
||||
});
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -402,7 +402,7 @@ export class ArticleHelper {
|
||||
);
|
||||
return;
|
||||
} else {
|
||||
await mkdirAsync(newFolder);
|
||||
await mkdirAsync(newFolder, { recursive: true });
|
||||
newFilePath = join(newFolder, `index.${fileExtension || contentType.fileType || fileType}`);
|
||||
}
|
||||
} else {
|
||||
@@ -414,6 +414,8 @@ export class ArticleHelper {
|
||||
|
||||
newFilePath = join(folderPath, newFileName);
|
||||
|
||||
await mkdirAsync(folderPath, { recursive: true });
|
||||
|
||||
if (await existsAsync(newFilePath)) {
|
||||
Notifications.warning(`Content with the title already exists. Please specify a new title.`);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user