externalLinks()

Thêm thuộc tính rel và target vào các liên kết ngoài trong đầu ra Markdown của bạn.

import { externalLinks } from "@unifast/node";

Chữ ký

function externalLinks(options?: ExternalLinksPluginOptions): UnifastPlugin

Tham số

options?

Cấu hình cho các thuộc tính của liên kết ngoài

Thuộc tínhKiểuMặc địnhMô tả
relstring"nofollow noopener noreferrer"Giá trị cho thuộc tính rel trên các liên kết ngoài
targetstringGiá trị cho thuộc tính target (ví dụ “_blank”)

Cách dùng

import { compile, externalLinks } from "@unifast/node";

const result = compile(md, {
  plugins: [
    externalLinks({
      rel: "nofollow noopener noreferrer",
      target: "_blank",
    }),
  ],
});

Ví dụ

Liên kết ngoài so với liên kết nội bộ