{"id":50825576,"url":"https://github.com/rgglez/astro-tocbutton","last_synced_at":"2026-06-13T18:40:07.479Z","repository":{"id":361016606,"uuid":"1252729344","full_name":"rgglez/astro-tocbutton","owner":"rgglez","description":"A floating button which shows a TOC for blog posts in an Astro-based blog.","archived":false,"fork":false,"pushed_at":"2026-05-28T21:14:22.000Z","size":59,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-28T22:12:36.930Z","etag":null,"topics":["astro","astro-blog","astro-paper","toc-generator"],"latest_commit_sha":null,"homepage":"","language":"Astro","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rgglez.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-28T20:11:15.000Z","updated_at":"2026-05-28T21:14:22.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/rgglez/astro-tocbutton","commit_stats":null,"previous_names":["rgglez/astro-tocbutton"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/rgglez/astro-tocbutton","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rgglez%2Fastro-tocbutton","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rgglez%2Fastro-tocbutton/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rgglez%2Fastro-tocbutton/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rgglez%2Fastro-tocbutton/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rgglez","download_url":"https://codeload.github.com/rgglez/astro-tocbutton/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rgglez%2Fastro-tocbutton/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34296382,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-13T02:00:06.617Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["astro","astro-blog","astro-paper","toc-generator"],"created_at":"2026-06-13T18:40:06.464Z","updated_at":"2026-06-13T18:40:07.451Z","avatar_url":"https://github.com/rgglez.png","language":"Astro","funding_links":[],"categories":[],"sub_categories":[],"readme":"# astro-tocbutton\n\n[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n![GitHub all releases](https://img.shields.io/github/downloads/rgglez/astro-tocbutton/total)\n![GitHub issues](https://img.shields.io/github/issues/rgglez/astro-tocbutton)\n![GitHub commit activity](https://img.shields.io/github/commit-activity/y/rgglez/astro-tocbutton)\n[![GitHub release](https://img.shields.io/github/release/rgglez/astro-tocbutton.svg)](https://github.com/rgglez/astro-tocbutton/releases/)\n![GitHub stars](https://img.shields.io/github/stars/rgglez/astro-tocbutton?style=social)\n![GitHub forks](https://img.shields.io/github/forks/rgglez/astro-tocbutton?style=social)\n\n**astro-tocbutton** generates a floating table-of-contents button for Astro blog posts. Reads `h2`–`h6` headings from a `#article` element and renders a popover with navigation links. Positioned bottom-left by default (so it does not conflict with a bottom-right back-to-top button), and configurable to any corner. RTL-aware: placement mirrors automatically under `dir=\"rtl\"`.\n\n## Installation\n\n```bash\nnpm install @rgglez/astro-tocbutton\n```\n\n## Usage\n\n```astro\nimport TocButton from \"@rgglez/astro-tocbutton\";\n\n\u003cTocButton /\u003e\n```\n\n### Optional props\n\n| Prop       | Type                                                         | Default          | Description                                                                 |\n|------------|-------------------------------------------------------------|------------------|-----------------------------------------------------------------------------|\n| `label`    | `string`                                                    | `\"Table of contents\"` | `aria-label` for the toggle button                                     |\n| `position` | `\"bottom-left\" \\| \"bottom-right\" \\| \"top-left\" \\| \"top-right\"` | `\"bottom-left\"`  | Fixed corner for the button. Uses logical edges, so it mirrors under RTL.   |\n\n```astro\n\u003cTocButton position=\"top-right\" label=\"On this page\" /\u003e\n```\n\nUnder `dir=\"rtl\"`, `*-left` placements resolve to the right edge and `*-right` to the left (the inline-start/inline-end edges flip automatically).\n\n## Requirements\n\n- **Astro ≥ 5.7** — the icon is imported as a native SVG component (`import Icon from \"./icon.svg\"`), supported from Astro 5.7 onward.\n- The article content must be wrapped in an element with `id=\"article\"`. Headings (`h2`–`h6`) inside it must have `id` attributes (Astro / remark sets these automatically for markdown/MDX).\n- [Tailwind CSS](https://tailwindcss.com/) **≥ 3.3** must be configured in your project (logical `start-*`/`end-*` utilities, used for RTL-aware positioning, were added in 3.3). If using Tailwind v4, add the package source to your content scan so utility classes are not purged:\n\n```css\n/* global.css (v4) */\n@source \"../node_modules/@rgglez/astro-tocbutton/src\";\n```\n\n## Behavior\n\n- Button is always visible on pages that contain headings; hidden if `#article` has none.\n- Clicking the button opens/closes a popover anchored to it (above the button for `bottom-*` positions, below it for `top-*`).\n- Headings are indented by level: `h2` = no indent, `h3` = `pl-4`, `h4` = `pl-8`, `h5` = `pl-10`, `h6` = `pl-12`.\n- Clicking a heading link closes the popover and scrolls to the section.\n- Also closes on **Escape** or click outside.\n- Compatible with Astro View Transitions (`data-astro-rerun` guard prevents duplicate listeners).\n\n## Development\n\n| Target        | Description                                               |\n|---------------|-----------------------------------------------------------|\n| `make tags`   | List git tags sorted by semver (descending)               |\n| `make patch`  | Bump PATCH version in `package.json`, commit, tag, push   |\n| `make publish`| Publish current version to npm                            |\n\nTypical release flow: `make patch` → `make publish`.\n\n## License\n\nCopyright (C) 2026 Rodolfo González González.\n\nLicensed under the [Apache v2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) license. Read the [LICENSE](LICENSE) file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frgglez%2Fastro-tocbutton","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frgglez%2Fastro-tocbutton","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frgglez%2Fastro-tocbutton/lists"}