-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Support to set whether the sidebar will be shown in each single post. #93
Conversation
Don't und, why this? In short words. |
I think it is because of #92. |
@ivan-nginx Hide the specified page's sidebar in default (but in the config |
Default to force true maybe? |
Now, we could set the NexT config But in order to the situation in #92 , I think we need a configure to set it for the each pages. For example, now I need to set the |
I see. Can u set var by default to true? For around possible bugs in future. |
@@ -87,10 +87,15 @@ $(document).ready(function () { | |||
|
|||
// Expand sidebar on post detail page by default, when post has a toc. | |||
var $tocContent = $('.post-toc-content'); | |||
var isSidebarCouldDisplay = CONFIG.sidebar.display === 'post' || | |||
var display = CONFIG.page.sidebar; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var display = true
above this.
{# Exports some front-matter variables to Front-End #} | ||
<script type="text/javascript" id="page.configurations"> | ||
CONFIG.page = { | ||
sidebar: {{ page.sidebar | json_encode }}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change the variable here, because the header.swig
will be cached when using hexo g
.
Now here is the demo. (my theme config
|
it means toc control sidebar originally? |
@sli1989 Originally it has 2 conditions to control the sidebar, whether it has TOC and NexT config Now the PR is introducing a new condition, which defined in the front-matter page by page. |
@tsanie when it's also useful for new custom page using |
@sli1989 yeah, I think this PR could satisfy you. Just add the attribute like |
{# Exports some front-matter variables to Front-End #} | ||
<script type="text/javascript" id="page.configurations"> | ||
CONFIG.page = { | ||
sidebar: {{ page.sidebar | json_encode }}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about sidebar: {{ page.title | page.sidebar | json_encode }},
?
make sure the sidebar diaplay in post with titile when CONFIG.sidebar.display === 'post' || CONFIG.sidebar.display === 'always'
, don't need to add sidebar: true
in front matter of posted pages where have few words (no toc situation).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That will make a different change with the original logic. The original logic is the sidebar.display === 'post' || sidebar.display === 'always'
AND the page has a TOC in the meanwhile.
Now the code is only add an additional option that allow the user to change it. I think it is better without a breaking change. 😃
hello bro, I just modified 1 place that can support this feature.. I didn't verify other schemes I use latest next & mist. hope this can help you // source/js/src/utils.js & line 228
displaySidebar: function() {
- if (!this.isDesktop() || this.isPisces() || this.isGemini()) {
+ if (!this.isDesktop() || this.isPisces() || this.isGemini() || CONFIG.page.sidebar===false) {
return;
} I didn't know whether other place has to me modified , to my thought |
Support to set whether the sidebar would be shown in each single post.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Now we couldn't control the sidebar will be shown in some posts and not be shown in the other ones.
Issue Number(s): #92
What is the new behavior?
If you've written a front-matter
sidebar
, then the sidebar will be controlled by it.How to use?
In any post source file
source/**/XXX.md
:... date: 2018-01-28 21:16:00 sidebar: false --- ...
Does this PR introduce a breaking change?