{"id":30389296,"url":"https://github.com/oom-components/toc","last_synced_at":"2025-08-21T08:19:06.591Z","repository":{"id":307844455,"uuid":"1029223533","full_name":"oom-components/toc","owner":"oom-components","description":"Web component to create a table of content","archived":false,"fork":false,"pushed_at":"2025-08-02T15:50:19.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-02T16:03:28.718Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://oom-components.github.io/toc/demo/","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/oom-components.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2025-07-30T17:51:58.000Z","updated_at":"2025-08-02T15:52:57.000Z","dependencies_parsed_at":"2025-08-02T16:03:30.429Z","dependency_job_id":"ad90a3b5-46a8-46fa-b7c2-e92460d47f89","html_url":"https://github.com/oom-components/toc","commit_stats":null,"previous_names":["oom-components/toc"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/oom-components/toc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oom-components%2Ftoc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oom-components%2Ftoc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oom-components%2Ftoc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oom-components%2Ftoc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oom-components","download_url":"https://codeload.github.com/oom-components/toc/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oom-components%2Ftoc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271448405,"owners_count":24761441,"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","status":"online","status_checked_at":"2025-08-21T02:00:08.990Z","response_time":74,"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":[],"created_at":"2025-08-21T08:19:06.028Z","updated_at":"2025-08-21T08:19:06.571Z","avatar_url":"https://github.com/oom-components.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Table of contents\n\nWeb component to create a table of contents.\n\n- No dependencies\n- Very light\n- Follow the **progressive enhancement strategy**. If JavaScript fails the page\n  continue working.\n- No styles or themes are provided with this package.\n- Build with modern JavaScript.\n\n## Usage\n\nImport and register the component with the desired tag name:\n\n```js\nimport Toc from \"toc/toc.js\";\n\ncustomElements.define(\"oom-toc\", Toc);\n```\n\nUse it in the HTML code. The `data-target` attribute must contain the id of the\ntext container:\n\n```html\n\u003cnav\u003e\n  \u003ch2\u003eTable of contents\u003c/h2\u003e\n\n  \u003coom-toc data-target=\"main-content\"\u003e\n    Fallback text if something fails\n  \u003c/oom-toc\u003e\n\u003c/nav\u003e\n\n\u003cdiv id=\"main-content\"\u003e\n  \u003ch2\u003eLorem Ipsum Dolor Sit Amet\u003c/h2\u003e\n  ...\n  \u003ch3\u003eConsectetur Adipiscing\u003c/h3\u003e\n  ...\n\u003c/div\u003e\n```\n\n## Anchors\n\nAnchors are created automatically if they are missing. For example:\n\n```html\n\u003ch2\u003eOne\u003c/h2\u003e\n\u003ch2 id=\"two\"\u003eTwo\u003c/h2\u003e\n\u003ch2\u003e\u003ca id=\"three\" href=\"#three\"\u003eThree\u003c/a\u003e\u003c/h2\u003e\n```\n\nThe component makes the following changes:\n\n```html\n\u003ch2 id=\"one\"\u003e\u003ca href=\"one\"\u003eOne\u003c/a\u003e\u003c/h2\u003e\n\u003ch2 id=\"two\"\u003e\u003ca href=\"two\"\u003eTwo\u003c/a\u003e\u003c/h2\u003e\n\u003ch2\u003e\u003ca id=\"three\" href=\"#three\"\u003eThree\u003c/a\u003e\u003c/h2\u003e\n```\n\n- It creates the id automatically using the text content of the heading.\n- It creates the anchor automatically if it's missing\n- If the id and/or anchor is detected, it does nothing.\n\nIf you want a different anchor style, you can override the `anchorCreator`\nstatic property:\n\n```js\nimport Toc from \"toc/toc.js\";\n\n// \u003ch2\u003e\u003ca href=\"#id\"\u003eanchor\u003c/a\u003eHeader\u003c/h2\u003e\nToc.anchorCreator = (heading, id) =\u003e {\n  const a = document.createElement(\"a\");\n  a.href = `#${id}`;\n  a.innerHTML = \"anchor\";\n  heading.prepend(a);\n};\n\ncustomElements.define(\"oom-toc\", Toc);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foom-components%2Ftoc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foom-components%2Ftoc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foom-components%2Ftoc/lists"}