Implementation of #117: sharing

This commit is contained in:
Zef Hemel
2022-11-24 16:08:51 +01:00
parent 5b1ec14891
commit b61e8ff681
12 changed files with 78 additions and 25 deletions
+6
View File
@@ -30,3 +30,9 @@ export type IndexTreeEvent = {
name: string;
tree: ParseTree;
};
export type PublishEvent = {
uri: string;
// Page name
name: string;
};
+3 -2
View File
@@ -35,7 +35,8 @@ export function extractFrontmatter(
}
// Find FrontMatter and parse it
if (t.type === "FrontMatter") {
const yamlText = renderToText(t.children![1].children![0]);
const yamlNode = t.children![1].children![0];
const yamlText = renderToText(yamlNode);
try {
const parsedData: any = YAML.parse(yamlText);
const newData = { ...parsedData };
@@ -50,7 +51,7 @@ export function extractFrontmatter(
}
}
if (removedOne) {
t.children![0].text = YAML.stringify(newData);
yamlNode.text = YAML.stringify(newData);
}
}
// If nothing is left, let's just delete this whole block