vuepress / core

Vue-Powered Static Site Generator
https://vuepress.vuejs.org
MIT License
2.33k stars 923 forks source link

[Bug report] 1、@vuepress/plugin-search 配置不生效 2、安装 vuepress-vite 后,无论在 config.ts 中是否配置 `bundler: '@vuepress/vite'`, 都默认使用 vite 编译,这一点文档没有说明 3、sidebar 点击展开后,加载完又闪烁收起,体验不好 4、希望 sidebar 加入 collapsable 属性,就像 v1.x 中那样使用 #377

Closed WangYuLue closed 3 years ago

WangYuLue commented 3 years ago

Bug report

  1. 按照文档配置 @vuepress/plugin-search 后,nav 栏没有显示搜索框。
  2. 安装 vuepress-vite 后,无论在 config.ts 中是否配置 bundler: '@vuepress/vite', 都默认使用 vite 编译,这一点文档没有说明
  3. sidebar 点击展开后,加载完又闪烁收起,体验不好
  4. 希望 sidebar 加入 collapsable 属性,就像 v1.x 中那样使用

Description

问题一:

我的步骤

1、编译工具是 vuepress-vite, 版本 ^2.0.0-beta.23 2、在 docs/config.ts 下添加配置:

import { defineUserConfig } from 'vuepress'
import type { DefaultThemeOptions } from 'vuepress'

export default defineUserConfig<DefaultThemeOptions>({
+    plugins: [
+      [
+        '@vuepress/plugin-search',
+        {
+          locales: {
+            '/': {
+              placeholder: 'Search',
+            },
+            '/zh/': {
+              placeholder: '搜索',
+            },
+          },
+        },
+      ],
+    ],
})

页面更新后, nav 栏没有搜索框,而且没有任何异常报出来。

在尝试将 @vuepress/plugin-search 升级到 "2.0.0-beta.23" 后,依旧没法正常显示。

 "devDependencies": {
    "@vuepress/plugin-search": "2.0.0-beta.23",
    "vuepress": "^2.0.0-beta.23",
    "vuepress-vite": "^2.0.0-beta.23"
  }

问题二:

安装 vuepress-vite 后,无论在 config.ts 中是否配置 bundler: '@vuepress/vite', 都默认使用 vite 编译,这一点文档没有说明

问题三:

tutieshi_640x497_12s

如动图显示,点击 sidebar 第一行时,会自动展开再收起。

consfig.ts 中, sidebar 的配置如下:

    sidebar: {
      '/blocks/': [
        '/blocks/browser',
        '/blocks/condition',
        '/blocks/windows'
      ],
    },

问题四:

这算一个需求,希望作者可以支持

Expected behavior

问题一:期望类似 1.x 那样,配置完即可看到搜索框;如果有错误,抛出相应错误 问题二:期望如果在config中没有配置,则默认使用 webpack 编译 问题三:期望可以流畅展示,视觉上不闪烁

Screenshots

Environment info

# Paste output of `vuepress info` here
  System:
    OS: macOS Mojave 10.14.6
    CPU: (8) x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
  Binaries:
    Node: 14.16.1 - /usr/local/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 6.14.10 - /usr/local/bin/npm
  Browsers:
    Chrome: 92.0.4515.131
    Firefox: 88.0.1
    Safari: 14.1.2
  npmPackages:
    @vuepress/core:  2.0.0-beta.23 
    @vuepress/theme-default:  2.0.0-beta.23 
    vuepress: ^2.0.0-beta.23 => 2.0.0-beta.23 
  npmGlobalPackages:
    vuepress: Not Found
meteorlxy commented 3 years ago
  1. Please provide a reproduce repo, and report in a separate issue.
  2. Please read docs carefully.
  3. Please provide a reproduce repo, and report in a separate issue.
  4. Duplicated.
Mister-Hope commented 3 years ago

The second one is also something I would want to report.

For testing purposes, I am installing both packages jn my project. And i am also facing the problem that the default bunder becomes vite when bunder option is omitted.

But in the docs, the default value is described as webpack, which should be an issue.

meteorlxy commented 3 years ago

@Mister-Hope It's already described in the docs:

https://github.com/vuepress/vuepress-next/blob/9582b3b72c42b28f74484b55d88bc1fb2d8f56df/docs/guide/bundler.md#L84

But yes, we could add a tip in the config reference for users who didn't notice this line.