-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit bca89df
Showing
29 changed files
with
2,315 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Publish Package to NPM | ||
|
||
on: | ||
release: | ||
types: [created] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: production | ||
url: https://www.npmjs.com/package/@benjc/rehype-scroll-to-top | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: "18.x" | ||
registry-url: "https://registry.npmjs.org" | ||
- name: Run install | ||
run: npm ci | ||
- name: Run build | ||
run: npm run build | ||
- name: Run publish | ||
run: npm publish --access=public | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Test | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: [18.x, 20.x] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: Run install | ||
run: npm ci | ||
- name: Run lint | ||
run: npm run lint | ||
- name: Run unit tests | ||
run: npm test | ||
- name: Run build | ||
run: npm run build | ||
- name: Generate coverage file | ||
run: npm run coverage | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v4 | ||
with: | ||
files: ./coverage/coverage-final.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
*.lcov | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
.npm | ||
|
||
# Artifact | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
*.lcov | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
.npm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/coverage/ | ||
/node_modules/ | ||
pnpm-lock.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"printWidth": 120, | ||
"semi": true, | ||
"singleQuote": false, | ||
"trailingComma": "es5" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Benjamin Charity | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# rehype-scroll-to-top | ||
|
||
![test workflow](https://github.com/benjamincharity/rehype-scroll-to-top/actions/workflows/test.yml/badge.svg) | ||
[![codecov](https://codecov.io/gh/benjamincharity/rehype-scroll-to-top/branch/main/graph/badge.svg?token=T3Z18P56LV)](https://codecov.io/gh/benjamincharity/rehype-scroll-to-top) | ||
|
||
## Motivation | ||
|
||
I needed an easy way for users to jump to the top of the page or the bottom. | ||
|
||
## Install | ||
|
||
``` | ||
npm i -D @benjamincharity/rehype-scroll-to-top | ||
``` | ||
|
||
## Sample | ||
|
||
### Input | ||
|
||
```html | ||
<h1>Title</h1> | ||
<p>Content</p> | ||
``` | ||
|
||
### Output | ||
|
||
```html | ||
<a aria-label="Scroll to bottom" href="#bottom" id="top" class="scroll-to scroll-to--top">Scroll to bottom</a> | ||
<h1>Title</h1> | ||
<p>Content</p> | ||
<a aria-label="Scroll to top" href="#top" id="bottom" class="scroll-to scroll-to--bottom">Scroll to top</a> | ||
``` | ||
|
||
## Options | ||
|
||
Sure, here is a table outlining the available setting options for the `rehype-scroll-to-top` plugin: | ||
|
||
| Option | Type | Description | Default | | ||
| ---------------------- | --------- | ----------------------------------- | -------------------- | | ||
| `topLink.ariaLabel` | `string` | Aria label for the top link | `"Scroll to bottom"` | | ||
| `topLink.classes` | `string` | CSS classes for the top link | `""` | | ||
| `topLink.disabled` | `boolean` | Whether the top link is disabled | `false` | | ||
| `topLink.id` | `string` | ID for the top link | `"top"` | | ||
| `topLink.text` | `string` | Text for the top link | `"Scroll to bottom"` | | ||
| `bottomLink.ariaLabel` | `string` | Aria label for the bottom link | `"Scroll to top"` | | ||
| `bottomLink.classes` | `string` | CSS classes for the bottom link | `""` | | ||
| `bottomLink.disabled` | `boolean` | Whether the bottom link is disabled | `false` | | ||
| `bottomLink.id` | `string` | ID for the bottom link | `"bottom"` | | ||
| `bottomLink.text` | `string` | Text for the bottom link | `"Scroll to top"` | | ||
|
||
These options can be passed to the `rehype-scroll-to-top` plugin as part of the `options` object. For example: | ||
|
||
```typescript | ||
rehypeScrollToTop({ | ||
topLink: { | ||
ariaLabel: "Go to bottom", | ||
classes: "my-custom-class", | ||
disabled: false, | ||
id: "my-top-link", | ||
text: "Go to bottom", | ||
}, | ||
bottomLink: { | ||
ariaLabel: "Go to top", | ||
classes: "my-other-custom-class", | ||
disabled: false, | ||
id: "my-bottom-link", | ||
text: "Go to top", | ||
}, | ||
}); | ||
``` | ||
|
||
This will customize the top and bottom links according to the provided options. | ||
|
||
## License | ||
|
||
[MIT][license] © [benjamincharity][author] | ||
|
||
[license]: license | ||
[author]: https://www.benjamincharity.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{ | ||
"name": "@benjc/rehype-scroll-to-top", | ||
"version": "0.1.0", | ||
"description": "A Rehype plugin that adds a 'scroll to top' & 'scroll to bottom' links to the page.", | ||
"type": "module", | ||
"main": "dist/index.js", | ||
"module": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"files": ["dist"], | ||
"scripts": { | ||
"prebuild": "rimraf dist", | ||
"build": "tsc", | ||
"test": "vitest", | ||
"coverage": "vitest run --coverage", | ||
"typecheck": "tsc --noEmit", | ||
"lint": "rome ci src tests" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/benjamincharity/rehype-scroll-to-top.git" | ||
}, | ||
"keywords": [ | ||
"rehype", | ||
"rehype-plugin" | ||
], | ||
"author": "Benjamin Charity <[email protected]> (https://www.benjamincharity.com/)", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/benjamincharity/rehype-scroll-to-top/issues" | ||
}, | ||
"homepage": "https://github.com/benjamincharity/rehype-scroll-to-top#readme", | ||
"devDependencies": { | ||
"@types/hast": "3.0.4", | ||
"@types/node": "^20.11.16", | ||
"@vitest/coverage-v8": "1.2.2", | ||
"hast-util-to-html": "9.0.0", | ||
"hastscript": "^9.0.0", | ||
"prettier": "3.2.4", | ||
"rehype-minify-whitespace": "6.0.0", | ||
"rimraf": "^5.0.5", | ||
"rome": "^12.1.3", | ||
"to-vfile": "^8.0.0", | ||
"typescript": "^5.3.3", | ||
"vite": "^5.0.12", | ||
"vitest": "^1.2.2" | ||
}, | ||
"peerDependencies": { | ||
"rehype": "^13.0.1", | ||
"unified": "^11.0.4" | ||
}, | ||
"engines": { | ||
"node": ">=20.0.0" | ||
} | ||
} |
Oops, something went wrong.