PAGENAME for page instantiations

pull/66/head
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 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;
}

View File

@ -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;
});

View File

@ -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.