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
+1 -1
View File
@@ -28,7 +28,7 @@
"gray-matter": "^4.0.3",
"remark-caml": "^0.0.6-rm",
"remark-wikirefs": "^0.0.7-rm",
"semtree": "^0.0.2",
"semtree": "^0.0.4",
"unist-util-select": "^5.0.0",
"wikirefs": "^0.0.4"
}
+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;
+4 -4
View File
@@ -3211,10 +3211,10 @@ section-matter@^1.0.0:
extend-shallow "^2.0.1"
kind-of "^6.0.0"
semtree@^0.0.2:
version "0.0.2"
resolved "https://registry.yarnpkg.com/semtree/-/semtree-0.0.2.tgz#49f1a30d1b8f56e83d2c23ed8cb8c04cc77f9f6a"
integrity sha512-1iybW0+FYQRK7rRirvc7+/GkFl0ik8m6n8EXzBU9spfKT6FHkVy1b6mUfZ1or0rYd3D2E2w1dqh0UerFBxp0zw==
semtree@^0.0.4:
version "0.0.4"
resolved "https://registry.yarnpkg.com/semtree/-/semtree-0.0.4.tgz#2c22727524ad4af4e5c8758a7a7908a79b627abf"
integrity sha512-JUGAa9KLpFLMvPzR1+OA++wL6tGJN71LL5Z6KT5YJVYUn9kBUv2FY5SYvo4tR5aLssO+BWDyoXyMy416SeZawA==
dependencies:
nanoid "^3.3.4"