Skip to content

Commit

Permalink
Adds ignore attribute for 11ty/eleventy#3363
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Sep 30, 2024
1 parent 82df21d commit c8b7a8b
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/docs/plugins/id-attribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ eleventyNavigation:
excerpt: A plugin to add `id` attributes to headings.
---

# Id Attribute
# Id Attribute {% addedin "3.0.0-beta.1" %}

{% tableofcontents %}

Expand All @@ -20,7 +20,7 @@ This is best paired with a user interface piece to add anchor links to heading e
* [`<heading-anchors>` from David Darnes](https://github.com/daviddarnes/heading-anchors)
* [`<heading-anchors>` from Zach Leatherman](https://github.com/zachleat/heading-anchors) (only for anchor links as siblings)

## Example
## Examples

```html
<h1>Welcome to Eleventy</h1>
Expand All @@ -32,12 +32,27 @@ is transformed into:
<h1 id="welcome-to-eleventy">Welcome to Eleventy</h1>
```

### Ignore a node {% addedin "3.0.0-beta.2" %}

Use the `eleventy:id-ignore` attribute on a child node to ignore it (only for the purposes of `id` attribute generation).

```html
<h1>Welcome to Eleventy<span eleventy:id-ignore> ignore this</span></h1>
```

is transformed into:

```html
<h1 id="welcome-to-eleventy">Welcome to Eleventy</h1>
```

## Usage

This plugin is bundled with Eleventy and requires no additional installation.
This plugin is bundled with Eleventy and requires no additional package installation (though you do need to opt-in via `addPlugin`).

{% include "snippets/plugins/idattr.njk" %}

### With options

{% include "snippets/plugins/idattr-opts.njk" %}

0 comments on commit c8b7a8b

Please sign in to comment.