Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use markdown-it plugin for toc #673

Open
muffinresearch opened this issue Jul 21, 2020 · 0 comments
Open

Use markdown-it plugin for toc #673

muffinresearch opened this issue Jul 21, 2020 · 0 comments
Labels
11ty-migration blocks-l10n These issues block localizing the site enhancement New feature or request

Comments

@muffinresearch
Copy link
Contributor

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">.

@muffinresearch muffinresearch added 11ty-migration enhancement New feature or request blocks-l10n These issues block localizing the site labels Jul 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
11ty-migration blocks-l10n These issues block localizing the site enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant