diff --git a/.vscode/settings.json b/.vscode/settings.json index e48f7ecb..0cea6771 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -23,58 +23,5 @@ "exportall.config.folderListener": [ "/src/pagesView/state/atom", "/src/pagesView/state/selectors" - ], - "frontMatter.content.pageFolders": [ - { - "title": "documentation", - "path": "[[workspace]]/docs/content/docs" - } - ], - "frontMatter.taxonomy.contentTypes": [ - { - "name": "default", - "fields": [ - { - "title": "Title", - "name": "title", - "type": "string" - }, - { - "title": "Description", - "name": "description", - "type": "string" - }, - { - "title": "Publishing date", - "name": "date", - "type": "datetime" - }, - { - "title": "Last modified date", - "name": "lastmod", - "type": "datetime" - }, - { - "title": "Article preview", - "name": "preview", - "type": "image" - }, - { - "title": "Is in draft", - "name": "draft", - "type": "boolean" - }, - { - "title": "Tags", - "name": "tags", - "type": "tags" - }, - { - "title": "Categories", - "name": "categories", - "type": "categories" - } - ] - } ] } \ No newline at end of file diff --git a/frontmatter.json b/frontmatter.json new file mode 100644 index 00000000..fe583b5d --- /dev/null +++ b/frontmatter.json @@ -0,0 +1,56 @@ +{ + "$schema": "https://beta.frontmatter.codes/frontmatter.schema.json", + "frontMatter.content.pageFolders": [ + { + "title": "documentation", + "path": "[[workspace]]/docs/content/docs" + } + ], + "frontMatter.taxonomy.contentTypes": [ + { + "name": "default", + "fields": [ + { + "title": "Title", + "name": "title", + "type": "string" + }, + { + "title": "Description", + "name": "description", + "type": "string" + }, + { + "title": "Publishing date", + "name": "date", + "type": "datetime" + }, + { + "title": "Last modified date", + "name": "lastmod", + "type": "datetime" + }, + { + "title": "Article preview", + "name": "preview", + "type": "image" + }, + { + "title": "Is in draft", + "name": "draft", + "type": "boolean" + }, + { + "title": "Tags", + "name": "tags", + "type": "tags" + }, + { + "title": "Categories", + "name": "categories", + "type": "categories" + } + ] + } + ] +} \ No newline at end of file diff --git a/src/helpers/Extension.ts b/src/helpers/Extension.ts index 4b808fc5..2f5f0e93 100644 --- a/src/helpers/Extension.ts +++ b/src/helpers/Extension.ts @@ -82,7 +82,9 @@ export class Extension { } // Create team settings - Settings.createTeamSettings(); + if (Settings.hasSettings()) { + Settings.createTeamSettings(); + } // Migration to version 4.0.0 const dateField = Settings.get(SETTING_DATE_FIELD); diff --git a/src/helpers/SettingsHelper.ts b/src/helpers/SettingsHelper.ts index 968f81b6..2c328535 100644 --- a/src/helpers/SettingsHelper.ts +++ b/src/helpers/SettingsHelper.ts @@ -172,11 +172,12 @@ export class Settings { const settingNames = Object.keys(pkg.contributes.configuration.properties); for (const name of settingNames) { - const setting = Settings.config.inspect(name.replace(`frontMatter.`, '')); + const settingName = name.replace(`${CONFIG_KEY}.`, ''); + const setting = Settings.config.inspect(settingName); if (setting && typeof setting.workspaceValue !== "undefined") { - await Settings.update(name, setting.workspaceValue, true); - await Settings.update(name.replace(`frontMatter.`, ''), undefined); + await Settings.update(settingName, setting.workspaceValue, true); + await Settings.update(settingName, undefined); } } } @@ -184,6 +185,30 @@ export class Settings { Notifications.info(`All settings promoted to team level.`); } + /** + * Check if there are any Front Matter settings in the workspace + * @returns + */ + public static hasSettings() { + let hasSetting = false; + + const pkg = Extension.getInstance().packageJson; + if (pkg?.contributes?.configuration?.properties) { + const settingNames = Object.keys(pkg.contributes.configuration.properties); + + for (const name of settingNames) { + const settingName = name.replace(`${CONFIG_KEY}.`, ''); + const setting = Settings.config.inspect(settingName); + + if (setting && typeof setting.workspaceValue !== "undefined") { + hasSetting = true; + } + } + } + + return hasSetting; + } + /** * Check if its the project config