File tree Expand file tree Collapse file tree 6 files changed +63
-5
lines changed Expand file tree Collapse file tree 6 files changed +63
-5
lines changed Original file line number Diff line number Diff line change 1+ = Page with ad and subheadings
2+ :page-ad-icon: mortarboard
3+ :page-ad-title: Free, Hands-on training with Neo4j GraphAcademy
4+ :page-ad-description: We're here to guide you on a fun and engaging journey to mastering Neo4j with free, hands-on courses.
5+ :page-ad-link: https://graphacademy.neo4j.com/?ref=promo-generic
6+ :page-ad-underline-role: button
7+ :page-ad-underline: Enroll now
8+
9+
10+ == Section 1
11+ This page has subheadings, so `toc-menu` is generated.
12+
13+ == Section 2
14+ This page also has an ad, which should be displayed below the page contents.
Original file line number Diff line number Diff line change 1+ = Page with subheadings but no ad
2+
3+
4+ == Section 1
5+ This page has subheadings, so page contents is displayed.
6+
7+ == Section 2
8+ There is no ad for this page.
Original file line number Diff line number Diff line change 1+ = Page with ad and no subheadings
2+ :page-ad-icon: mortarboard
3+ :page-ad-title: Free, Hands-on training with Neo4j GraphAcademy
4+ :page-ad-description: We're here to guide you on a fun and engaging journey to mastering Neo4j with free, hands-on courses.
5+ :page-ad-link: https://graphacademy.neo4j.com/?ref=promo-generic
6+ :page-ad-underline-role: button
7+ :page-ad-underline: Enroll now
8+
9+ This page has no subheadings.
10+
11+ But we still want the `toc-ad` to be displayed.
Original file line number Diff line number Diff line change 1+ = Page with no subheadings and no ad
2+
3+ This page has no subheadings.
4+
5+ It has no ad to display so there should be no `<aside class="toc sidebar">...</aside>` in the HTML.
Original file line number Diff line number Diff line change @@ -164,6 +164,20 @@ page:
164164 - content : warning
165165 url : banner-warning.html
166166 urlType : internal
167+ - content : Sidebar
168+ items :
169+ - content : No headings, no ad
170+ url : sidebar-no-headings-no-ad.html
171+ urlType : internal
172+ - content : No headings, with ad
173+ url : sidebar-no-headings-ad.html
174+ urlType : internal
175+ - content : Headings, no ad
176+ url : sidebar-headings-no-ad.html
177+ urlType : internal
178+ - content : Headings, with ad
179+ url : sidebar-headings-ad.html
180+ urlType : internal
167181 - content : Labels
168182 url : labels.html
169183 urlType : internal
Original file line number Diff line number Diff line change 1111 var article = document . querySelector ( 'article.doc' )
1212 var selectors = document . querySelector ( '.nav-container .selectors' )
1313 var selectorsHeight = selectors ? selectors . getBoundingClientRect ( ) . height : 0
14- var headings
1514 var headingSelector = [ ]
1615 for ( var l = 0 ; l <= levels ; l ++ ) headingSelector . push ( l ? '.sect' + l + '>h' + ( l + 1 ) + '[id]' : 'h1[id].sect0' )
17- if ( ! ( headings = find ( headingSelector . join ( ',' ) , article ) ) . length ) return sidebar . parentNode . removeChild ( sidebar ) // remove sidebar if there are no headings
16+ var headings = find ( headingSelector . join ( ',' ) , article )
17+
18+ var menu = sidebar . querySelector ( '.toc-menu-placeholder' )
19+ if ( ! menu ) ( menu = document . createElement ( 'div' ) ) . className = 'toc-menu-placeholder'
20+ var ad = document . querySelector ( '.toc-ad' )
21+
22+ // display an ad or nothing if there are no headings
23+ if ( ! ( headings . length ) ) {
24+ if ( ! ad ) return sidebar . parentNode . removeChild ( sidebar ) // remove sidebar if there is no ad
25+ return menu . parentNode . removeChild ( menu ) // remove toc menu if there are no headings but still display ad
26+ }
1827
1928 var lastActiveFragment
2029 var links = { }
2938 return accum
3039 } , document . createElement ( 'ul' ) )
3140
32- var menu = sidebar . querySelector ( '.toc-menu-placeholder' )
33- if ( ! menu ) ( menu = document . createElement ( 'div' ) ) . className = 'toc-menu-placeholder'
34-
3541 if ( document . querySelector ( 'body.has-banner' ) ) {
3642 document . querySelector ( '.toc-menu' ) . style . top = 'calc(var(--toc-top) + var(--banner-height))'
3743 }
You can’t perform that action at this time.
0 commit comments