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

关于目录的一个问题:指定文章禁用右侧的目录 #943

Closed
xovel opened this Issue Jun 14, 2016 · 5 comments

Comments

Projects
None yet
3 participants
@xovel
Copy link

xovel commented Jun 14, 2016

翻遍了issue愣是没找到处理方案。

目的:指定某一篇文章,文章里面有hx形式的标题,常规情况下会生成一个目录放在右侧的侧边栏。但是某些场景下,我并不需要这个目录显示。又不想去掉正文中的hx标签。但侧边栏还是要留着。。。

求教如何去实现?

是不是这个需求有点奇葩了?

@lzhr

This comment has been minimized.

Copy link

lzhr commented Jun 17, 2016

自己写一个special-layout ?
post.swig片段:

{% block sidebar %}
  {{ sidebar_template.render(true) }}
{% endblock %}
@lzhr

This comment has been minimized.

Copy link

lzhr commented Jun 17, 2016

sidebar.swig片段:

{% set display_toc = is_post and theme.toc.enable %}

      {% if display_toc %}
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            {{ __('sidebar.toc') }}
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            {{ __('sidebar.overview') }}
          </li>
        </ul>
      {% endif %}
@xovel

This comment has been minimized.

Copy link

xovel commented Jun 20, 2016

@lzhr
I just solved this by using a special front-matter: notoc: true
。。。习惯了英文

多谢提点,问题已解决。

..\layout\_macro\sidebar.swig中将

{% set display_toc = is_post and theme.toc.enable %}

这一句改成:

{% set display_toc = is_post and theme.toc.enable and !page.notoc %}

如果需要禁用目录,在对应的Front-Matter部分添加一个notoc: true就行了。

@ivan-nginx

This comment has been minimized.

Copy link
Collaborator

ivan-nginx commented Jul 20, 2017

@xovel dont understand u, write in English if not solved. If solved, close it please. Thank's!

@xovel

This comment has been minimized.

Copy link

xovel commented Jul 20, 2017

@ivan-nginx Well, it is done already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment