markdown目录问题

This commit is contained in:
caishi 2023-03-02 18:31:20 +08:00
parent ae82595800
commit a0c88ba24a
2 changed files with 3 additions and 2 deletions

View File

@ -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);

View File

@ -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>
) )
}) })