Vuepress: Search will show me the files I haven't Uploaded

Created on 30 Oct 2019  ·  5Comments  ·  Source: vuejs/vuepress




  • [x] I confirm that this is an issue rather than a question.




Bug report

Steps to reproduce

My English is pool, so i will use Chinese to convey my original meaning with the help of translation software.

What is expected?

I used GitHub Page + Vuepress to build a static blog. I uploaded some files in the 'docs' folder, but they did not configure the routing information.I hope that the content will not appear in the search, because I don't want it to appear.

我使用了 Github Page + Vuepress 搭建一个静态博客,我在docs文件夹中上传了一些文件,但是他们并未配置路由信息。我希望在搜索的时候不会出现这些内容,因为我不希望这些内容展现出来。

What is actually happening?

In fact, when I search, these pages that I have not configured routing information are also displayed, and even can be accessed.

事实上,当我搜索的时候,这些我未配置路由信息的页面也展示了出来,而且竟然能访问。

Other relevant information

  • Output of npx vuepress info in my VuePress project:
    I don't know if this design is in line with the author's original intention. If it doesn't, I'm glad to help the author find a problem. If it doesn't, I hope the author can give me some suggestions to solve this problem. Thank you very much.
    > 我不知道这个设计是否符合作者的原意,如果不符合,那么我很高兴帮助作者发现了一个问题;如果不符合,希望作者能给我一点小建议去解决这个问题,感激不尽。

Most helpful comment

Hi @learningNicolas ,

I believe that patterns is what you are looking for. (Simply click on the link before doesn't seem to nav to the correct location, you can find it under Config Reference > Basic Config > patterns)

For example, if your docs' folder structure is:

├── docs
│   ├── .vuepress
│   ├── private
│   ├── README.md
│   ├── guide

The config.js would be:

patterns: ['**/*.md', '**/*.vue', '!private'],

Then all of your docs in the private folder won't be built.

Refers:

  • PR that solved this: #1705
  • Another related issue: #1558

All 5 comments

Just as the doc said: it automatically builds a simple search index from the title, h2 and h3 headers from all the pages. no matter whether you config it in the route. I think it is by proposing..

Obviously your 'extra' files have a header like h2, h3...
So why not push your 'extra file' to another branch? not the building one.

据我了解文按照档里写的vuepress的搜索功能会搜索所有含有 h2, h3的文件。我觉的应该是这样的设计的。 如果不想被搜索的话 为啥不把这些‘多余’的文件push到其他的分支?而不是你用来build的github page的分支

Thanks for your suggestion, actually i try to use .gitignore file to untrack some .md file, and them can't be found on my github repository, But it seems that in the process of build, vuepress has already indexed these files and generated some .js files.
I describe my usage scenarios and may help you understand my problem. I use Typora (a markdown editing software) to write my notes, some of which are not suitable for public posting, but For the sake of convenience, I also hope that they can be managed in a unified folder, so I encountered the problem raised earlier.

感谢你的建议,事实上我使用.gitignore文件进行过尝试,把一些不想提交的文件截留了下来,这些.md文件并不能在我的 Github 仓库上找到,但似乎在build的过程中,vuepress就已经将这些文件建立索引,并生成了一些.js文件。
我描述下我的使用场景,可能会有助于您理解我的问题,我使用Typora(一个markdown编辑软件)来编写我的笔记,其中有一些私密内容并不适合公开发表,但为了方便我又希望能在一个统一的文件夹下对它们进行管理,所以遇到了前面提出的问题。

Hi @learningNicolas ,

I believe that patterns is what you are looking for. (Simply click on the link before doesn't seem to nav to the correct location, you can find it under Config Reference > Basic Config > patterns)

For example, if your docs' folder structure is:

├── docs
│   ├── .vuepress
│   ├── private
│   ├── README.md
│   ├── guide

The config.js would be:

patterns: ['**/*.md', '**/*.vue', '!private'],

Then all of your docs in the private folder won't be built.

Refers:

  • PR that solved this: #1705
  • Another related issue: #1558

Thank you very much, @ludanxer
It works! 👍 👍
also thanks for your help @haochenli

As @ludanxer said, pattern is what you're looking for. Thanks !

Was this page helpful?
0 / 5 - 0 ratings