Merge pull request #931 from stackernews/fix-toc-slugs
Fix ToC due to repeated slug calls
This commit is contained in:
commit
1b2bb6d0fb
|
@ -80,8 +80,8 @@ export default memo(function Text ({ rel, imgproxyUrls, children, tab, itemId, o
|
||||||
|
|
||||||
const Heading = useCallback(({ children, node, ...props }) => {
|
const Heading = useCallback(({ children, node, ...props }) => {
|
||||||
const [copied, setCopied] = useState(false)
|
const [copied, setCopied] = useState(false)
|
||||||
const id = useMemo(() =>
|
const nodeText = toString(node)
|
||||||
noFragments ? undefined : slugger?.slug(toString(node).replace(/[^\w\-\s]+/gi, '')), [node, noFragments, slugger])
|
const id = useMemo(() => noFragments ? undefined : slugger?.slug(nodeText.replace(/[^\w\-\s]+/gi, '')), [nodeText, noFragments, slugger])
|
||||||
const h = useMemo(() => {
|
const h = useMemo(() => {
|
||||||
if (topLevel) {
|
if (topLevel) {
|
||||||
return node?.TagName
|
return node?.TagName
|
||||||
|
|
Loading…
Reference in New Issue