Skip to content

Commit

Permalink
Add the bit-toc component
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Chasen Le Hara committed Apr 23, 2019
1 parent 146efef commit 3c7a158
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion make-example.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ var siteConfig = {
// we get an error without this, here, though
"steal-stache": "^4.0.1",
"steal-conditional": "^0.3.6",
"bit-docs-html-codepen-link": "^1.0.0"
"bit-docs-html-codepen-link": "^1.0.0",
"bit-docs-html-toc": "^1.1.1"
},
staticDist: [
path.join(__dirname, "dist", "static")
Expand Down
12 changes: 12 additions & 0 deletions static/canjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,18 @@ function init() {
sidebarViewModel.selectedPageName = window.docObject.name;
}

// Set up the client-side TOC
var tocContainer = document.querySelector("#scroll-toc");
var oldToc = document.querySelector("bit-toc");
if (oldToc) {
tocContainer.removeChild(oldToc);
}
var newToc = document.createElement("bit-toc");
newToc.depth = window.docObject.outline;
newToc.headingContainerSelector = "#right > article";
newToc.scrollSelector = "#scroll-toc";
tocContainer.appendChild(newToc);

if (!surveyAdControl) {
// Set up the survey ad control
surveyAdControl = new SurveyAdControl("survey-ad");
Expand Down
2 changes: 2 additions & 0 deletions templates/content.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,7 @@
{{/with}}

</div>
<div class="column" id="scroll-toc">
</div>
</div>
{{> survey-ad.mustache}}

0 comments on commit 3c7a158

Please sign in to comment.