1
0

PAGENAME for page instantiations

This commit is contained in:
Zef Hemel 2022-08-08 13:09:19 +02:00
parent 7cbc6db5e1
commit 3589aadbb3
3 changed files with 9 additions and 2 deletions

View File

@ -42,10 +42,10 @@ export async function instantiateTemplateCommand() {
let { text } = await readPage(selectedTemplate.name); let { text } = await readPage(selectedTemplate.name);
let parseTree = await parseMarkdown(text); let parseTree = await parseMarkdown(text);
let additionalPageMeta = extractMeta(parseTree, ["name"]); let additionalPageMeta = extractMeta(parseTree, ["PAGENAME"]);
console.log("Page meta", additionalPageMeta); 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) { if (!pageName) {
return; return;
} }

View File

@ -107,6 +107,10 @@ export function extractMeta(
delete newData[key]; delete newData[key];
} }
codeTextNode.children![0].text = stringifyYaml(newData).trim(); 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; return undefined;
}); });

View File

@ -1,5 +1,8 @@
An attempt at documenting of the changes/new features introduced in each (pre) release. 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 ## 0.0.30
* Slash commands now only trigger after a non-word character to avoid "false positives" like "hello/world". * 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. * Page auto complete now works with slashes in the name.