Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sidebar: false 失效 #13

Closed
3 tasks done
rmb122 opened this issue May 29, 2020 · 3 comments
Closed
3 tasks done

sidebar: false 失效 #13

rmb122 opened this issue May 29, 2020 · 3 comments
Labels
Bug Something isn't working Solved
Milestone

Comments

@rmb122
Copy link

rmb122 commented May 29, 2020

Please follow this Issue template to provide relevant information, such as source code repositories, blog links, and screenshots, which will help us investigate.
请按照此 Issue 模版提供相关信息,例如源码仓库、博客链接和屏幕截图,这将有助于我们进行调查。

Issue Checklist

  • I am using the latest version of NexT.
  • I have read the relevant documents of Hexo and NexT.
  • I have reviewed the latest Roadmap on GitHub and searched for current issues, which does not help me.

Expected behavior

在页面设置 sidebar: false 时, 侧边栏应隐藏
debug 之后发现是过滤器的问题

next/layout/_partials/head/head-unique.njk

<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: {{ page.sidebar | json }},
    isHome : {{ is_home() }},
    isPost : {{ is_post() }},
    lang   : '{{ page.lang }}'
  };
</script>

next/scripts/renderer.js

env.addFilter('json', dictionary => {
    return JSON.stringify(dictionary || '');
  });

导致输出在页面的配置为 '' 而不是 false.

修改为

env.addFilter('json', dictionary => {
    if (typeof dictionary !== "undefined" && dictionary !== null) {
        return JSON.stringify(dictionary);
    } else {
        return '""';
    }
  });

后正常

Actual behavior

侧边栏仍然显示

Steps to reproduce the behavior

配置文件

sidebar:
  # Sidebar Position.
  #position: left
  position: right

  # Manual define the sidebar width. If commented, will be default for:
  # Muse | Mist: 320
  # Pisces | Gemini: 240
  #width: 300

  # Sidebar Display (only for Muse | Mist), available values:
  #  - post    expand on posts automatically. Default.
  #  - always  expand for all pages automatically.
  #  - hide    expand only when click on the sidebar toggle icon.
  #  - remove  totally remove sidebar including sidebar toggle.
  display: post

  # Sidebar padding in pixels.
  padding: 18
  # Sidebar offset from top menubar in pixels (only for Pisces | Gemini).
  offset: 12
  # Enable sidebar on narrow view (only for Muse | Mist).
  onmobile: false

新建一个 post, 设置 sidebar: false

Environment Information

Node.js and NPM Information


Package dependencies Information


Hexo Configuration

NexT Configuration

Other Information

@rmb122 rmb122 added the Bug Something isn't working label May 29, 2020
@welcome
Copy link

welcome bot commented May 29, 2020

Thanks for opening this issue, maintainers will get back to you as soon as possible!

@stevenjoezhang
Copy link
Member

stevenjoezhang commented May 29, 2020

感谢反馈!稍后修复这个问题。


Thanks for your feedback! Fixed in 4013450

Ref
theme-next/hexo-theme-next#93
theme-next/hexo-theme-next#1205
theme-next/hexo-theme-next#1218

stevenjoezhang added a commit that referenced this issue May 29, 2020
@stevenjoezhang stevenjoezhang added this to the 8.0.0-rc.3 milestone Jun 7, 2020
@github-actions
Copy link

github-actions bot commented Jun 8, 2021

This thread has been automatically locked since there has not been any recent activity after it was closed. It is possible issue was solved or at least outdated. Feel free to open new for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Something isn't working Solved
Projects
None yet
Development

No branches or pull requests

2 participants