From 88ab0538d9de7d77e3081f2dae6d00e845c8d9c8 Mon Sep 17 00:00:00 2001 From: Jacob Marshall Date: Wed, 29 Jan 2025 22:45:15 +0000 Subject: [PATCH] update id gen --- .../src/components/MdxProvider/MdxTitle/MdxTitle.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/documentation/src/components/MdxProvider/MdxTitle/MdxTitle.tsx b/apps/documentation/src/components/MdxProvider/MdxTitle/MdxTitle.tsx index 59f3a402..dba88ed5 100644 --- a/apps/documentation/src/components/MdxProvider/MdxTitle/MdxTitle.tsx +++ b/apps/documentation/src/components/MdxProvider/MdxTitle/MdxTitle.tsx @@ -29,7 +29,15 @@ function getIdFrom(children: ReactNode): string { ? children.map(getTextContent).join('') : getTextContent(children) - return textContent.toLowerCase().replace(/[\s\W_]+/g, '-') + return textContent + .normalize('NFKD') // separate accented characters into their base form and diacritical marks + .replace(/[\u0300-\u036f]/g, '') // remove all the accents + .trim() + .toLowerCase() + .replace(/\./g, '-') // some titles (configuration) contain keypath, so replace dots with hyphens + .replace(/[^a-z0-9 -]/g, '') // remove non-alphanumeric characters + .replace(/\s+/g, '-') // replace spaces with hyphens + .replace(/-+/g, '-') // remove consecutive hyphens } export const h = (order: 1 | 2 | 3 | 4 | 5 | 6): ElementType => {