autolinkHeadings()

Automatically add anchor links to headings.

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

Signature

function autolinkHeadings(options?: AutolinkHeadingsOptions): UnifastPlugin

Parameters

options?

Configuration for heading link behavior

PropertyTypeDefaultDescription
behavior"prepend" | "append" | "wrap""prepend"Where to place the anchor link relative to the heading content

Usage

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

const md = `# Introduction

## Getting Started

### Installation`;

const result = compile(md, {
  plugins: [
    autolinkHeadings({
      behavior: "prepend", // "prepend" | "append" | "wrap"
    }),
  ],
});

Examples