ozum/vuepress-bar

Sidebar is not defined

chris-dnv opened this issue · 3 comments

I'm trying to add the sidebar filter as per the Readme however on the build i get ReferenceError: sidebar is not defined. Could you help please?

Themeconfig in config.js

image

ozum commented

It's a JavaScript error. You didn't define the sidebar variable anywhere. First define the variable.

Please see the example below. Actually, it is the same example in README, but I added comments.

// Here we define sidebar variable.
const { nav, sidebar } = getConfig();


module.exports = {
  themeConfig: {
    nav,
	
	// Here we can use the sidebar variable defined above.
    sidebar: sidebar.filter((i) => i.title !== "Node Modules"),
  }
};

Thank you Ozum this was indeed the initial issue,

However no matter what title i try to filter i get the following error on build :

TypeError: Cannot read property 'filter' of undefined

themeConfig: { ...getConfig(${__dirname}/..`),
logo: "/logo.png",
nav: [
{ text: 'Home', link: '/' },
{ text: 'VoA2.0', link: '/01.VoA 2.0 Design/' },
{ text: 'VoA China', link: '/02.VoA China Design/' },
],
sidebar: sidebar.filter((i) => i.title !== "VoA China Design"),
},plugins: [

image

ozum commented

This problem seems again related to JS. First, try console.log(sidebar) or other debugging methods to see what is the content of the sidebar variable.