Skip to content

Commit 3c7a158

Browse files
author
Chasen Le Hara
committed
Add the bit-toc component
Right now it’s removed and re-added to the DOM every time a new page is loaded. Waiting for bit-docs/bit-docs-html-toc#26 to be implemented. Part of canjs/canjs#4744
1 parent 146efef commit 3c7a158

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

make-example.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ var siteConfig = {
2828
// we get an error without this, here, though
2929
"steal-stache": "^4.0.1",
3030
"steal-conditional": "^0.3.6",
31-
"bit-docs-html-codepen-link": "^1.0.0"
31+
"bit-docs-html-codepen-link": "^1.0.0",
32+
"bit-docs-html-toc": "^1.1.1"
3233
},
3334
staticDist: [
3435
path.join(__dirname, "dist", "static")

static/canjs.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,18 @@ function init() {
171171
sidebarViewModel.selectedPageName = window.docObject.name;
172172
}
173173

174+
// Set up the client-side TOC
175+
var tocContainer = document.querySelector("#scroll-toc");
176+
var oldToc = document.querySelector("bit-toc");
177+
if (oldToc) {
178+
tocContainer.removeChild(oldToc);
179+
}
180+
var newToc = document.createElement("bit-toc");
181+
newToc.depth = window.docObject.outline;
182+
newToc.headingContainerSelector = "#right > article";
183+
newToc.scrollSelector = "#scroll-toc";
184+
tocContainer.appendChild(newToc);
185+
174186
if (!surveyAdControl) {
175187
// Set up the survey ad control
176188
surveyAdControl = new SurveyAdControl("survey-ad");

templates/content.mustache

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,7 @@
2222
{{/with}}
2323

2424
</div>
25+
<div class="column" id="scroll-toc">
26+
</div>
2527
</div>
2628
{{> survey-ad.mustache}}

0 commit comments

Comments
 (0)