Created
September 7, 2023 12:23
-
-
Save fractaledmind/7b52e7e84b396780dcb99f5e0c81f4e6 to your computer and use it in GitHub Desktop.
Minimal requirements for linked headings in a BridgetownRB site
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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