{"_id":"@carrotwu/generatoc","_rev":"2-016e9f98e960d5e5364bd87de885b02d","name":"@carrotwu/generatoc","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@carrotwu/generatoc","version":"1.0.0","description":"Automatically generate table of content from heading of HTML document（ forked from https://github.com/gadzan/generatoc/）","main":"dist/index.js","scripts":{"test":"jest --coverage && coveralls < coverage/lcov.info","jest":"jest --coverage","build":"rollup -c","dev":"rollup -w -c rollup.config.dev.js","release":"npm publish"},"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/carrot-wu/generatoc.git"},"types":"dist/index.d.ts","keywords":["toc","javascript","typescript","table","of","contents","generate","html","structure","SSR"],"author":{"name":"Gadzan"},"license":"MIT","bugs":{"url":"https://github.com/carrot-wu/generatoc/issues"},"homepage":"https://github.com/carrot-wu/generatoc/","devDependencies":{"@babel/core":"^7.9.6","@babel/preset-env":"^7.9.6","@babel/preset-typescript":"^7.9.0","@rollup/plugin-babel":"^5.0.0","@rollup/plugin-buble":"^0.21.3","@rollup/plugin-node-resolve":"^7.1.3","@rollup/plugin-typescript":"^4.1.1","@types/jest":"^25.2.2","coveralls":"^3.1.0","eslint":"^7.0.0","jest":"^26.0.1","postcss-preset-env":"^6.7.0","rollup":"^2.10.0","rollup-plugin-postcss":"^3.1.1","rollup-plugin-serve":"^1.0.1","rollup-plugin-sourcemaps":"^0.6.2","rollup-plugin-terser":"^5.3.0","rollup-plugin-typescript2":"^0.27.1","ts-jest":"^25.5.1","tslib":"^2.0.0","typescript":"^3.8.3"},"gitHead":"ea5400664b64f10bc1d77da63dfb2aa20adcdd54","_id":"@carrotwu/generatoc@1.0.0","_nodeVersion":"12.16.3","_npmVersion":"6.14.5","dist":{"integrity":"sha512-gitnOhgOTR1jCJPG5NSkr1p/Gnuzd5H8Ma+SlD3VV9AVR53GmbA17AmWs7sz1nrHxG7AywtaQ/Hb60WMCQrbXQ==","shasum":"914f6d6cf7e7ba28f2f009411f4d5464bc18a16f","tarball":"https://registry.npmjs.org/@carrotwu/generatoc/-/generatoc-1.0.0.tgz","fileCount":16,"unpackedSize":47420,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfYe2cCRA9TVsSAnZWagAANKIP/1KuJrx27QqiTsDddF/p\ntJxwJSlxL738CwKzhGxfytGwzFE5z8wauepKb0FY3I1CZ7qEfWPvvE0pyYDG\nQlNxgMysWzYalgoTRo1eENL7Ua0qoDMcUUnDF4ELEQNh/KzPjwMMJTt5twqZ\n6fvkqvSPM4IuIK9QWpRiuGoCs2lsqQrUN3FLBDBc/uO9e8uwGdnzupnDSXrV\nVpz3eK2hbaEzt8504mbXDvLqbyRJ2wGputejsNZhw7sD6X54Uqf+r2YooszR\nR26FT6JAWZBjXAy7yG9Mj+Lu+SHff/YEYXAuV4jV0g9q5Xx02ZpAYl4Qp6qZ\nffauq8ERhzDmHIVc6alWe9cRRonH3PPJdljc6Fd5JT8mabOg9zUWR6NoOLGZ\n4rk6dMu2RxfooVBqyK7/0VGZnlf+doY5uqtPmHkW9pJapno8Wts0szYue661\nMc3h1wUId8qSAXTCliD3eCbN/7CHIZp5+3qTBUO30Mg+04i8QTpkoU/2HijC\niWOzxmNHbj02gAd33O6y7hxd2CIi41ujUrkuj2LYHBxbZ7CGqPqIxnBHyz4G\nw5QBF6ztYkVQB/1WENGjej+/+HV6vknBYFlUzEz5+cRWqLvZ5q8nHNezgY1t\nUPggr5IxtumWz0vFpqDJc+HikuHrLBAyGPvupLZ/g23/iluAlK+YHJRik1Rm\nFykc\r\n=63qI\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICSWulyer5JDe0hrXYhmean5Jmw8IXc436Dk9TwyYkJAAiAfpodeZ66oti3hNY15srlqXrTM5m+nIeds0GXm47SEhg=="}]},"maintainers":[{"name":"carrotwu","email":"542425997@qq.com"}],"_npmUser":{"name":"carrotwu","email":"542425997@qq.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/generatoc_1.0.0_1600253340412_0.823992106239128"},"_hasShrinkwrap":false},"1.0.1":{"name":"@carrotwu/generatoc","version":"1.0.1","description":"Automatically generate table of content from heading of HTML document（ forked from https://github.com/gadzan/generatoc/）","main":"dist/index.js","scripts":{"test":"jest --coverage && coveralls < coverage/lcov.info","jest":"jest --coverage","build":"rollup -c","dev":"rollup -w -c rollup.config.dev.js","release":"npm publish"},"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/carrot-wu/generatoc.git"},"types":"dist/index.d.ts","keywords":["toc","javascript","typescript","table","of","contents","generate","html","structure","SSR"],"author":{"name":"Gadzan"},"license":"MIT","bugs":{"url":"https://github.com/carrot-wu/generatoc/issues"},"homepage":"https://github.com/carrot-wu/generatoc/","devDependencies":{"@babel/core":"^7.9.6","@babel/preset-env":"^7.9.6","@babel/preset-typescript":"^7.9.0","@rollup/plugin-babel":"^5.0.0","@rollup/plugin-buble":"^0.21.3","@rollup/plugin-node-resolve":"^7.1.3","@rollup/plugin-typescript":"^4.1.1","@types/jest":"^25.2.2","coveralls":"^3.1.0","eslint":"^7.0.0","jest":"^26.0.1","postcss-preset-env":"^6.7.0","rollup":"^2.10.0","rollup-plugin-postcss":"^3.1.1","rollup-plugin-serve":"^1.0.1","rollup-plugin-sourcemaps":"^0.6.2","rollup-plugin-terser":"^5.3.0","rollup-plugin-typescript2":"^0.27.1","ts-jest":"^25.5.1","tslib":"^2.0.0","typescript":"^3.8.3"},"gitHead":"7d65df3360b939e237f06820162181286c3b35eb","_id":"@carrotwu/generatoc@1.0.1","_nodeVersion":"12.16.3","_npmVersion":"6.14.5","dist":{"integrity":"sha512-xckeoRL00Wj5MkYd3qYzeUm+med872owI64Pr/udBnUPEBx6WQXqnpa4pDhh+t5EvknMxWu/2ezQZ48EizFkPw==","shasum":"c7393bef38cabbf96d078e09f1d0f6b5f31c9297","tarball":"https://registry.npmjs.org/@carrotwu/generatoc/-/generatoc-1.0.1.tgz","fileCount":16,"unpackedSize":48516,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfYfAcCRA9TVsSAnZWagAA7SsP/A8hU3oteSMdLKdwnezI\nP+2SL2ZLfePwKgdfI+yR70LmRmWe5xegoRmtxPkJXYT6gq3yYuYfXaHRstqC\nRZPum2il0Oe7RXP7i3rXeBw0Xt1tvsoXH39hX/PmAg8a6XAr2plLpdSGEZAP\njcTdsbRFI/RY4Y/B6k6OREhZe0BhFhn+zP6uQhcGYjwVsIfT2j4WZ2inGAWS\nZRLHB5YRxfbXh5Q+4hWeFjg0JHleu2IuVolNudnTNgZ8PWFxAcwFGRtgfHId\nq1blS45PPH+1GvrdPmTuldFCRphfwatsvZwQYifzsAhbaqndFTQ3+N02dW6p\nKU/Ospsh6zDV2P8eKsKCnwlRh+K39ro+kXUnLM+o12gbUev8Y9yV1xNhR+6V\nYkmqWj6WxWbY3LiX3BxXoxrcCBZd1wiHq8HQu29CKldXdSKlWVdYNeBUNzYr\nCcIiDeCnjzHaMy0MV93jk7ftsNtglRNFHjCCMDVr2w28PnXepBJca3CmV7P0\nIpXkhC9KzGLUxmljXiOLA8+QJKnN7T/jjvXUaXecSew2fU0wZz/NTUKedBfE\nGjArBid/7LMtGa5i0sQUOYPascfYg60ll4NuyyacORAVVvBZVxDln6pc3c1I\neQ16vCwzRAiOjW/s8YV7MFmmQvsDZNq37vF8ANOmZ88j4SKx8fIiu+gcVXcU\nOtqF\r\n=fs2P\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFw6jRYukEMq4+Cn9YZEi1BYxv+sEcG3KTcha9bzL0fUAiBHVLTridWH+kizaSQPdVy4F/Fzi6A95edXHC7Wq7vZzw=="}]},"maintainers":[{"name":"carrotwu","email":"542425997@qq.com"}],"_npmUser":{"name":"carrotwu","email":"542425997@qq.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/generatoc_1.0.1_1600253980450_0.4067842495611498"},"_hasShrinkwrap":false}},"time":{"created":"2020-09-16T10:49:00.381Z","1.0.0":"2020-09-16T10:49:00.499Z","modified":"2022-04-04T21:59:06.966Z","1.0.1":"2020-09-16T10:59:40.591Z"},"maintainers":[{"name":"carrotwu","email":"542425997@qq.com"}],"description":"Automatically generate table of content from heading of HTML document（ forked from https://github.com/gadzan/generatoc/）","homepage":"https://github.com/carrot-wu/generatoc/","keywords":["toc","javascript","typescript","table","of","contents","generate","html","structure","SSR"],"repository":{"type":"git","url":"git+https://github.com/carrot-wu/generatoc.git"},"author":{"name":"Gadzan"},"bugs":{"url":"https://github.com/carrot-wu/generatoc/issues"},"license":"MIT","readme":"# GeneraToc\r\n\r\n![Travis (.org)](https://img.shields.io/travis/gadzan/generatoc?style=for-the-badge)\r\n![npm 20downloads](https://img.shields.io/npm/dt/generatoc?label=npm%20downloads&logo=npm&style=for-the-badge)\r\n![npm bundle size](https://img.shields.io/bundlephobia/min/generatoc?style=for-the-badge)\r\n![Coveralls github](https://img.shields.io/coveralls/github/gadzan/generatoc?style=for-the-badge)\r\n![License](https://img.shields.io/npm/l/generatoc?style=for-the-badge)\r\n![Version](https://img.shields.io/npm/v/generatoc?logo=npm&label=version&style=for-the-badge)\r\n![GitHub package.json version](https://img.shields.io/github/package-json/v/gadzan/generatoc?logo=github&style=for-the-badge)\r\n[![HitCount](http://hits.dwyl.com/gadzan/generatoc.svg)](http://hits.dwyl.com/gadzan/generatoc)\r\n\r\nGeneraToc generates a table of contents (TOC) from headings in an HTML document. This is useful for documentation websites or SSR pages because it makes them easier to navigate. \r\n\r\nThis library was inspired by [Tocify](https://github.com/gfranko/jquery.tocify.js) and [Tocbot](https://github.com/tscanlin/tocbot), but GeneraToc **uses native DOM** methods with **no other dependencies** and unlike Tocbot, GeneraToc does **NOT rely on id attribute** to navigate to the heading.\r\n\r\n## DEMO\r\n\r\n[https://gadzan.github.io/generatoc/demo/](https://gadzan.github.io/generatoc/demo/)\r\n\r\n## Installation\r\n\r\nInstall it with npm.\r\n```bash\r\nnpm install --save generatoc\r\n```\r\n\r\nOR Install it with yarn.\r\n```bash\r\nyarn add generatoc\r\n```\r\n\r\nOR include in browser environment\r\ninclude the script at the bottom of the page before the closing body tag.\r\n```html\r\n<script src=\"https://cdn.jsdelivr.net/npm/generatoc/build/generatoc.min.js\"></script>\r\n```\r\n\r\nInclude CSS\r\n\r\nin html file\r\n```html\r\n<link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/generatoc/build/generatoc.min.css\">\r\n```\r\n\r\nOR\r\n\r\nIf you installed it with npm you might try importing the styles from 'node_modules'\r\n```css\r\n@import 'generatoc/src/style/main.css';\r\n```\r\n\r\n## Usage\r\n\r\nDefine a `div` element with id attribute\r\n```html\r\n<div id=\"toc\"></div>\r\n```\r\n\r\n#### Use GeneraToc with typescript:\r\n```typescript\r\nimport generatoc from 'generatoc'\r\n// Typescript\r\n// (Required) Article content selector, default as '.post-content'\r\nconst content: string = '.post-content'\r\n\r\n// (Optional) Select h2 ~ h5 heading level, it is also a defualt setting if you leave it undefined\r\nconst heading: string[] = ['h2', 'h3', 'h4', 'h5']\r\n\r\n// (Optional) TOC element is append to #toc element, it is also a defualt setting if you leave it undefined\r\nconst selector: string = '#toc'\r\n\r\ngeneratoc.init({ content, heading, selector })\r\n```\r\n\r\n#### Use GeneraToc with javascript:\r\n```javascript\r\n// JavaScript\r\nimport generatoc from 'generatoc'\r\nconst content = '.post-content'\r\nconst heading = ['h2', 'h3', 'h4', 'h5']\r\nconst selector = '#toc'\r\ngeneratoc.init({ content, heading, selector })\r\n```\r\n\r\n#### Use in browser environment\r\n```javascript\r\nconst content = '.post-content'\r\nconst heading = ['h2', 'h3', 'h4', 'h5']\r\nconst selector = '#toc'\r\ngeneratoc.init({ content, heading, selector })\r\n```\r\n\r\n### You need to know when importing css file\r\n\r\n**If the `selector` is not `#toc` you have to modify css file manully**, just replace all `#toc` string with your selector name in css file which can be found at `./node_modules/generatoc/src/style/main.css`\r\n\r\n## Development\r\n\r\n```bash\r\nyarn install\r\nnpm run dev\r\n```\r\n\r\n## Other init options\r\n```\r\n{\r\n  // scrollHistory: Accepts a boolean: true or false\r\n  // Adds a hash to the page url, to maintain history, when scrolling to a TOC item\r\n  scrollHistory: false,\r\n\r\n  // scrollOffset: Accepts a number: default to 0\r\n  // Scroll to the target with a vertical offset(pixel). If you have a fixed header in your page, this is what you need to set.\r\n  scrollOffset: 0,\r\n\r\n  // duration: Accepts a number: default to 7\r\n  // The duration of scroll animation, a larger number means slower scroll. please input with a number larger than 1.\r\n  duration: 7,\r\n}\r\n```\r\n\r\n## TODO\r\n\r\n- [x] Destory method\r\n- [x] Reload method\r\n- [x] Development env\r\n- [x] Test cases\r\n- [x] Show and close animation\r\n- [ ] More configurations\r\n\r\n## Using with SSR\r\n\r\nIf you are using GeneraToc with SSR framwork, like Nuxt.js, please add `transpile` param to `nuxt.config.js`\r\n```\r\nbuild: {\r\n  transpile: ['generatoc']\r\n}\r\n```\r\n\r\n## LICENSE\r\nMIT\r\n","readmeFilename":"README.md"}