ref: semtree updates.
This commit is contained in:
@@ -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>
|
||||
)}
|
||||
|
||||
@@ -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
@@ -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>
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user