Switch over to WebAssembly, Rust and Yew #35

Merged
BlakeRain merged 87 commits from yew-static into main 2023-08-30 18:01:40 +00:00
2 changed files with 25 additions and 1 deletions
Showing only changes of commit f1a1216a7c - Show all commits

View File

@ -475,11 +475,13 @@ where
match tag {
Tag::Paragraph => self.enter(RenderElement::new(TagName::P)),
Tag::Heading(level, ident, classes) => {
Tag::Heading(level, ident, mut classes) => {
let mut heading = RenderElement::new(heading_for_level(level));
if let Some(ident) = ident {
heading.add_attribute(AttributeName::Id, ident.to_string());
classes.push("with-anchor");
classes.push("group");
}
if !classes.is_empty() {
@ -488,6 +490,14 @@ where
}
self.enter(heading);
if let Some(ident) = ident {
let mut anchor = RenderElement::new(TagName::A);
anchor.add_attribute(AttributeName::Href, format!("#{}", ident));
anchor.add_attribute(AttributeName::Class, "group-hover:block");
anchor.add_child(RenderIcon::Link);
self.output(anchor);
}
}
Tag::BlockQuote => self.enter(RenderElement::new(TagName::BlockQuote)),

View File

@ -18,6 +18,20 @@
h5,
h6 {
@apply w-full font-sans;
&.with-anchor {
@apply relative;
> a {
@apply hidden absolute top-2 -left-8;
@apply text-gray-500 dark:text-gray-400;
@apply hover:text-gray-400 dark:hover:text-gray-300;
> svg {
@apply w-8 h-8;
}
}
}
}
h1,