🔗 A bare-bones fork of AnchorJS. https://www.npmjs.com/package/simple-anchor
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
Jake Jarvis ded4f88b2e
bring bundle config up-to-date with rollup template
1 week ago
.github/workflows fix CI 2 months ago
src initial commit 🎉 2 months ago
.editorconfig bring bundle config up-to-date with rollup template 1 week ago
.eslintrc.json bring bundle config up-to-date with rollup template 1 week ago
.gitattributes bring bundle config up-to-date with rollup template 1 week ago
.gitignore initial commit 🎉 2 months ago
LICENSE initial commit 🎉 2 months ago
README.md update badges & fix unpkg URL 2 months ago
package.json bring bundle config up-to-date with rollup template 1 week ago
rollup.config.js bring bundle config up-to-date with rollup template 1 week ago
yarn.lock bring bundle config up-to-date with rollup template 1 week ago

README.md

🔗 Simple Anchor

CI npm MIT License

A JavaScript utility for adding deep anchor links (like these) to existing page content. Zero dependencies and only ~1kB gzipped!

Changes from AnchorJS

  • Styling of .anchorjs-link elements is completely on you. The non-optional and hefty base styles of AnchorJS have been removed for a slimmer module. (This includes the default 🔗 icon.)
  • Element IDs are also left to you — this package will not generate an element's ID automatically if one is not already set (eg. <h2 id="installation">Installation</h2>). Elements without one are automatically ignored.

Otherwise, the AnchorJS docs still serve as a good reference.

Usage

Browser

<script src="https://unpkg.com/simple-anchor/dist/simple-anchor.min.js"></script>
<script>
  var anchor = new SimpleAnchor();
  anchors.add({
   icon: '#'
  });
</script>

Node

npm install simple-anchor
# or...
yarn add simple-anchor
import SimpleAnchor from 'simple-anchor';
// or...
// const SimpleAnchor = require('simple-anchor');

const anchors = new SimpleAnchor();
anchors.add({
   icon: '#'
});

Since AnchorJS's default CSS has been removed as mentioned above, it's up to you to style the .anchorjs-link element.

Examples

License

MIT