diff --git a/package.json b/package.json index 206eda20..6aacb790 100644 --- a/package.json +++ b/package.json @@ -299,6 +299,11 @@ "items": { "type": "string" } + }, + "disableCreation": { + "type": "boolean", + "default": false, + "description": "%setting.frontMatter.content.pageFolders.items.properties.disableCreation.description%" } }, "additionalProperties": false, diff --git a/package.nls.json b/package.nls.json index 972c54de..c151f16b 100644 --- a/package.nls.json +++ b/package.nls.json @@ -74,6 +74,7 @@ "setting.frontMatter.content.pageFolders.items.properties.previewPath.description": "Defines a custom preview path for the folder.", "setting.frontMatter.content.pageFolders.items.properties.filePrefix.description": "Defines a prefix for the file name.", "setting.frontMatter.content.pageFolders.items.properties.contentTypes.description": "Defines which content types can be used for the current location. If not defined, all content types will be available.", + "setting.frontMatter.content.pageFolders.items.properties.disableCreation.description": "Disable the creation of new content in the folder.", "setting.frontMatter.content.placeholders.markdownDescription": "This array of placeholders defines the placeholders that you can use in your content types and templates for automatically populating your content its front matter. [Check in the docs](https://frontmatter.codes/docs/settings/overview#frontmatter.content.placeholders)", "setting.frontMatter.content.placeholders.items.properties.id.description": "ID of the placeholder, in your content type or template, use it as follows: {{placeholder}}", "setting.frontMatter.content.placeholders.items.properties.value.description": "The placeholder its value", diff --git a/src/commands/Folders.ts b/src/commands/Folders.ts index f8945df3..c7fa5131 100644 --- a/src/commands/Folders.ts +++ b/src/commands/Folders.ts @@ -95,7 +95,7 @@ export class Folders { return; } - const folders = Folders.get(); + const folders = Folders.get().filter((f) => !f.disableCreation); const location = folders.find((f) => f.title === selectedFolder); if (location) { const folderPath = Folders.getFolderPath(Uri.file(location.path)); diff --git a/src/helpers/ContentType.ts b/src/helpers/ContentType.ts index 325d5b56..504f2cef 100644 --- a/src/helpers/ContentType.ts +++ b/src/helpers/ContentType.ts @@ -85,7 +85,7 @@ export class ContentType { } const contentTypes = ContentType.getAll(); - const folders = Folders.get(); + const folders = Folders.get().filter((f) => !f.disableCreation); const folder = folders.find((f) => f.title === selectedFolder); if (!folder) { diff --git a/src/helpers/Questions.ts b/src/helpers/Questions.ts index e4806696..2bd347d6 100644 --- a/src/helpers/Questions.ts +++ b/src/helpers/Questions.ts @@ -116,7 +116,7 @@ export class Questions { public static async SelectContentFolder( showWarning: boolean = true ): Promise { - let folders = Folders.get(); + let folders = Folders.get().filter((f) => !f.disableCreation); let selectedFolder: string | undefined; if (folders.length > 1) { diff --git a/src/models/ContentFolder.ts b/src/models/ContentFolder.ts index 74e9e8d5..734245a8 100644 --- a/src/models/ContentFolder.ts +++ b/src/models/ContentFolder.ts @@ -2,6 +2,7 @@ export interface ContentFolder { title: string; path: string; + disableCreation?: boolean; excludeSubdir?: boolean; previewPath?: string; filePrefix?: string;