Skip to content

Use markdown-it plugin for toc #673

Open

Description

@muffinresearch

Instead of using page data to build the toc it would be better to fix #659 and then use a toc plugin.

The same slugify function should be used everywhere for ids as that will make everything consistent:

Here's a sample of code that does the toc and heading id generation:

    [require('markdown-it-anchor'), {
      permalink: false,
      slugify: slugify
    }],
    [require('markdown-it-toc-done-right'), {
      listType: 'ol',
      level: 2,
      slugify: slugify,
      containerClass: 'table-of-contents-inner',
      callback: (html, ast) => {
        html = `<aside class="module-aside table-of-contents">${html}</aside>`;
      },
    }],

This should also then negate the need for doc authors working around issues with this by adding <section id="some-id-just-for-linkage">.

Activity

  1. added
    enhancement
    blocks-l10n
    on Jul 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    11ty-migrationblocks-l10nenhancement

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions