-
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 af6f546
Showing
34 changed files
with
6,050 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,39 @@ | ||
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-semantic-images | ||
|
||
permissions: | ||
id-token: write | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: "20.x" | ||
registry-url: "https://registry.npmjs.org" | ||
scope: "@benjc" | ||
|
||
- uses: pnpm/action-setup@v2 | ||
with: | ||
version: 8 | ||
|
||
- name: Run install | ||
run: pnpm i | ||
|
||
- name: Run build | ||
run: pnpm run build | ||
|
||
- name: Run publish | ||
run: npm publish --provenance --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,51 @@ | ||
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 }} | ||
|
||
- uses: pnpm/action-setup@v2 | ||
with: | ||
version: 8 | ||
|
||
- name: Run install | ||
run: pnpm i | ||
|
||
- name: Run lint | ||
run: pnpm lint | ||
|
||
- name: Run unit tests | ||
run: pnpm test | ||
|
||
- name: Run type coverage tests | ||
run: pnpm type-coverage | ||
|
||
- name: Run build | ||
run: pnpm run build | ||
|
||
- name: Generate coverage file | ||
run: pnpm run coverage | ||
|
||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v4 | ||
env: | ||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | ||
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,13 @@ | ||
{ | ||
"bracketSpacing": true, | ||
"importOrder": ["^@core/(.*)$", "^@server/(.*)$", "^@ui/(.*)$", "^~/(.*)$", "^[./]"], | ||
"importOrderSeparation": true, | ||
"importOrderSortSpecifiers": true, | ||
"plugins": ["@trivago/prettier-plugin-sort-imports"], | ||
"printWidth": 120, | ||
"quoteProps": "consistent", | ||
"semi": true, | ||
"singleQuote": false, | ||
"trailingComma": "es5", | ||
"useTabs": false | ||
} |
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 @@ | ||
{ | ||
"space": true, | ||
"rules": { | ||
"import/order": "off" | ||
} | ||
} |
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,102 @@ | ||
# rehype-semantic-images | ||
|
||
![test workflow](https://github.com/benjamincharity/rehype-semantic-images/actions/workflows/test.yml/badge.svg) | ||
[![codecov](https://codecov.io/gh/benjamincharity/rehype-semantic-images/branch/main/graph/badge.svg?token=T3Z18P56LV)](https://codecov.io/gh/benjamincharity/rehype-semantic-images) | ||
|
||
## Motivation | ||
|
||
TODO | ||
|
||
## Install | ||
|
||
``` | ||
npm i -D @benjc/rehype-semantic-images | ||
``` | ||
|
||
## Usage | ||
|
||
```typescript | ||
import rehypeSemanticImages from "@benjc/rehype-semantic-images"; | ||
import rehype from "rehype"; | ||
import rehypeParse from "rehype-parse"; | ||
import { unified } from "unified"; | ||
|
||
unified().use(rehypeParse, { fragment: true }).use(rehypeSemanticImages).process("<h1>Title</h1><p>Content</p>"); | ||
|
||
// Or with options: | ||
unified() | ||
.use(rehypeParse, { fragment: true }) | ||
.use(rehypeSemanticImages, { | ||
// topLink: { disabled: true }, | ||
// bottomLink: { | ||
// text: `Back to top ↑`, | ||
// classes: "animated-link-underline", | ||
// }, | ||
}) | ||
.process("<h1>Title</h1><p>Content</p>"); | ||
``` | ||
|
||
### Input | ||
|
||
```html | ||
<h1>Title</h1> | ||
<p>Content</p> | ||
``` | ||
|
||
### Output | ||
|
||
```html | ||
<div class="scroll-to-wrapper"> | ||
<a aria-label="Scroll to bottom" href="#bottom" id="top" class="scroll-to scroll-to--top">Scroll to bottom</a> | ||
</div> | ||
<h1>Title</h1> | ||
<p>Content</p> | ||
<div class="scroll-to-wrapper"> | ||
<a aria-label="Scroll to top" href="#top" id="bottom" class="scroll-to scroll-to--bottom">Scroll to top</a> | ||
</div> | ||
``` | ||
|
||
## Options | ||
|
||
| 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-semantic-images` 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,66 @@ | ||
{ | ||
"name": "@benjc/rehype-semantic-images", | ||
"version": "0.0.1", | ||
"description": "TODO", | ||
"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", | ||
"coverage:types": "type-coverage --min=100", | ||
"typecheck": "tsc --noEmit", | ||
"lint": "xo --prettier", | ||
"lint:fix": "xo --fix --prettier", | ||
"format": "prettier --write ." | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/benjamincharity/rehype-semantic-images.git" | ||
}, | ||
"keywords": [ | ||
"rehype", | ||
"rehype-plugin" | ||
], | ||
"author": "Benjamin Charity <[email protected]> (https://www.benjamincharity.com/)", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/benjamincharity/rehype-semantic-images/issues" | ||
}, | ||
"homepage": "https://github.com/benjamincharity/rehype-semantic-images#readme", | ||
"devDependencies": { | ||
"@trivago/prettier-plugin-sort-imports": "^4.3.0", | ||
"@types/hast": "^3.0.4", | ||
"@types/node": "^20.11.16", | ||
"@vitest/coverage-v8": "^1.2.2", | ||
"hast-util-select": "6.0.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", | ||
"to-vfile": "^8.0.0", | ||
"type-coverage": "^2.27.1", | ||
"typecov": "~0.2.3", | ||
"typescript": "^5.3.3", | ||
"vite": "^5.0.12", | ||
"vitest": "^1.2.2", | ||
"xo": "~0.56.0" | ||
}, | ||
"peerDependencies": { | ||
"rehype": "^13.0.0", | ||
"unified": "^11.0.0" | ||
}, | ||
"engines": { | ||
"node": ">=18.0.0" | ||
}, | ||
"dependencies": { | ||
"unist-util-visit": "5.0.0" | ||
} | ||
} |
Oops, something went wrong.