forked from Gitlink/forgeplus-react
markdown目录问题
This commit is contained in:
parent
ae82595800
commit
a0c88ba24a
|
@ -22,7 +22,8 @@ function CoderDepotReadme({ operate , history , readme , ChangeFile }){
|
||||||
const items = $.map($("#readme").find("h1,h2,h3,h4,h5,h6"), function (el, _) {
|
const items = $.map($("#readme").find("h1,h2,h3,h4,h5,h6"), function (el, _) {
|
||||||
const anchor = el.id;
|
const anchor = el.id;
|
||||||
const level = el.tagName.replace("H", "");
|
const level = el.tagName.replace("H", "");
|
||||||
const href = `#${anchor}`;
|
let id = anchor.replace(/[.,/#!$%^&*;:{}=\-_`~():,。¥;「」|?》《~·【】‘、!]/g,"");
|
||||||
|
const href = `#${id}`;
|
||||||
return { href:`${href}`,text:el.textContent , level:level }
|
return { href:`${href}`,text:el.textContent , level:level }
|
||||||
});
|
});
|
||||||
setMenuList(items);
|
setMenuList(items);
|
||||||
|
|
|
@ -40,7 +40,7 @@ function ReadmeCatelogue({ menuList , hash }) {
|
||||||
menu.map((item,key)=>{
|
menu.map((item,key)=>{
|
||||||
return(
|
return(
|
||||||
<div style={{paddingLeft:`${item.level *15}px`}} className={goHref===item.href?"items active":"items"}>
|
<div style={{paddingLeft:`${item.level *15}px`}} className={goHref===item.href?"items active":"items"}>
|
||||||
<Link href={`#${item.text}`} title={item.text} />
|
<Link href={`${item.href}`} title={item.text} />
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue