From 3589aadbb37dd9dd21c6c8f73847cf600c8cf64f Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Mon, 8 Aug 2022 13:09:19 +0200 Subject: [PATCH] PAGENAME for page instantiations --- packages/plugs/core/template.ts | 4 ++-- packages/plugs/query/data.ts | 4 ++++ website/CHANGELOG.md | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/plugs/core/template.ts b/packages/plugs/core/template.ts index a52876ef..a2266496 100644 --- a/packages/plugs/core/template.ts +++ b/packages/plugs/core/template.ts @@ -42,10 +42,10 @@ export async function instantiateTemplateCommand() { let { text } = await readPage(selectedTemplate.name); let parseTree = await parseMarkdown(text); - let additionalPageMeta = extractMeta(parseTree, ["name"]); + let additionalPageMeta = extractMeta(parseTree, ["PAGENAME"]); console.log("Page meta", additionalPageMeta); - let pageName = await prompt("Name of new page", additionalPageMeta.name); + let pageName = await prompt("Name of new page", additionalPageMeta.PAGENAME); if (!pageName) { return; } diff --git a/packages/plugs/query/data.ts b/packages/plugs/query/data.ts index eded6a1d..10132990 100644 --- a/packages/plugs/query/data.ts +++ b/packages/plugs/query/data.ts @@ -107,6 +107,10 @@ export function extractMeta( delete newData[key]; } codeTextNode.children![0].text = stringifyYaml(newData).trim(); + // If nothing is left, let's just delete this thing + if (Object.keys(newData).length === 0) { + return null; + } } return undefined; }); diff --git a/website/CHANGELOG.md b/website/CHANGELOG.md index ba3dea5a..a4bc2376 100644 --- a/website/CHANGELOG.md +++ b/website/CHANGELOG.md @@ -1,5 +1,8 @@ An attempt at documenting of the changes/new features introduced in each (pre) release. +## 0.0.31 +* For the `Template: Instantiate Page` command, the page meta value `PAGENAME` is now used to configure the page name (was `name` before). Also if `PAGENAME` is the only page meta defined, it will remove the page meta entirely when instantiating. + ## 0.0.30 * Slash commands now only trigger after a non-word character to avoid "false positives" like "hello/world". * Page auto complete now works with slashes in the name.