{"id":15659755,"url":"https://github.com/zachleat/heading-anchors","last_synced_at":"2025-04-13T11:09:48.107Z","repository":{"id":255419739,"uuid":"849559462","full_name":"zachleat/heading-anchors","owner":"zachleat","description":"Adds and positions sibling anchor links for heading elements (h1–h6) when they have an `id` attribute.","archived":false,"fork":false,"pushed_at":"2025-02-03T21:45:48.000Z","size":23,"stargazers_count":30,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-13T11:09:42.699Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://zachleat.github.io/heading-anchors/demo.html","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zachleat.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-29T20:10:23.000Z","updated_at":"2025-02-06T02:49:00.000Z","dependencies_parsed_at":"2024-08-29T22:37:56.249Z","dependency_job_id":"6ad4372d-e1c1-4646-9f56-12e85cdbf1a8","html_url":"https://github.com/zachleat/heading-anchors","commit_stats":null,"previous_names":["zachleat/heading-anchors"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zachleat%2Fheading-anchors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zachleat%2Fheading-anchors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zachleat%2Fheading-anchors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zachleat%2Fheading-anchors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zachleat","download_url":"https://codeload.github.com/zachleat/heading-anchors/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248703199,"owners_count":21148118,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T13:18:40.807Z","updated_at":"2025-04-13T11:09:48.086Z","avatar_url":"https://github.com/zachleat.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `\u003cheading-anchors\u003e` Web Component\n\nA web component to add and position sibling anchor links for heading elements (`h1`–`h6`) when they have an `id` attribute.\n\nInspired by [David Darnes’ `\u003cheading-anchors\u003e`](https://github.com/daviddarnes/heading-anchors).\n\n* [Demo](https://zachleat.github.io/heading-anchors/demo.html) on GitHub Pages\n\n## Installation\n\n```\nnpm install @zachleat/heading-anchors\n```\n\nInclude the `heading-anchors.js` file on your web site (via `\u003cscript type=\"module\"\u003e`) and use `\u003cheading-anchors\u003e`.\n\n## Features\n\n* Useful when you want preserve heading text as is (selectable, able to nest other links, etc).\n* Useful when you want to exclude anchor links from your RSS feed.\n* Links are positioned alongside heading text, but _not_ nested inside of headings (for improved screen-reader compatibility and accessibility)\n* Establishes a placeholder element to establish space for the anchor link and so that heading text doesn’t reflow during interaction\n* Prefers the CSS Anchoring API (where available) but works using JavaScript positioning when the API is not available.\n* Automatically matches `font` styling of the heading (`font-family`, `line-height`, `font-size`, and `font-weight`)\n\n### Options\n\n* Use the `selector` attribute to change the headings used, e.g. `\u003cheading-anchors selector=\"h2,h3,h4\"\u003e`\n\t* Default: `h2,h3,h4,h5,h6`\n* Internationalization (i18n) friendly using the `prefix` attribute to change the accessible text inside the anchor links, e.g. `\u003cheading-anchors prefix=\"Ir a la sección titulada\"\u003e`\n\t* Default: `Jump to section titled`\n* Use the `content` attribute to change the character used.\n\t* Default: `#`, supports an empty string if you want to use CSS pseudo elements.\n* Style the anchor link using `.ha-placeholder` selector (change font-family, etc).\n* Use the `data-ha-exclude` attribute to opt-out of an anchor link.\n\n### Prior Art\n\n* https://github.com/daviddarnes/heading-anchors\n* https://amberwilson.co.uk/blog/are-your-anchor-links-accessible/ (which has a lot of good related content too)\n\n\n## Advanced\n\n### Eliminate Layout Shift\n\n(Optional) There is a small layout shift by the addition of the `#` character. Add this CSS to make room for this pre-component definition:\n\n```css\nheading-anchors:not(:defined) :is(h2,h3,h4,h5,h6):after {\n\tcontent: \"#\";\n\tpadding: 0 .25em;\n\topacity: 0;\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzachleat%2Fheading-anchors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzachleat%2Fheading-anchors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzachleat%2Fheading-anchors/lists"}