diff --git a/content/about-treehouse.tree b/content/about-treehouse.tree index a833e95..8215682 100644 --- a/content/about-treehouse.tree +++ b/content/about-treehouse.tree @@ -41,14 +41,9 @@ + *where?* % id = "01H89RFHCQW4NN6PW6V6RFCVH3" + content.link = "about-treehouse/uh" + ***WHERE???*** - % id = "01H89RFHCQ83APVW034YC40K5P" - + here, actually. - - % id = "01H89RFHCQ0SYWSQZDYHRXKAR0" - - I lied. I didn't build this tech to support infinite nesting, as that would require infinite disk space. which I don't have. - % id = "01H89RFHCQPAMNSN81SRVH2TZ5" - always evolving and shaping and shifting diff --git a/content/about-treehouse/uh.tree b/content/about-treehouse/uh.tree new file mode 100644 index 0000000..9b5044c --- /dev/null +++ b/content/about-treehouse/uh.tree @@ -0,0 +1,3 @@ +% content.link = "about-treehouse/uh" + do_not_persist = true ++ … diff --git a/crates/treehouse/src/cli/regenerate.rs b/crates/treehouse/src/cli/regenerate.rs index 8ae097d..1b5dee0 100644 --- a/crates/treehouse/src/cli/regenerate.rs +++ b/crates/treehouse/src/cli/regenerate.rs @@ -154,6 +154,11 @@ impl Generator { } }; + std::fs::create_dir_all( + target_path + .parent() + .expect("there should be a parent directory to generate files into"), + )?; std::fs::write(target_path, templated_html)?; } } diff --git a/crates/treehouse/src/html/tree.rs b/crates/treehouse/src/html/tree.rs index 4892cfc..6363ace 100644 --- a/crates/treehouse/src/html/tree.rs +++ b/crates/treehouse/src/html/tree.rs @@ -37,9 +37,15 @@ pub fn branch_to_html( String::new() }; + let do_not_persist = if branch.attributes.do_not_persist { + " data-th-do-not-persist=\"\"" + } else { + "" + }; + write!( s, - "
  • ", + "
  • ", EscapeAttribute(&branch.html_id) ) .unwrap(); diff --git a/crates/treehouse/src/tree/attributes.rs b/crates/treehouse/src/tree/attributes.rs index 9953d6e..080b385 100644 --- a/crates/treehouse/src/tree/attributes.rs +++ b/crates/treehouse/src/tree/attributes.rs @@ -13,6 +13,10 @@ pub struct Attributes { /// Controls how the block should be presented. #[serde(default)] pub content: Content, + + /// Do not persist the branch in localStorage. + #[serde(default)] + pub do_not_persist: bool, } /// Controls for block content presentation. diff --git a/static/js/tree.js b/static/js/tree.js index 68c3de8..9b2eb73 100644 --- a/static/js/tree.js +++ b/static/js/tree.js @@ -17,8 +17,9 @@ class Branch extends HTMLLIElement { this.details = this.childNodes[0]; this.innerUL = this.details.childNodes[1]; + let doPersist = !this.hasAttribute("data-th-do-not-persist"); let isOpen = branchIsOpen(this.id); - if (isOpen !== undefined) { + if (doPersist && isOpen !== undefined) { this.details.open = isOpen; } this.details.addEventListener("toggle", _ => {