Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The IdAttributePlugin can create conflicts #3424

Closed
vrugtehagel opened this issue Aug 26, 2024 · 2 comments
Closed

The IdAttributePlugin can create conflicts #3424

vrugtehagel opened this issue Aug 26, 2024 · 2 comments
Labels

Comments

@vrugtehagel
Copy link
Contributor

vrugtehagel commented Aug 26, 2024

Operating system

macOS Sonoma 14.6.1

Eleventy

3.0.0-beta.1

Describe the bug

The plugin does not check for existing id attributes in the markup, only ones created for headers previously. That means the following markup (from a real example):

<section id="thank-you">
  <h2>Thank you!</h2>
  <p></p>
</section>

Will output

<section id="thank-you">
  <h2 id="thank-you">Thank you!</h2>
  <p></p>
</section>

Solutions

There are two solutions I can think of:

  1. Allow users to opt-out (or in) on a per-page basis. Ones of the sites I manage had two occurrances of clashing id attributes as a result of adding this plugin, but many pages don't actually need the ids for the headers. It'd be nice if I could opt-in on a per-page basis, so that these issues would be less prevalent.
  2. Alternatively, and I recognize this might be more computationally expensive; check the entire page HTML for id attributes to avoid the conflicts.
@zachleat
Copy link
Member

zachleat commented Sep 3, 2024

Fixed in #3430

@zachleat zachleat added this to the Eleventy 3.0.0 milestone Sep 3, 2024
@zachleat
Copy link
Member

Upstream #3363

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants
@zachleat @vrugtehagel and others