From 2b0ad94b8b824011436830d1b149339c4210e982 Mon Sep 17 00:00:00 2001 From: Waldek Mastykarz Date: Mon, 26 Aug 2019 13:21:45 +0200 Subject: [PATCH] Added support for *.markdown Added support for sorting tags and categories --- src/commands/FrontMatter.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/commands/FrontMatter.ts b/src/commands/FrontMatter.ts index 06da6363..0333df79 100644 --- a/src/commands/FrontMatter.ts +++ b/src/commands/FrontMatter.ts @@ -133,11 +133,14 @@ export class FrontMatter { // Retrieve all the Markdown files const mdFiles = await vscode.workspace.findFiles('**/*.md', "**/node_modules/**"); - if (!mdFiles) { + const markdownFiles = await vscode.workspace.findFiles('**/*.markdown', "**/node_modules/**"); + if (!mdFiles && !markdownFiles) { vscode.window.showInformationMessage(`No MD files found.`); return; } + const allMdFiles = mdFiles.concat(markdownFiles); + vscode.window.withProgress({ location: vscode.ProgressLocation.Notification, title: `Front Matter: exporting tags and categories`, @@ -148,11 +151,11 @@ export class FrontMatter { let categories: string[] = []; // Set the initial progress - const progressNr = mdFiles.length/100; + const progressNr = allMdFiles.length/100; progress.report({ increment: 0}); let i = 0; - for (const file of mdFiles) { + for (const file of allMdFiles) { progress.report({ increment: (++i/progressNr) }); const mdFile = await vscode.workspace.openTextDocument(file); if (mdFile) { @@ -184,6 +187,7 @@ export class FrontMatter { crntTags = [...crntTags, ...tags]; // Update the tags and filter out the duplicates crntTags = [...new Set(crntTags)]; + crntTags = crntTags.sort(); config.update(ACTION_TAXONOMY_TAGS, crntTags); // Retrieve the currently known tags, and add the new ones @@ -192,6 +196,7 @@ export class FrontMatter { crntCategories = [...crntCategories, ...categories]; // Update the categories and filter out the duplicates crntCategories = [...new Set(crntCategories)]; + crntCategories = crntCategories.sort(); config.update(ACTION_TAXONOMY_CATEGORIES, crntCategories); // Done