ozum/vuepress-bar

if there is another md file (besides README.md) at top level, replacements fail

ssuess opened this issue · 2 comments

Hi, I have the following code in my config file:

sidebar.forEach((item) => { if (item !=='' && item.title.includes("Api")) { item.title = item.title.replace("Api", "API"); }})

which works fine as long as I only have one top level README.md file and everything else is inside subfolders. But the moment I add another top level file (like somthing.md) it fails with the following error:

TypeError: Cannot read property 'includes' of undefined

I made a workaround:

sidebar.forEach((item) => { 
if (typeof item.title !== 'undefined') { 
if (item !=='' && item.title.includes("Api")) { item.title = item.title.replace("Api", "API"); }
}
})

But still not sure why this happens.

ozum commented

Thanks for the provided workaround.