remarkjs / remark-autolink-headings

Legacy remark plugin to automatically add links to headings — please use `rehype-autolink-headings` instead

Home Page:https://unifiedjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No Id, No href attribute

MejanH opened this issue · comments

I imported the plugin and added use(headings) in remark. It didn't add any id or href attribute in the headings tag.

am I missing something?

import headings from "remark-autolink-headings";

export async function getPostData(id: string) {
  const fullPath = path.join(postsDirectory, `${id}.md`);
  const fileContents = fs.readFileSync(fullPath, "utf8");

  const matterResult = matter(fileContents);
  const processedContent = await remark()
    .use(headings)
    .use(highlight)
    .use(html)
    .process(matterResult.content);

  const contentHtml = processedContent.toString();

  return {
    id,
    contentHtml,
    ...(matterResult.data as {
      date: string;
      title: string;
      cover: string;
      tags: string[];
      author: string;
    }),
  };
}

If you need help, support, or have a question that is not a bug report or feature request, please post it on Spectrum: https://spectrum.chat/unified/remark.

Questions asked here will be closed.

https://github.com/remarkjs/.github/blob/main/.github/ISSUE_TEMPLATE/3-help.md

Please move this to Spectrum, thanks for your understanding.