ref: semtree updates.

This commit is contained in:
manunamz
2023-10-12 16:51:30 -04:00
parent 5ef0263482
commit 69bd514f33
6 changed files with 15 additions and 15 deletions
+2 -2
View File
@@ -6,7 +6,7 @@ import { bonsai } from '../wikibonsai/semtree';
const { nodes } = Astro.props;
const root = bonsai ? bonsai.root : '';
const tree = bonsai ? bonsai.tree : [];
const treeNodes = bonsai ? bonsai.nodes : [];
---
<!-- from: https://stackoverflow.com/questions/74126716/how-to-self-reference-astro-component -->
<ul class="branch">
@@ -18,7 +18,7 @@ const tree = bonsai ? bonsai.tree : [];
<a class="invalid">{node.text}</a>
}
<Astro.self nodes={node.children.map(child =>
tree.find(treeNode => treeNode.text == child)
treeNodes.find(tn => tn.text == child)
)} />
</li>
)}
+3 -3
View File
@@ -5,11 +5,11 @@ import { bonsai } from '../wikibonsai/semtree';
const { current } = Astro.props;
const root = bonsai ? bonsai.root : '';
const tree = bonsai ? bonsai.tree : [];
const treeNodes = bonsai ? bonsai.nodes : [];
const curNode = tree.find(node => node.text == current);
const curNode = treeNodes.find(tn => tn.text == current);
const ancestors = curNode ? curNode.ancestors : [];
const ancestorNodes = ancestors.map(n => tree.find(tn => tn.text == n));
const ancestorNodes = ancestors.map(an => treeNodes.find(tn => tn.text == an));
---
<style>
ol {
+2 -2
View File
@@ -8,7 +8,7 @@ import { SITE_TITLE, SITE_DESCRIPTION } from '../consts';
import { bonsai } from '../wikibonsai/semtree';
const root = bonsai ? bonsai.root : '';
const tree = bonsai ? bonsai.tree : [];
const treeNodes = bonsai ? bonsai.nodes : [];
---
<!doctype html>
@@ -20,7 +20,7 @@ const tree = bonsai ? bonsai.tree : [];
<Header title={SITE_TITLE} />
<main>
<h1>Tag Map</h1>
<Branch nodes={tree.filter(node => node.text === root)} />
<Branch nodes={treeNodes.filter(tn => tn.text === root)} />
</main>
<Footer />
</body>
+3 -3
View File
@@ -22,14 +22,14 @@ export async function buildBonsai() {
res = bonsai.parse(bonsaiText, rootFilename);
// append url for template rendering and init fam metadata
const allEntryDocs = await getCollection('entries');
for (const node of bonsai.tree) {
for (const node of bonsai.nodes) {
const doc: any = allEntryDocs.find((doc) => path.basename(doc.id, '.md') == node.text);
if (doc !== undefined) {
node.url = '/entries/' + doc.slug;
}
}
// uncomment if 'virtualTrunk' is set to 'false'
// for (const node of bonsai.tree) {
// for (const node of bonsai.nodes) {
// const doc: any = allIndexDocs.find((doc) => path.basename(doc.id, '.md') == node.text);
// if (doc !== undefined) {
// node.url = '/index/' + doc.slug;
@@ -37,7 +37,7 @@ export async function buildBonsai() {
// }
// uncomment in case blog posts are desired on the #tag map
// const allBlogDocs = await getCollection('blog');
// for (const node of bonsai.tree) {
// for (const node of bonsai.nodes) {
// const doc: any = allBlogDocs.find((doc) => path.basename(doc.id, '.md') == node.text);
// if (doc !== undefined) {
// node.url = '/blog/' + doc.slug;