@@ -19,15 +19,21 @@ function formatWidgets(widgets) {
1919 return result ;
2020}
2121
22- function hasColumn ( widgets , position ) {
22+ function hasColumn ( widgets , position , config , page ) {
23+ const showToc = ( config . toc === true ) && [ 'page' , 'post' ] . includes ( page . layout ) ;
2324 if ( Array . isArray ( widgets ) ) {
24- return typeof widgets . find ( widget => widget . position === position ) !== 'undefined' ;
25+ return typeof widgets . find ( widget => {
26+ if ( widget . type === 'toc' && ! showToc ) {
27+ return false ;
28+ }
29+ return widget . position === position ;
30+ } ) !== 'undefined' ;
2531 }
2632 return false ;
2733}
2834
29- function getColumnCount ( widgets ) {
30- return [ hasColumn ( widgets , 'left' ) , hasColumn ( widgets , 'right' ) ] . filter ( v => ! ! v ) . length + 1 ;
35+ function getColumnCount ( widgets , config , page ) {
36+ return [ hasColumn ( widgets , 'left' , config , page ) , hasColumn ( widgets , 'right' , config , page ) ] . filter ( v => ! ! v ) . length + 1 ;
3137}
3238
3339function getColumnSizeClass ( columnCount ) {
@@ -61,7 +67,7 @@ class Widgets extends Component {
6167 render ( ) {
6268 const { site, config, helper, page, position } = this . props ;
6369 const widgets = formatWidgets ( config . widgets ) [ position ] || [ ] ;
64- const columnCount = getColumnCount ( config . widgets ) ;
70+ const columnCount = getColumnCount ( config . widgets , config , page ) ;
6571
6672 if ( ! widgets . length ) {
6773 return null ;
@@ -89,7 +95,7 @@ class Widgets extends Component {
8995 }
9096 return null ;
9197 } ) }
92- { position === 'left' && hasColumn ( config . widgets , 'right' ) ? < div class = { classname ( {
98+ { position === 'left' && hasColumn ( config . widgets , 'right' , config , page ) ? < div class = { classname ( {
9399 'column-right-shadow' : true ,
94100 'is-hidden-widescreen' : true ,
95101 'is-sticky' : isColumnSticky ( config , 'right' )
0 commit comments