Compare commits

..

10 Commits

Author SHA1 Message Date
Elio Struyf 6f6015cf83 Merge branch 'main' of github.com:estruyf/vscode-front-matter 2024-03-01 10:33:18 +01:00
Elio Struyf afd2878428 #769 - Fix settings on install 2024-03-01 10:33:13 +01:00
Elio Struyf c66deb032c Merge pull request #770 from estruyf/patch-10.0.2
Patch 10.0.2
2024-03-01 10:05:04 +01:00
Elio Struyf 4c079b3e9d 10.0.2 2024-03-01 09:01:46 +01:00
Elio Struyf 03c2cd31d7 Update changelog 2024-03-01 09:01:38 +01:00
Elio Struyf d1dba01923 #769 - Fix folder update 2024-03-01 09:00:42 +01:00
Elio Struyf 286ac4adfe Merge pull request #767 from estruyf/dev
#766 - Fix snippet placeholder retrieval
2024-02-28 21:13:56 +01:00
Elio Struyf 7633ac91be Update changelog 2024-02-28 21:12:17 +01:00
Elio Struyf 282527c90d 10.0.1 2024-02-28 21:11:27 +01:00
Elio Struyf 07fbf8bdb9 #766 - Fix snippet placeholder retrieval 2024-02-28 21:11:24 +01:00
8 changed files with 264 additions and 157 deletions
+12
View File
@@ -1,5 +1,17 @@
# Change Log
## [10.0.2] - 2024-03-01
### 🐞 Fixes
- [#769](https://github.com/estruyf/vscode-front-matter/issues/769): Fix to remove internal properties for content folders
## [10.0.1] - 2024-02-28
### 🐞 Fixes
- [#766](https://github.com/estruyf/vscode-front-matter/issues/766): Fix for snippet placeholder retrieval
## [10.0.0] - 2024-02-28 - [Release notes](https://beta.frontmatter.codes/updates/v10.0.0)
### ✨ New features
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "vscode-front-matter-beta",
"version": "10.0.0",
"version": "10.0.2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "vscode-front-matter-beta",
"version": "10.0.0",
"version": "10.0.2",
"license": "MIT",
"dependencies": {
"@radix-ui/react-dropdown-menu": "^2.0.6"
+184 -147
View File
@@ -3,14 +3,15 @@
"displayName": "Front Matter CMS",
"description": "Front Matter is a CMS that runs within Visual Studio Code. It gives you the power and control of a full-blown CMS while also providing you the flexibility and speed of the static site generator of your choice like: Hugo, Jekyll, Docusaurus, NextJs, Gatsby, and many more...",
"icon": "assets/frontmatter-teal-128x128.png",
"version": "10.0.0",
"version": "10.0.2",
"preview": false,
"publisher": "eliostruyf",
"galleryBanner": {
"color": "#0e131f",
"theme": "dark"
},
"badges": [{
"badges": [
{
"description": "version",
"url": "https://img.shields.io/github/package-json/v/estruyf/vscode-front-matter?color=green&label=vscode-front-matter&style=flat-square",
"href": "https://github.com/estruyf/vscode-front-matter"
@@ -70,7 +71,8 @@
"**/.frontmatter/config/*.json": "jsonc"
}
},
"keybindings": [{
"keybindings": [
{
"command": "frontMatter.dashboard",
"key": "alt+d"
},
@@ -88,19 +90,23 @@
}
],
"viewsContainers": {
"activitybar": [{
"id": "frontmatter-explorer",
"title": "FM",
"icon": "$(fm-logo)"
}]
"activitybar": [
{
"id": "frontmatter-explorer",
"title": "FM",
"icon": "$(fm-logo)"
}
]
},
"views": {
"frontmatter-explorer": [{
"id": "frontMatter.explorer",
"name": "Front Matter",
"icon": "$(fm-logo)",
"type": "webview"
}]
"frontmatter-explorer": [
{
"id": "frontMatter.explorer",
"name": "Front Matter",
"icon": "$(fm-logo)",
"type": "webview"
}
]
},
"configuration": {
"title": "%settings.configuration.title%",
@@ -168,7 +174,8 @@
"frontMatter.content.defaultFileType": {
"type": "string",
"default": "md",
"oneOf": [{
"oneOf": [
{
"enum": [
"md",
"mdx"
@@ -184,7 +191,8 @@
"frontMatter.content.defaultSorting": {
"type": "string",
"default": "",
"oneOf": [{
"oneOf": [
{
"enum": [
"LastModifiedAsc",
"LastModifiedDesc",
@@ -532,7 +540,8 @@
"categories"
],
"markdownDescription": "%setting.frontMatter.content.filters.markdownDescription%",
"items": [{
"items": [
{
"type": "string",
"enum": [
"contentFolders",
@@ -605,7 +614,8 @@
"command": {
"$id": "#scriptCommand",
"type": "string",
"anyOf": [{
"anyOf": [
{
"enum": [
"node",
"bash",
@@ -801,7 +811,8 @@
"title",
"file"
],
"anyOf": [{
"anyOf": [
{
"required": [
"schema"
]
@@ -855,7 +866,8 @@
"id",
"path"
],
"anyOf": [{
"anyOf": [
{
"required": [
"schema"
]
@@ -1096,26 +1108,29 @@
}
}
},
"default": [{
"name": "default",
"fileTypes": null,
"fields": [{
"title": "Title",
"name": "title",
"type": "string"
},
{
"title": "Caption",
"name": "caption",
"type": "string"
},
{
"title": "Alt text",
"name": "alt",
"type": "string"
}
]
}],
"default": [
{
"name": "default",
"fileTypes": null,
"fields": [
{
"title": "Title",
"name": "title",
"type": "string"
},
{
"title": "Caption",
"name": "caption",
"type": "string"
},
{
"title": "Alt text",
"name": "alt",
"type": "string"
}
]
}
],
"scope": "Media"
},
"frontMatter.media.supportedMimeTypes": {
@@ -1345,7 +1360,8 @@
"default": "",
"description": "%setting.frontMatter.taxonomy.contentTypes.items.properties.fields.items.properties.taxonomyId.description%",
"not": {
"anyOf": [{
"anyOf": [
{
"const": ""
},
{
@@ -1539,7 +1555,8 @@
"type",
"name"
],
"allOf": [{
"allOf": [
{
"if": {
"properties": {
"type": {
@@ -1747,48 +1764,51 @@
"fields"
]
},
"default": [{
"name": "default",
"pageBundle": false,
"fields": [{
"title": "Title",
"name": "title",
"type": "string"
},
{
"title": "Description",
"name": "description",
"type": "string"
},
{
"title": "Publishing date",
"name": "date",
"type": "datetime",
"default": "{{now}}",
"isPublishDate": true
},
{
"title": "Content 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"
}
]
}],
"default": [
{
"name": "default",
"pageBundle": false,
"fields": [
{
"title": "Title",
"name": "title",
"type": "string"
},
{
"title": "Description",
"name": "description",
"type": "string"
},
{
"title": "Publishing date",
"name": "date",
"type": "datetime",
"default": "{{now}}",
"isPublishDate": true
},
{
"title": "Content 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"
}
]
}
],
"scope": "Taxonomy"
},
"frontMatter.taxonomy.customTaxonomy": {
@@ -1801,7 +1821,8 @@
"type": "string",
"description": "%setting.frontMatter.taxonomy.customTaxonomy.items.properties.id.description%",
"not": {
"anyOf": [{
"anyOf": [
{
"const": ""
},
{
@@ -1986,7 +2007,8 @@
}
}
},
"commands": [{
"commands": [
{
"command": "frontMatter.project.switch",
"title": "%command.frontMatter.project.switch%",
"category": "Front Matter",
@@ -2312,16 +2334,21 @@
}
}
],
"submenus": [{
"id": "frontmatter.submenu",
"label": "Front Matter"
}],
"submenus": [
{
"id": "frontmatter.submenu",
"label": "Front Matter"
}
],
"menus": {
"webview/context": [{
"command": "workbench.action.webview.openDeveloperTools",
"when": "frontMatter:isDevelopment"
}],
"editor/title": [{
"webview/context": [
{
"command": "workbench.action.webview.openDeveloperTools",
"when": "frontMatter:isDevelopment"
}
],
"editor/title": [
{
"command": "frontMatter.markup.heading",
"group": "navigation@-133",
"when": "frontMatter:file:isValid == true && frontMatter:markdown:wysiwyg"
@@ -2407,11 +2434,14 @@
"when": "resourceFilename == 'frontmatter.json'"
}
],
"explorer/context": [{
"submenu": "frontmatter.submenu",
"group": "frontmatter@1"
}],
"frontmatter.submenu": [{
"explorer/context": [
{
"submenu": "frontmatter.submenu",
"group": "frontmatter@1"
}
],
"frontmatter.submenu": [
{
"command": "frontMatter.createFromTemplate",
"when": "explorerResourceIsFolder",
"group": "frontmatter@1"
@@ -2427,7 +2457,8 @@
"group": "frontmatter@3"
}
],
"commandPalette": [{
"commandPalette": [
{
"command": "frontMatter.init",
"when": "frontMatterCanInit"
},
@@ -2604,7 +2635,8 @@
"when": "frontMatter:file:isValid == true"
}
],
"view/title": [{
"view/title": [
{
"command": "frontMatter.chatbot",
"group": "navigation@0",
"when": "view == frontMatter.explorer"
@@ -2636,52 +2668,57 @@
}
]
},
"grammars": [{
"path": "./syntaxes/hugo.tmLanguage.json",
"scopeName": "frontmatter.markdown.hugo",
"injectTo": [
"text.html.markdown"
]
}],
"walkthroughs": [{
"id": "frontmatter.welcome",
"title": "Get started with Front Matter",
"description": "Discover the features of Front Matter and learn how to use the CMS for your SSG or static site.",
"steps": [{
"id": "frontmatter.welcome.init",
"title": "Get started",
"description": "Initial steps to get started.\n[Open dashboard](command:frontMatter.dashboard)",
"media": {
"markdown": "assets/walkthrough/get-started.md"
"grammars": [
{
"path": "./syntaxes/hugo.tmLanguage.json",
"scopeName": "frontmatter.markdown.hugo",
"injectTo": [
"text.html.markdown"
]
}
],
"walkthroughs": [
{
"id": "frontmatter.welcome",
"title": "Get started with Front Matter",
"description": "Discover the features of Front Matter and learn how to use the CMS for your SSG or static site.",
"steps": [
{
"id": "frontmatter.welcome.init",
"title": "Get started",
"description": "Initial steps to get started.\n[Open dashboard](command:frontMatter.dashboard)",
"media": {
"markdown": "assets/walkthrough/get-started.md"
},
"completionEvents": [
"onContext:frontMatterInitialized"
]
},
"completionEvents": [
"onContext:frontMatterInitialized"
]
},
{
"id": "frontmatter.welcome.documentation",
"title": "Documentation",
"description": "Check out the documentation for Front Matter.\n[View our documentation](https://frontmatter.codes/docs)",
"media": {
"markdown": "assets/walkthrough/documentation.md"
{
"id": "frontmatter.welcome.documentation",
"title": "Documentation",
"description": "Check out the documentation for Front Matter.\n[View our documentation](https://frontmatter.codes/docs)",
"media": {
"markdown": "assets/walkthrough/documentation.md"
},
"completionEvents": [
"onLink:https://frontmatter.codes/docs"
]
},
"completionEvents": [
"onLink:https://frontmatter.codes/docs"
]
},
{
"id": "frontmatter.welcome.supporter",
"title": "Support the project",
"description": "Become a supporter.\n[Support the project](https://github.com/sponsors/estruyf)",
"media": {
"markdown": "assets/walkthrough/support-the-project.md"
},
"completionEvents": [
"onLink:https://github.com/sponsors/estruyf"
]
}
]
}]
{
"id": "frontmatter.welcome.supporter",
"title": "Support the project",
"description": "Become a supporter.\n[Support the project](https://github.com/sponsors/estruyf)",
"media": {
"markdown": "assets/walkthrough/support-the-project.md"
},
"completionEvents": [
"onLink:https://github.com/sponsors/estruyf"
]
}
]
}
]
},
"scripts": {
"dev:ext": "npm run clean && npm run localization:generate && npm-run-all --parallel watch:*",
@@ -2810,4 +2847,4 @@
"dependencies": {
"@radix-ui/react-dropdown-menu": "^2.0.6"
}
}
}
+18
View File
@@ -405,8 +405,13 @@ export class Folders {
* @param folders
*/
public static async update(folders: ContentFolder[]) {
const originalFolders = Settings.get(SETTING_CONTENT_PAGE_FOLDERS) as ContentFolder[];
const wsFolder = Folders.getWorkspaceFolder();
// Filter out the locale folders
folders = folders.filter((folder) => !folder.locale || folder.locale === folder.defaultLocale);
// Remove the internal FM properties
const folderDetails = folders
.map((folder) => {
const detail = {
@@ -418,6 +423,19 @@ export class Folders {
return null;
}
if (detail.locale && detail.locale === detail.defaultLocale) {
// Check if the folder was on the original list
const originalFolder = originalFolders.find((f) => f.path === folder.originalPath);
if (originalFolder && !originalFolder.locales && folder.locales) {
delete detail.locales;
}
delete detail.localeSourcePath;
delete detail.localeTitle;
}
delete detail.locale;
delete detail.originalPath;
return detail;
@@ -42,6 +42,10 @@ const SnippetForm: React.ForwardRefRenderFunction<SnippetFormHandle, ISnippetFor
const insertPlaceholderValues = useCallback(
async (value: SnippetSpecialPlaceholders) => {
if (!value) {
return '';
}
if (value === 'FM_SELECTED_TEXT') {
return selection || '';
}
@@ -141,13 +145,23 @@ ${snippetBody}
const snippetFields = snippet.fields || [];
// Loop over all fields to check if they are present in the snippet
for (const field of snippetFields) {
console.log('placeholders', placeholders);
console.log('snippetFields', snippetFields);
for await (const field of snippetFields) {
console.log('field', field);
const idx = placeholders.findIndex((fieldName) => fieldName === field.name);
if (idx > -1) {
allFields.push({
...field,
value: await insertPlaceholderValues(field.default || '')
});
try {
const value = await insertPlaceholderValues(field.default || '');
console.log('value', value);
allFields.push({
...field,
value
});
} catch (e) {
console.log('Error', (e as Error).message)
}
}
}
+27 -1
View File
@@ -10,7 +10,7 @@ import {
DiagnosticCollection,
languages
} from 'vscode';
import { Folders } from '../commands/Folders';
import { Folders, WORKSPACE_PLACEHOLDER } from '../commands/Folders';
import { Template } from '../commands/Template';
import {
EXTENSION_NAME,
@@ -30,6 +30,7 @@ import { TaxonomyHelper } from './TaxonomyHelper';
import { Cache } from '../commands/Cache';
import * as l10n from '@vscode/l10n';
import { LocalizationKey } from '../localization';
import { parseWinPath } from './parseWinPath';
export class Extension {
private static instance: Extension;
@@ -243,6 +244,31 @@ export class Extension {
}
}
if (major === 10 && minor === 0 && patch < 2) {
let folders = Settings.get<ContentFolder[]>(SETTING_CONTENT_PAGE_FOLDERS) || [];
folders = folders
.filter((f) => !f.locale || f.locale === f.defaultLocale)
.map((f) => {
delete f.locale;
delete f.localeTitle;
if (f.localeSourcePath) {
const wsFolder = Folders.getWorkspaceFolder();
if (wsFolder) {
const localPath = parseWinPath(f.localeSourcePath).replace(
parseWinPath(wsFolder.fsPath),
WORKSPACE_PLACEHOLDER
);
f.path = localPath;
}
delete f.localeSourcePath;
}
return f;
});
await Settings.update(SETTING_CONTENT_PAGE_FOLDERS, folders, true);
}
// The tags and categories settings need to be moved to the database
const tags = Settings.get<string[]>(SETTING_TAXONOMY_TAGS) || [];
const categories = Settings.get<string[]>(SETTING_TAXONOMY_CATEGORIES) || [];
+1 -1
View File
@@ -140,7 +140,7 @@ export class SnippetListener extends BaseListener {
data: { value: string; filePath: string },
requestId?: string
) {
if (!data.value || !command || !requestId) {
if (!command || !requestId) {
return;
}
+1 -1
View File
@@ -17,5 +17,5 @@ export interface ContentFolder {
localeTitle?: string;
localeSourcePath?: string;
defaultLocale?: string;
locales: I18nConfig[];
locales?: I18nConfig[];
}