zudo-doc
GitHub repository

Type to search...

to open search from anywhere

External Links

Created May 28, 2026Updated Jul 24, 2026Takeshi Takatsudo

Opt-in rewriter that adds target and rel attributes to outbound links.

What it does

zfb ships an opt-in external-link rewriter, configured through the top-level markdown.externalLinks option. When enabled, every <a> whose href is classified as external receives the target and rel attributes you configure. It is a build-time port of rehype-external-links and runs inside zfb's markdown pipeline.

The rewriter is off by default. Neither zfb nor the zudo-doc preset enables it, so omitting the option leaves the rendered HTML byte-for-byte unchanged.

No automatic icon

Content-body external links receive no visual affordance today. zudo-doc's content-link component (content-link.tsx) applies only accent color and underline — it adds no external-link icon, and it does not set target or rel. The markdown.externalLinks rewriter described here adds attributes only; it does not inject an icon or any other marker.

What counts as external

An href is treated as external when:

  • It is an absolute http: or https: URL.

  • Its origin differs from the top-level site URL (when site is configured). When site is absent, any absolute http: / https: URL is treated as external.

Non-HTTP(S) schemes (mailto:, tel:, …) are always left unchanged, and relative URLs (/internal/, ./page.mdx, #anchor) are always internal.

Enabling it

The zudo-doc preset owns the markdown config, and zudoDoc() returns a complete zfb config. To opt in, spread that config and extend its markdown block with an externalLinks entry — spread base.markdown so the preset's existing markdown.features are preserved:

import { defineConfig } from "zfb/config";
import { zudoDoc } from "@takazudo/zudo-doc/config";

const base = zudoDoc({
  // ...your project settings
});

export default defineConfig({
  ...base,
  markdown: {
    ...base.markdown,
    externalLinks: {
      target: "_blank",
      rel: ["noopener", "noreferrer"],
    },
  },
});

Both fields are optional. target defaults to "_blank" and rel defaults to ["noopener", "noreferrer"], so externalLinks: {} opts in with those defaults. Supplied rel tokens are merged (case-insensitively deduplicated) with any rel already present on the link.

Example

With the rewriter enabled, a standard markdown link to an external site:

See the [zfb repository](https://github.com/takazudo/zfb) for source.

renders as <a href="https://github.com/takazudo/zfb" target="_blank" rel="noopener noreferrer">. The link text and its accent styling are unchanged — only the target and rel attributes are added.

Notes

  • The rewriter sets attributes only; it renders no icon. To show a visual external-link indicator once the rewriter is enabled, add your own CSS — for example a rule keyed on the a[target="_blank"] attribute it adds.

  • See Resolve Links for the companion feature that normalizes internal .mdx / .md link targets.

Revision History

Takeshi TakatsudoCreated: 2026-05-29T01:40:39+09:00Updated: 2026-07-25T02:50:45+09:00

AI Assistant

Ask a question about the documentation.

Preview theme

Loading theme previews…