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[]) => { |
||||
if (children[children.length - 1].includes(check)) { |
||||
const temp = children[children.length - 1].split(check); |
||||
const headingId = temp[temp.length - 1].split('}')[0]; |
||||
|
||||
children[children.length - 1] = temp[0]; |
||||
|
||||
const CHECK = '{#'; |
||||
const lastChild = children[children.length - 1]; |
||||
const split = lastChild.split(CHECK); |
||||
if (lastChild.includes(CHECK)) { |
||||
const headingId = split[split.length - 1].split('}')[0]; |
||||
const newChildren = [...children]; |
||||
newChildren[newChildren.length - 1] = split[0]; |
||||
return { |
||||
children, |
||||
title: temp[0].replaceAll('#', ''), |
||||
children: newChildren, |
||||
title: split[0].replaceAll('#', ''), |
||||
headingId |
||||
}; |
||||
} |
||||
|
||||
return null; |
||||
return { |
||||
children, |
||||
title: split[0].replaceAll('#', ''), |
||||
headingId: getKebabCaseFromName(split[0]) |
||||
}; |
||||
}; |
||||
|
Loading…
Reference in new issue