1
mirror of https://github.com/jakejarvis/simple-anchor.git synced 2025-04-28 07:30:28 -04:00

Compare commits

...

7 Commits
v1.0.1 ... main

7 changed files with 847 additions and 744 deletions

17
.editorconfig Normal file
View File

@ -0,0 +1,17 @@
# http://editorconfig.org
# this file is the top-most editorconfig file
root = true
# all files
[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true
# site content
[*.md]
trim_trailing_whitespace = false

View File

@ -1,17 +1,19 @@
{
"extends": [
"@jakejarvis/eslint-config"
"@jakejarvis/eslint-config",
"plugin:compat/recommended",
"plugin:import/recommended"
],
"parser": "@babel/eslint-parser",
"parserOptions": {
"ecmaVersion": 2015,
"sourceType": "module"
"requireConfigFile": false
},
"env": {
"browser": true,
"node": true
},
"ignorePatterns": [
"dist/**",
"rollup.config.js"
"*.d.ts",
"dist/**"
]
}

2
.gitattributes vendored Normal file
View File

@ -0,0 +1,2 @@
# Set default behavior to automatically normalize line endings.
* text=auto eol=lf

View File

@ -1,6 +1,10 @@
# 🔗 Simple Anchor [![npm](https://img.shields.io/npm/v/simple-anchor?logo=npm)](https://www.npmjs.com/package/simple-anchor)
# 🔗 Simple Anchor
A JavaScript utility for adding deep anchor links ([like these](https://ux.stackexchange.com/q/36304/33248)) to existing page content.
[![CI](https://github.com/jakejarvis/simple-anchor/actions/workflows/ci.yml/badge.svg)](https://github.com/jakejarvis/simple-anchor/actions/workflows/ci.yml)
[![npm](https://img.shields.io/npm/v/simple-anchor?logo=npm)](https://www.npmjs.com/package/simple-anchor)
[![MIT License](https://img.shields.io/github/license/jakejarvis/simple-anchor?color=violet)](LICENSE)
A JavaScript utility for adding deep anchor links ([like these](https://ux.stackexchange.com/q/36304/33248)) to existing page content. Zero dependencies and [only ~1kB gzipped!](https://bundlephobia.com/package/simple-anchor)
## Changes from [AnchorJS](https://github.com/bryanbraun/anchorjs)
@ -14,7 +18,7 @@ Otherwise, the [AnchorJS docs](https://www.bryanbraun.com/anchorjs/) still serve
### Browser
```html
<script src="https://unpkg.com/@jakejarvis/simple-anchor/dist/simple-anchor.min.js"></script>
<script src="https://unpkg.com/simple-anchor/dist/simple-anchor.min.js"></script>
<script>
var anchor = new SimpleAnchor();
anchors.add({

View File

@ -1,13 +1,13 @@
{
"name": "simple-anchor",
"version": "1.0.0",
"version": "1.0.3",
"description": "A bare-bones fork of AnchorJS.",
"license": "MIT",
"homepage": "https://github.com/jakejarvis/simple-anchor",
"author": "Jake Jarvis (https://github.com/jakejarvis)",
"contributors": [
"Bryan Braun (https://github.com/bryanbraun)"
],
"description": "A bare-bones fork of AnchorJS.",
"license": "MIT",
"homepage": "https://github.com/jakejarvis/simple-anchor",
"repository": {
"type": "git",
"url": "https://github.com/jakejarvis/simple-anchor.git"
@ -26,31 +26,34 @@
"browser": "./dist/simple-anchor.min.js"
},
"scripts": {
"clean": "rimraf dist",
"build": "rollup -c",
"watch": "rollup -c -w",
"lint": "eslint .",
"prepublishOnly": "run-s clean build"
"prepublishOnly": "yarn build"
},
"dependencies": {},
"devDependencies": {
"@babel/core": "^7.15.0",
"@babel/preset-env": "^7.15.0",
"@jakejarvis/eslint-config": "^1.0.1",
"@babel/core": "^7.15.8",
"@babel/eslint-parser": "^7.15.8",
"@babel/preset-env": "^7.15.8",
"@jakejarvis/eslint-config": "*",
"@rollup/plugin-babel": "^5.3.0",
"@rollup/plugin-commonjs": "^21.0.0",
"@rollup/plugin-eslint": "^8.0.1",
"@rollup/plugin-node-resolve": "^13.0.4",
"eslint": "^7.32.0",
"@rollup/plugin-node-resolve": "^13.0.5",
"builtin-modules": "^3.2.0",
"eslint": "^8.0.0",
"eslint-plugin-compat": "^3.13.0",
"eslint-plugin-import": "^2.24.2",
"npm-run-all": "^4.1.5",
"rimraf": "^3.0.2",
"rollup": "^2.56.3",
"eslint-plugin-import": "^2.25.2",
"rollup": "^2.58.0",
"rollup-plugin-copy": "^3.4.0",
"rollup-plugin-delete": "^2.0.0",
"rollup-plugin-filesize": "^9.1.1",
"rollup-plugin-node-externals": "^2.2.0",
"rollup-plugin-terser": "^7.0.2"
},
"keywords": [
"frontend",
"front-end",
"anchor",
"links",
"dom",

View File

@ -1,29 +1,34 @@
import pkg from "./package.json";
import resolve from "@rollup/plugin-node-resolve";
import externals from "rollup-plugin-node-externals";
import { babel } from "@rollup/plugin-babel";
import { terser } from "rollup-plugin-terser";
import eslint from "@rollup/plugin-eslint";
import filesize from "rollup-plugin-filesize";
import copy from "rollup-plugin-copy";
import del from "rollup-plugin-delete";
import commonjs from "@rollup/plugin-commonjs";
import eslint from "@rollup/plugin-eslint";
const banner = `/*! Simple Anchor v${pkg.version} | MIT License | https://github.com/jakejarvis/simple-anchor */`;
const exportName = "SimpleAnchor";
const input = "src/index.js";
const banner = `/*! ${pkg.name} v${pkg.version} | ${pkg.license} License | ${pkg.homepage} */`;
export default [
{
// universal (browser and node)
input: "src/index.js",
input,
output: [
{
name: "SimpleAnchor",
file: "dist/simple-anchor.js",
name: exportName,
file: pkg.exports.browser.replace(".min.js", ".js"), // unminified (.js)
format: "umd",
exports: "named",
esModule: false,
banner: banner,
},
{
name: "SimpleAnchor",
file: "dist/simple-anchor.min.js",
name: exportName,
file: pkg.exports.browser, // minified (.min.js)
format: "umd",
exports: "named",
esModule: false,
@ -38,17 +43,19 @@ export default [
},
],
plugins: [
del({ targets: "dist/*" }),
copy({
// clearly this isn't really typescript, so we need to manually copy the type definition file
targets: [
{
src: "src/index.d.ts",
src: input.replace(".js", ".d.ts"),
dest: "dist",
rename: "simple-anchor.d.ts",
rename: pkg.types.replace("./dist/", ""),
},
],
}),
resolve(),
commonjs(),
eslint(),
babel({
babelHelpers: "bundled",
@ -60,24 +67,25 @@ export default [
},
{
// modules
input: "src/index.js",
input,
output: [
{
// ES6 module (import)
file: "dist/simple-anchor.esm.js",
file: pkg.exports.import,
format: "esm",
exports: "named",
banner: banner,
},
{
// commonjs (require)
file: "dist/simple-anchor.cjs.js",
file: pkg.exports.require,
format: "cjs",
exports: "named",
banner: banner,
},
],
plugins: [
externals({ deps: true }),
resolve(),
babel({
babelHelpers: "bundled",

1483
yarn.lock

File diff suppressed because it is too large Load Diff