Merge pull request #931 from stackernews/fix-toc-slugs

Fix ToC due to repeated slug calls
This commit is contained in:
Keyan 2024-03-17 12:49:12 -05:00 committed by GitHub
commit 1b2bb6d0fb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 2 deletions

View File

@ -80,8 +80,8 @@ export default memo(function Text ({ rel, imgproxyUrls, children, tab, itemId, o
const Heading = useCallback(({ children, node, ...props }) => {
const [copied, setCopied] = useState(false)
const id = useMemo(() =>
noFragments ? undefined : slugger?.slug(toString(node).replace(/[^\w\-\s]+/gi, '')), [node, noFragments, slugger])
const nodeText = toString(node)
const id = useMemo(() => noFragments ? undefined : slugger?.slug(nodeText.replace(/[^\w\-\s]+/gi, '')), [nodeText, noFragments, slugger])
const h = useMemo(() => {
if (topLevel) {
return node?.TagName