uswds-jekyll
uswds-jekyll copied to clipboard
Is anchorjs working properly?
I followed the instructions and uncommented the line in my _config.yml that I think enabled anchorJS...
anchor_js_targets: [h1, h2, h3, h4, h5, h6]
When I generate my site, I do not see the anchor links after my headers.
Looking at the generated source, I see
<script src="/source-code/assets/js/vendor/anchor.min.js"></script>
but I never see a call to anchors.add()
I might be misunderstanding how this is used. Do you have a link to a site using this feature so I can figure out what I'm doing wrong?
This file is where the add()
is called.
I had to ensure my headers were within a .usa-layout-docs
element.
Here's a screenshot of the anchor showing
I think I must have missed something when I added this to the USWDS issue queue https://github.com/uswds/uswds/issues/4166
Are anchor links already part of the USWDS?
I'm just coming across this now after we've developed a similar solution https://accessibility.civicactions.com/guide/tools#site-wide-evaluation
Code is up here https://github.com/CivicActions/accessibility
How do we set this up so anchor link are just part of the default for H2-H4 headings? That seems like something that would be a good default for most Jekyll pages. Maybe not all, but there is no reason that this isn't something that is controlled when defining the page type.
I'd also prefer not to use JS if there is an alternative (and there is). Anyways, would love your feedback @ryanhofdotgov