Urara-Blog/node_modules/.pnpm-store/v3/files/00/19548c79909f307517430b9bf9d49edbb4d66f6d49cdf63f6395b000177d1752f426331cfe4c2baafb81441f24b18645c4a9363f510c3e086f30367fe45511
2022-08-14 01:14:53 +08:00

64 lines
2.3 KiB
Text

/**
* Plugin to automatically add `target` and `rel` attributes to external links.
*
* @type {import('unified').Plugin<[Options?] | Array<void>, Root>}
*/
export default function rehypeExternalLinks(
options?: void | Options | undefined
):
| void
| import('unified').Transformer<import('hast').Root, import('hast').Root>
export type Root = import('hast').Root
export type Properties = import('hast').Properties
export type Element = import('hast').Element
export type ElementChild = Element['children'][number]
export type Target = '_self' | '_blank' | '_parent' | '_top'
export type Rel = Array<string> | string
export type Protocols = Array<string>
export type Content = ElementChild | Array<ElementChild>
export type ContentProperties = Properties
export type TargetCallback = (node: Element) => Target | null | undefined
export type RelCallback = (node: Element) => Rel | null | undefined
export type ProtocolsCallback = (node: Element) => Protocols | null | undefined
export type ContentCallback = (node: Element) => Content | null | undefined
export type ContentPropertiesCallback = (
node: Element
) => Properties | null | undefined
/**
* Configuration.
*/
export type Options = {
/**
* How to display referenced documents (`string?`: `_self`, `_blank`,
* `_parent`, or `_top`, default: `_blank`).
* The default (nothing) is to not set `target`s on links.
*/
target?: Target | TargetCallback | undefined
/**
* Link types to hint about the referenced documents.
* Pass an empty array (`[]`) to not set `rel`s on links.
*
* **Note**: when using a `target`, add `noopener` and `noreferrer` to avoid
* exploitation of the `window.opener` API.
*/
rel?: Rel | RelCallback | undefined
/**
* Protocols to check, such as `mailto` or `tel`.
*/
protocols?: Protocols | ProtocolsCallback | undefined
/**
* hast content to insert at the end of external links.
* Will be inserted in a `<span>` element.
*
* Useful for improving accessibility by giving users advanced warning when
* opening a new window.
*/
content?: Content | ContentCallback | undefined
/**
* hast properties to add to the `span` wrapping `content`, when given.
*/
contentProperties?:
| import('hast').Properties
| ContentPropertiesCallback
| undefined
}