ozum/vuepress-bar

How to specify pages

fanux opened this issue · 10 comments

fanux commented

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

Could you provide a sample repo please?

fanux commented
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

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

I think add a pages list will better

ozum commented

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

So dir like this?

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

Two .vuepress dir?

ozum commented

No, just single .vuepress.

Only in /docs/.vuepress:

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

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

ozum commented

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

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 😄