a funny gag

This commit is contained in:
liquidex 2023-08-22 22:32:40 +02:00
parent 1225f6d313
commit 7ed058a9db
6 changed files with 22 additions and 8 deletions

View file

@ -41,14 +41,9 @@
+ *where?* + *where?*
% id = "01H89RFHCQW4NN6PW6V6RFCVH3" % id = "01H89RFHCQW4NN6PW6V6RFCVH3"
content.link = "about-treehouse/uh"
+ ***WHERE???*** + ***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" % id = "01H89RFHCQPAMNSN81SRVH2TZ5"
- always evolving and shaping and shifting - always evolving and shaping and shifting

View file

@ -0,0 +1,3 @@
% content.link = "about-treehouse/uh"
do_not_persist = true
+ …

View file

@ -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)?; std::fs::write(target_path, templated_html)?;
} }
} }

View file

@ -37,9 +37,15 @@ pub fn branch_to_html(
String::new() String::new()
}; };
let do_not_persist = if branch.attributes.do_not_persist {
" data-th-do-not-persist=\"\""
} else {
""
};
write!( write!(
s, s,
"<li is=\"{component}\" class=\"{class}\" id=\"{}\"{linked_branch}>", "<li is=\"{component}\" class=\"{class}\" id=\"{}\"{linked_branch}{do_not_persist}>",
EscapeAttribute(&branch.html_id) EscapeAttribute(&branch.html_id)
) )
.unwrap(); .unwrap();

View file

@ -13,6 +13,10 @@ pub struct Attributes {
/// Controls how the block should be presented. /// Controls how the block should be presented.
#[serde(default)] #[serde(default)]
pub content: Content, pub content: Content,
/// Do not persist the branch in localStorage.
#[serde(default)]
pub do_not_persist: bool,
} }
/// Controls for block content presentation. /// Controls for block content presentation.

View file

@ -17,8 +17,9 @@ class Branch extends HTMLLIElement {
this.details = this.childNodes[0]; this.details = this.childNodes[0];
this.innerUL = this.details.childNodes[1]; this.innerUL = this.details.childNodes[1];
let doPersist = !this.hasAttribute("data-th-do-not-persist");
let isOpen = branchIsOpen(this.id); let isOpen = branchIsOpen(this.id);
if (isOpen !== undefined) { if (doPersist && isOpen !== undefined) {
this.details.open = isOpen; this.details.open = isOpen;
} }
this.details.addEventListener("toggle", _ => { this.details.addEventListener("toggle", _ => {