Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sidebar: 'auto' doesn't create sidebar #178

Closed
kdankert opened this issue Dec 6, 2020 · 3 comments · Fixed by #224
Closed

sidebar: 'auto' doesn't create sidebar #178

kdankert opened this issue Dec 6, 2020 · 3 comments · Fixed by #224
Assignees
Labels
bug Something isn't working

Comments

@kdankert
Copy link

kdankert commented Dec 6, 2020

Describe the bug
Using sidebar auto doesn't produce sidebar at all, even it is considered to be a valid option in https://github.com/vuejs/vitepress/blob/master/src/client/theme-default/config.ts.

To Reproduce

  1. Create a new project
  2. Configure vitepress to use sidebar: 'auto' in .vitepress/config.js
  3. Create some pages with headings
  4. Start dev server

Expected behavior
A sidebar should be auto generated using the headings provided in the markdown files

System Info

  • vitepress version: v0.9.1
  • vite version: v1.0.0-rc.13
  • Node version: v15.3.0
  • OS version: macOS 10.15.7 (19H2)
@kdankert kdankert added the bug: pending triage Maybe a bug, waiting for confirmation label Dec 6, 2020
@YunshuaiPeng
Copy link

Sidebar object is required.Check out https://github.com/vuejs/vitepress/blob/master/docs/.vitepress/config

@kiaking
Copy link
Member

kiaking commented Feb 5, 2021

Yap this is bug. Sidebar is actually mounted, but it's hidden because at layout component it treats it as hidden.

const showSidebar = computed(() => {
  const { frontmatter } = route.data
  const { themeConfig } = siteRouteData.value
  return (
    !frontmatter.home &&
    frontmatter.sidebar !== false &&
    ((typeof themeConfig.sidebar === 'object' &&
      Object.keys(themeConfig.sidebar).length != 0) ||
      (Array.isArray(themeConfig.sidebar) && themeConfig.sidebar.length != 0))
  )
})

So fixing this code, should correctly show the auto sidebar 🔥

@kiaking kiaking added bug Something isn't working and removed bug: pending triage Maybe a bug, waiting for confirmation labels Feb 5, 2021
@kiaking kiaking self-assigned this Feb 5, 2021
kiaking added a commit that referenced this issue Feb 9, 2021
BREAKING CHANGE: If sidebat is `undefined`, it will be treated as `auto` where
previsouly it's treated as `false`. It was always treated as `auto`, but due to
this bug, the sidebar was hidden, therefore it looked like it was treated
as `false`.
@cloydlau
Copy link

cloydlau commented Nov 16, 2022

Has this been removed later on? I got a TypeError: Cannot read properties of undefined (reading 'some') with the following config:

sidebar: {
  'XXX': 'auto',
}

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants