- {/* Future Payload Table of Contents Implementation */}
+
diff --git a/components/PayloadRichText.tsx b/components/PayloadRichText.tsx
index 598441f8..d57eaaa4 100644
--- a/components/PayloadRichText.tsx
+++ b/components/PayloadRichText.tsx
@@ -51,27 +51,74 @@ const jsxConverters: JSXConverters = {
heading: ({ node, nodesToJSX }: any) => {
const children = nodesToJSX({ nodes: node.children });
const tag = node?.tag;
+
+ // Extract text to generate an ID for the TOC
+ // Lexical children might contain various nodes; we need a plain text representation
+ const textContent = node.children ? node.children.map((c: any) => c.text || '').join('') : '';
+ const id = textContent
+ ? textContent
+ .toLowerCase()
+ .replace(/ä/g, 'ae')
+ .replace(/ö/g, 'oe')
+ .replace(/ü/g, 'ue')
+ .replace(/ß/g, 'ss')
+ .replace(/[*_`]/g, '')
+ .replace(/[^\w\s-]/g, '')
+ .replace(/\s+/g, '-')
+ .replace(/-+/g, '-')
+ .replace(/^-+|-+$/g, '')
+ : undefined;
+
if (tag === 'h1')
return (
-