Giter Club home page Giter Club logo

Comments (5)

ATQQ avatar ATQQ commented on August 18, 2024

https://theme.sugarat.top/config/global.html#recommend

可以看一下全局的 recommend 配置 里的filter 方法。

理论上列表为空的时候就可以不展示 主题内置的这个相关文章。

from sugar-blog.

ATQQ avatar ATQQ commented on August 18, 2024
const blogTheme = getThemeConfig({
  recommend: {
    filter(page){
     // 筛选过滤为空数组 
    },
    empty: false // false时无推荐文章不展示此模块
  }
})

from sugar-blog.

wakaryry avatar wakaryry commented on August 18, 2024

那么我要如何才能显示出来 博客主题 下的 相关文章 侧边栏了?

我现在是想某个文件夹下面的文档按照vitepress的sidebar来配置,我们可以控制分类。
其他的文章就算是博客文章,按照我们的主题来配置,左侧出现的是 相关文章 类似的配置。

问题是:我为doc设置sidebar之后,非doc文件夹下的博客文章的侧边栏就不会显示出来。

{
sidebar: {
      '/doc/': {
        base: '/doc/',
        items: [
          {
            text: '简介',
            collapsed: false,
            items: [
              {
                text: '指引',
                link: 'guide'
              }
            ]
          }
        ]
      }
    },
}
{
// 推荐文章
  recommend: {
    // 当没有推荐文章时的提示,设置为 false 则不展示
    empty: false,
    filter: (page) => {
      // console.log(page)
      if (page.route.startsWith('/doc/')) {
        return false
      }
      return true
    }
  }
}

谢谢

from sugar-blog.

ATQQ avatar ATQQ commented on August 18, 2024

sidebar 配置成一个数组,加入一项这个

sidebar: [
          {
            text: '',
            items: []
          }
        ]

from sugar-blog.

wakaryry avatar wakaryry commented on August 18, 2024

这样设置is OK。

sidebar: {
      '/': {
        base: '/',
        items: [{
          text: '',
          items: []
        }]
      },
      '/doc/': {
          base: '/doc/',
          items: sidebarDoc()
        }
    }

感谢提示。

from sugar-blog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.