https://github.com/iwstkhr/rehype-target-blank
Plugin to make target _blank
https://github.com/iwstkhr/rehype-target-blank
blank rehype target
Last synced: 3 months ago
JSON representation
Plugin to make target _blank
- Host: GitHub
- URL: https://github.com/iwstkhr/rehype-target-blank
- Owner: iwstkhr
- License: mit
- Created: 2024-02-21T11:18:19.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-03T14:48:43.000Z (7 months ago)
- Last Synced: 2024-11-09T20:44:07.896Z (6 months ago)
- Topics: blank, rehype, target
- Language: TypeScript
- Homepage:
- Size: 61.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rehype-target-blank
rehype plugin to set `_blank` to `target` attributes.## Installation
```sh
npm i git+https://github.com/iwstkhr/rehype-target-blank.git
```## Options
| Name | Type | Description |
| ---- | ---- | ----------- |
| excludes | string[] | Excluded URLs |
| icon | boolean | Whether an external icon should be displayed |
| iconClass | string | CSS classes for an external icon |
| rel | string | [`rel`](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel) attribute value |## Usage in Astro
Add `rehypeTargetBlank` to `astro.config.mjs` like the following.```js
export default defineConfig({
site: 'https:///',
integrations: [tailwind()],
markdown: {
rehypePlugins: [
[rehypeTargetBlank, {
excludes: [
'https://',
'http://localhost',
'#',
],
icon: true,
iconClass: 'ml-1 inline-block align-text-top w-2.5 h-2.5',
rel: 'external',
}],
],
},
});
```If you use Tailwind CSS, please make sure to add `'./node_modules/@iwstkhr/rehype-target-blank/**/*.js',` to `tailwind.config.js` like the following.
```js
/** @type {import('tailwindcss').Config} */
export default {
darkMode: 'class',
content: [
'./src/**/*.{js,jsx,ts,tsx,astro}',
'./node_modules/@iwstkhr/rehype-target-blank/**/*.js',
],
theme: {
extend: {},
},
plugins: [],
};
```## License
MIT