Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Fix anchor

Joshen Lim9a56ad4f286d
diff --git a/apps/docs/components/CustomHTMLElements/CustomHTMLElements.utils.ts b/apps/docs/components/CustomHTMLElements/CustomHTMLElements.utils.ts
index a405988030e..b64d4ed8086 100644
--- a/apps/docs/components/CustomHTMLElements/CustomHTMLElements.utils.ts
+++ b/apps/docs/components/CustomHTMLElements/CustomHTMLElements.utils.ts
@@ -7,13 +7,27 @@ export const getAnchor = (text: any): string | undefined => {
)
if (customAnchor !== undefined) return customAnchor.slice(3, customAnchor.indexOf('}'))
- const formattedText = text.map((x) => {
- if (typeof x !== 'string') return x.props.children
- else return x.trim()
- })
+ const formattedText = text
+ .map((x) => {
+ if (typeof x !== 'string') return x.props.children
+ else return x.trim()
+ })
+ .map((x) =>
+ x
+ .toLowerCase()
+ .replace(/[^a-z0-9- ]/g, '')
+ .replace(/[ ]/g, '-')
+ )
return formattedText.join('-').toLowerCase()
} else {
- return text.props.children
+ const anchor = text.props.children
+ if (typeof anchor === 'string') {
+ return anchor
+ .toLowerCase()
+ .replace(/[^a-z0-9- ]/g, '')
+ .replace(/[ ]/g, '-')
+ }
+ return anchor
}
} else if (typeof text === 'string') {
if (text.includes('{#') && text.endsWith('}')) {