npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@azamiharu/marked-rel-external

v1.0.1

Published

外部リンクに安全な rel 属性と rel="me" を付与する marked 拡張機能

Readme

@azamiharu/marked-rel-external

marked のリンクレンダラーを拡張し、外部リンクに対して自動的に target="_blank" や適切な rel 属性(external, me, noopener, noreferrer)を付与する拡張機能です。

特徴

  • 自動環境判定: ブラウザ環境では location.host を自動的に内部ホストとして認識します。
  • 分散型SNS対応: Mastodon や Misskey などのプロフィールリンク(rel="me")を identityURLs として登録することで、自動的に rel="me" を付与します。
  • セキュリティ: 外部リンクには一律で noopener noreferrer を付与し、タブジャッキング攻撃を防ぎます。
  • インラインパース対応: リンクテキスト内の太字やコードスパンなどのインライン要素も正しく処理します。

インストール

pnpm add @azamiharu/marked-rel-external

使い方

基本的な使用例

import { markedRelExternal } from "@azamiharu/marked-rel-external";
import { Marked } from "marked";

const html = new Marked()
  .use(markedRelExternal({
    internalHosts: ["my-site.com"],
    identityURLs: ["https://mastodon.social/@username"],
  }))
  .parse("[GitHub](https://github.com/)");

// 出力結果:
// <a href="https://github.com/" rel="external noopener noreferrer" target="_blank">GitHub</a>

ブラウザでの自動認識

ブラウザ環境(window オブジェクトが存在する環境)で使用する場合、オプションを空にすると現在のドメインを自動的に internalHosts に追加します。また、HTML 内に <link rel="me" href="..."> が存在すれば、それらを自動的に identityURLs として読み込みます。

const marked = new Marked().use(markedRelExternal());

オプション

| プロパティ | 型 | 説明 | | --------------- | ---------- | --------------------------------------------------------------------------------------------------- | | internalHosts | string[] | 内部リンクとして扱うホスト名のリスト。これに含まれるドメインには target="_blank" を付与しません。 | | identityURLs | string[] | 自身のアイデンティティを示す URL のリスト。これに一致するリンクには rel="me" が付与されます。 |

開発

ビルド

pnpm build

ライセンス

MIT