Skip to content

Instantly share code, notes, and snippets.

@fractaledmind
Created September 7, 2023 12:23
Show Gist options
  • Save fractaledmind/7b52e7e84b396780dcb99f5e0c81f4e6 to your computer and use it in GitHub Desktop.
Save fractaledmind/7b52e7e84b396780dcb99f5e0c81f4e6 to your computer and use it in GitHub Desktop.
Minimal requirements for linked headings in a BridgetownRB site
[aria-hidden="true"] {
visibility: hidden;
}
.anchor {
text-decoration: none;
}
h2:hover .anchor,
h3:hover .anchor,
h4:hover .anchor,
h5:hover .anchor,
h6:hover .anchor {
visibility: visible;
}
class Builders::Inspectors < SiteBuilder
def build
inspect_html do |document|
document.css("main h2[id],h3[id],h4[id],h5[id],h6[id]").each do |heading|
heading << %(
<a href="##{heading[:id]}" class="anchor" aria-hidden="true">#</a>
)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment