Skip to content

cworld1/rehype-autolink-headings-simple

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rehype-autolink-headings simple

bundlejs

A simple version of rehype-autolink-headings.

Less dependencies and less useless code. Using typescript to develop.

Usage

npm install rehype-autolink-headings-simple
import { rehypeAutolinkHeadings } from "rehype-autolink-headings-simple";
import { unified } from "unified";
import { parse } from "rehype-parse";
import { stringify } from "rehype-stringify";

const processor = unified()
  .use(parse)
  .use(rehypeAutolinkHeadings, {
    behavior: "append",
    properties: {
      behavior: "append",
      properties: { className: ["anchor"] },
      content: { type: "text", value: "#" },
    },
  })
  .use(stringify);

const result = processor.processSync("<h1>Heading</h1>").toString();

Known issues

Astro should change render order manually. See Astro: Heading IDs and plugins

License

The MIT License (MIT).

Releases

No releases published

Packages

 
 
 

Contributors