Enhancement: Add property to page folder setting to disable content creation #674

This commit is contained in:
Elio Struyf
2023-09-22 16:51:59 +02:00
parent c506ab75c1
commit 8ba2e15db0
6 changed files with 10 additions and 3 deletions

View File

@@ -299,6 +299,11 @@
"items": {
"type": "string"
}
},
"disableCreation": {
"type": "boolean",
"default": false,
"description": "%setting.frontMatter.content.pageFolders.items.properties.disableCreation.description%"
}
},
"additionalProperties": false,

View File

@@ -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",

View File

@@ -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));

View File

@@ -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) {

View File

@@ -116,7 +116,7 @@ export class Questions {
public static async SelectContentFolder(
showWarning: boolean = true
): Promise<string | undefined> {
let folders = Folders.get();
let folders = Folders.get().filter((f) => !f.disableCreation);
let selectedFolder: string | undefined;
if (folders.length > 1) {

View File

@@ -2,6 +2,7 @@ export interface ContentFolder {
title: string;
path: string;
disableCreation?: boolean;
excludeSubdir?: boolean;
previewPath?: string;
filePrefix?: string;