Skip to content

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

fix: use github-slugger instead of custom slugify

Sushmithamalleshe6c2cb079289
diff --git a/docs/scripts/validate-links.ts b/docs/scripts/validate-links.ts
index cd0b7b68b..4482c3aa5 100644
--- a/docs/scripts/validate-links.ts
+++ b/docs/scripts/validate-links.ts
@@ -7,6 +7,7 @@ import {
scanURLs,
validateFiles,
} from 'next-validate-link';
+import GithubSlugger from 'github-slugger';
import {
source,
getReferenceSource,
@@ -22,28 +23,18 @@ type AnySource =
type PageOf = ReturnType<AnySource['getPages']>[number];
-/**
- * Slugify a heading the same way rehype-slug does.
- */
-function slugify(text: string): string {
- return text
- .toLowerCase()
- .replace(/[^\w\s-]/g, '')
- .replace(/[\s]+/g, '-')
- .replace(/-+/g, '-')
- .replace(/^-|-$/g, '');
-}
-
/**
* Extract heading anchors from raw MDX/markdown content.
* Falls back to this when data.toc is unavailable (outside Next.js runtime).
+ * Uses github-slugger to match rehype-slug's algorithm (handles Unicode, duplicate suffixes).
*/
function extractHeadingsFromContent(content: string): string[] {
+ const slugger = new GithubSlugger();
const headings: string[] = [];
for (const line of content.split('\n')) {
const match = line.match(/^#{1,6}\s+(.+)$/);
if (match) {
- headings.push(slugify(match[1]));
+ headings.push(slugger.slug(match[1]));
}
}
return headings;