docgen: use github-slugger to generate better slugs

This commit is contained in:
Patrik Oldsberg
2020-07-17 10:38:29 +02:00
parent 7e5451d8a9
commit 922c7296fd
3 changed files with 23 additions and 3 deletions
@@ -14,6 +14,7 @@
* limitations under the License.
*/
import GithubSlugger from 'github-slugger';
import sortSelector from './sortSelector';
import { MarkdownPrinter, TypeLink } from './types';
import { execSync } from 'child_process';
@@ -46,7 +47,7 @@ export default class GithubMarkdownPrinter implements MarkdownPrinter {
}
headerLink(heading: string): string {
const slug = heading.replace(/[^a-z0-9]/gi, '-').toLowerCase();
const slug = GithubSlugger.slug(heading);
return `#${slug}`;
}