diff --git a/packages/cli/src/commands/make-site.tsx b/packages/cli/src/commands/make-site.tsx
index 2b7313d..77b118a 100644
--- a/packages/cli/src/commands/make-site.tsx
+++ b/packages/cli/src/commands/make-site.tsx
@@ -1,5 +1,5 @@
import { RenderContext } from "@rdf-toolkit/explorer-views/context";
-import renderHTML, { HtmlContent } from "@rdf-toolkit/explorer-views/jsx/html";
+import renderHTML, { HtmlContent, HtmlElement } from "@rdf-toolkit/explorer-views/jsx/html";
import renderMain from "@rdf-toolkit/explorer-views/pages/main";
import renderNavigation from "@rdf-toolkit/explorer-views/pages/navigation";
import renderFooter from "@rdf-toolkit/explorer-views/sections/footer";
@@ -188,22 +188,64 @@ function renderPage(iri: string, context: Website, links: HtmlContent, scripts:
const main = renderMain(subject, iri in context.documents ? context.documents[iri] : null, context);
- return
-
-
- {title} – {context.title}
- {links}
- {scripts}
-
-
-
-
- {main}
-
-
- ;
+ // from the context, get the IRI
+ const iri_class: Class | undefined = context.schema.classes.get(subject);
+ // get all of the parent classes of 'iri_class' by iterating over the 'subClassOf' property.
+ // Do this recursively until there are no more parent classes.
+ const reachable_classes: Class[] = [];
+ function get_reachable_classes(class_: Class) {
+ reachable_classes.push(class_);
+ for (const parent_class of class_.subClassOf as IRIOrBlankNode[]) {
+ // get the class object from the IRI
+ const defn = context.schema.classes.get(parent_class);
+ // if it's not null, then call the function recursively
+ if (defn) {
+ get_reachable_classes(defn);
+ }
+ }
+ }
+ if (iri_class) {
+ get_reachable_classes(iri_class);
+ }
+
+
+ // generate the source for a javascript function which sets the open attribute
+ // on all elements in the document if the class is in the 'reachable_classes' array
+ const script = `
+ function set_open() {
+ const details = document.querySelectorAll("details");
+ const reachable_classes = [${reachable_classes.map(c => `"${c.id.value}"`).join(", ")}];
+ for (const detail of details) {
+ const iri = detail.getAttribute("iri");
+ console.log(iri);
+ if (reachable_classes.includes(iri)) {
+ detail.open = true;
+ }
+ }
+ }
+ document.addEventListener("DOMContentLoaded", set_open);
+ `;
+
+ // Render the HTML
+ return (
+
+
+
+ {title} – {context.title}
+ {links}
+ {scripts}
+
+
+
+
+
+ {main}
+
+
+
+ );
}
function resolveHref(url: string, base: string): string {
diff --git a/packages/explorer-views/src/components/treeview.tsx b/packages/explorer-views/src/components/treeview.tsx
index e3b87e5..c84d2e4 100644
--- a/packages/explorer-views/src/components/treeview.tsx
+++ b/packages/explorer-views/src/components/treeview.tsx
@@ -1,8 +1,10 @@
import { Ix } from "@rdf-toolkit/iterable";
+import { IRI, IRIOrBlankNode } from "@rdf-toolkit/rdf/terms";
import { HtmlContent } from "../jsx/html.js";
import "./treeview.css";
export interface TreeNode {
+ readonly id: IRIOrBlankNode;
readonly label: HtmlContent;
readonly children?: Iterable;
readonly open?: boolean;
@@ -13,7 +15,7 @@ function renderNode(node: TreeNode, depth: number): HtmlContent {
.map(child => renderNode(child, node.open ? 1 : depth + 1))
.wrap(children =>