src/tools/generate-id-from-children.tsximport React from 'react'// Helper function to generate a valid ID from children contentexport function generateIdFromChildren(children: React.ReactNode): string {// Convert children to stringconst text = React.Children.toArray(children).map((child) => {if (typeof child === 'string') return childif (typeof child === 'number') return String(child)return ''}).join(' ').trim()// Generate slug-like ID: lowercase, replace spaces/special chars with hyphensreturn (text.toLowerCase().replace(/[^\w\s-]/g, '') // Remove special characters except spaces and hyphens.replace(/\s+/g, '-') // Replace spaces with hyphens
Showing the first 20 lines.
Get full code