ozum / vuepress-bar

VuePress sidebar and navbar generator based on file and directory structure. Focus your documents, not sidebar or navbar.
90 stars 40 forks source link

How to specify pages #10

Closed fanux closed 4 years ago

fanux commented 4 years ago

I only want my blog pages auto-generate, but all other pages generate sidebar too, and I can't remove the root dir.

image

ozum commented 4 years ago

Could you provide a sample repo please?

fanux commented 4 years ago

https://github.com/sealyun/vuepress/blob/40ee4fb15d31bb8240a8bd6db39e220a8729a4db/.vuepress/config.js

plugins: [ ['autobar', {setHomepage : 'hide',navPrefix : "blog"}]

fanux commented 4 years ago
const getConfig = require("vuepress-bar");
const barConfig = getConfig('./')

module.exports = {
  head: [
    ['meta', { name: 'theme-color', content: '#007af5' }],
    ['meta', { name: 'apple-mobile-web-app-capable', content: 'yes' }],
    ['meta', { name: 'apple-mobile-web-app-status-bar-style', content: 'black' }],
    ['script', {}, `
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?2803648cc5852dd3e9e46bbd0bf63366";
      var s = document.getElementsByTagName("script")[0]; 
      s.parentNode.insertBefore(hm, s);
    })();
  `]
  ],
  title: 'sealyun | kubernetes安装',
  themeConfig: {
    logo: 'https://sealyun.com/img/logo.png',
    sidebar: barConfig.sidebar,
    nav: [
      { text: '离线包下载', link: 'http://store.lameleg.com', target:'_self', rel:'' },
      { text: '常见问题', link: '/faq/', target:'_self', rel:'' },
      { text: '版本变更', link: '/changelog/', target:'_self', rel:'' },
      { text: '开源项目', link: '/github/', target:'_self' },
      { text: '联系方式', link: '/contact/', target:'_self' },
      {
        text: '友情连接',
        items: [
          { text: '', items: [{link: 'https://fuckcloudnative.io/#sealyun', text: "云原生实验室"}] },
          { text: '', items: [{link: 'https://kuboard.cn/#sealyun', text: "kuboard"}] },
          { text: '', items: [{link: 'https://www.qikqiak.com/?utm_source=sealyun.com', text: "阳明的博客"}] },
          { text: '', items: [{link: 'https://zhangguanzhang.github.io/#sealyun', text: "张馆长的博客"}] },
        ]
      },
    ]
  },
}
fanux commented 4 years ago

const barConfig = getConfig("./",["/blog/","/docs/"])

I think add a pages list will better

ozum commented 4 years ago

You should add all your content to a subfolder for vuepress-bar working correctly.

For example:

Add all your content to docs (including .vuepress) folder as below:

image

Then in config.js

const getConfig = require("vuepress-bar");
const barConfig = getConfig(`${__dirname}/..`);

module.exports = {
  // ... your config 
  themeConfig: {
    sidebar: barConfig.sidebar,
    nav: [] // your nav details
  }
}
fanux commented 4 years ago

So dir like this?

website
     |--.vuepress
     |--docs
             |--.vuepress
     |--README.md

Two .vuepress dir?

ozum commented 4 years ago

No, just single .vuepress.

Only in /docs/.vuepress:

website
  |--docs
    |--.vuepress
    |--README.md
fanux commented 4 years ago

But I have other pages... this is my website: sealyun.com, and I don't expect other pages have sidebar

ozum commented 4 years ago

Maybe you can create two vuepress sites and add manual links between them in nav:

website
  |--docs1
    |--.vuepress
    |--README.md
  |--docs2
    |--.vuepress
    |--README.md
fanux commented 4 years ago

I think that is not very nice, vuepress bar add a config to filter out which pages need it will better. Like this :

const barConfig = getConfig("./",["/blog/","/docs/"])

It is my suggestion 😄