mirror of https://github.com/ethereum/go-ethereum
Merge branch 'master' of https://github.com/ethereum/geth-website
commit
e105ef421c
@ -0,0 +1,7 @@ |
|||||||
|
export const getKebabCaseFromName = (name: string): string => |
||||||
|
name |
||||||
|
.replace(/[#]/g, '') |
||||||
|
.trim() |
||||||
|
.toLowerCase() |
||||||
|
.replace(/ /g, '-') |
||||||
|
.replace(/[^a-z0-9-]/g, ''); |
@ -1,18 +1,22 @@ |
|||||||
const check = '{#'; |
import { getKebabCaseFromName } from './'; |
||||||
|
|
||||||
export const parseHeadingId = (children: string[]) => { |
export const parseHeadingId = (children: string[]) => { |
||||||
if (children[children.length - 1].includes(check)) { |
const CHECK = '{#'; |
||||||
const temp = children[children.length - 1].split(check); |
const lastChild = children[children.length - 1]; |
||||||
const headingId = temp[temp.length - 1].split('}')[0]; |
const split = lastChild.split(CHECK); |
||||||
|
if (lastChild.includes(CHECK)) { |
||||||
children[children.length - 1] = temp[0]; |
const headingId = split[split.length - 1].split('}')[0]; |
||||||
|
const newChildren = [...children]; |
||||||
|
newChildren[newChildren.length - 1] = split[0]; |
||||||
return { |
return { |
||||||
children, |
children: newChildren, |
||||||
title: temp[0].replaceAll('#', ''), |
title: split[0].replaceAll('#', ''), |
||||||
headingId |
headingId |
||||||
}; |
}; |
||||||
} |
} |
||||||
|
return { |
||||||
return null; |
children, |
||||||
|
title: split[0].replaceAll('#', ''), |
||||||
|
headingId: getKebabCaseFromName(split[0]) |
||||||
|
}; |
||||||
}; |
}; |
||||||
|
Loading…
Reference in new issue