Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pr improvements #8

Merged
merged 9 commits into from
Feb 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,30 @@ jobs:
environment:
name: production
url: https://www.npmjs.com/package/@benjc/rehype-scroll-to-top

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'
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 --access=public
run: npm publish --provenance --access=public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
14 changes: 14 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,37 @@ jobs:
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:
Expand Down
6 changes: 0 additions & 6 deletions .prettierrc

This file was deleted.

13 changes: 13 additions & 0 deletions .prettierrc.json
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
}
6 changes: 6 additions & 0 deletions .xo-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"space": true,
"rules": {
"import/order": "off"
}
}
17 changes: 7 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,24 @@ npm i -D @benjc/rehype-scroll-to-top
## Usage

```typescript
import rehype from "rehype";
import rehypeParse from 'rehype-parse';
import rehypeScrollToTop from "@benjc/rehype-scroll-to-top";
import { unified } from 'unified';
import rehype from "rehype";
import rehypeParse from "rehype-parse";
import { unified } from "unified";

unified()
.use(rehypeParse, {fragment: true})
.use(rehypeScrollToTop)
.process('<h1>Title</h1><p>Content</p>')
unified().use(rehypeParse, { fragment: true }).use(rehypeScrollToTop).process("<h1>Title</h1><p>Content</p>");

// Or with options:
unified()
.use(rehypeParse, {fragment: true})
.use(rehypeParse, { fragment: true })
.use(rehypeScrollToTop, {
topLink: { disabled: true },
bottomLink: {
text: `Back to top ↑`,
classes: 'animated-link-underline',
classes: "animated-link-underline",
},
})
.process('<h1>Title</h1><p>Content</p>')
.process("<h1>Title</h1><p>Content</p>");
```

### Input
Expand Down
15 changes: 12 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
{
"name": "@benjc/rehype-scroll-to-top",
"version": "0.1.4",
"version": "0.1.5",
"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"],
"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": {
Expand All @@ -30,6 +35,7 @@
},
"homepage": "https://github.com/benjamincharity/rehype-scroll-to-top#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",
Expand All @@ -39,9 +45,12 @@
"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"
"vitest": "^1.2.2",
"xo": "~0.56.0"
},
"peerDependencies": {
"rehype": "^13.0.0",
Expand Down
Loading
Loading