Empty `options` fails to render sidebar
dmohns opened this issue · comments
Describe the bug
When calling generateSidebar
with an empty options object the sidebar generation returns {}
. Passing anything fixes the behaviour, see example below.
To Reproduce
console.log('Empty options');
console.log(generateSidebar({}));
console.log('(Essentially) Empty options');
console.log(generateSidebar({ debugPrint: false }));
Returns
Empty options
{}
(Essentially) Empty options
[
{ text: 'dev_docs', items: [ [Object], [Object], [Object] ] },
{ text: 'introduction', items: [ [Object], [Object], [Object] ] },
{
text: 'usage_guide',
items: [ [Object], [Object], [Object], [Object] ]
}
]
Expected behavior
When calling with empty options a rendered sidebar with default values should be returned. While (I think) this doesn't happen too often in a live environment, it might occur when users are exploring and playing around with the library.
Screenshots If applicable, add screenshots to help explain your problem.
N/A
Desktop (please complete the following information):
- OS: [e.g. Windows 10] MacOS
- Browser [e.g. Chrome, Safari] Chrome
Additional context
I'm not very experienced with JavaScript. Maybe such a behaviour is totally normal and intuitive for JS users. If so, please ignore this bug report 😉
Hello, Thank you for using vitepress-sidebar
.
Your comment is valid and makes a very good point. It seems that plugin need to handle empty objects or empty option values correctly.
So i have fixed that issue and it will be reflected in the next release.
Thanks!