@@ -29,32 +29,64 @@ To use, add bit-docs-html-toc to your bit-docs dependencies in package.json:
29
29
30
30
Where ` $VERSION ` is the latest version on npm.
31
31
32
- In your template add a class ** on-this-page-container ** :
32
+ In your template add a ` <bit-toc> ` element :
33
33
34
34
``` html
35
- <div class = " on-this-page-container " ></div >
35
+ <bit-toc ></bit-toc >
36
36
```
37
37
38
- By default, all heading tags children of the first ` article ` tag on the page will
38
+ ## Attributes
39
+
40
+ ` <bit-toc> ` supports the following attributes:
41
+
42
+ ### heading-container-selector
43
+
44
+ By default, all heading tags children of the first ` article ` tag on the page will
39
45
be collected to create the table of contents; if you want to use a different element
40
46
just do:
41
47
42
48
``` html
43
- <div
44
- class =" on-this-page-container"
45
- data-heading-container-selector =" #my-custom-selector"
49
+ <bit-toc
50
+ heading-container-selector =" #my-custom-selector"
46
51
>
47
- </div >
52
+ </bit-toc >
48
53
```
49
54
50
55
The table of contents will be injected into this element at run time.
51
56
57
+ ### depth
58
+
59
+ By default, only ` h2 ` elements are collected. You
60
+ can change to include ` <h3> ` elements by setting depth like:
52
61
53
- To control the number of child headers that will be included in the TOC, use the
62
+ ``` html
63
+ <bit-toc depth =" 2" ></bit-toc >
64
+ ```
65
+
66
+ Alternatively, the number of child headers that will be included in the TOC, use the
54
67
` @outline ` tag like so:
55
68
56
69
```
57
70
@outline 2
58
71
```
59
72
60
- This will include ` <h2> ` and ` <h3> ` elements, rather than the normal ` <h2> ` only.
73
+ ### child-tag
74
+
75
+ If you want ` <li> ` 's to be within an ` <ol> ` instead of a ` <ul> ` , this
76
+ can be configured like:
77
+
78
+ ``` html
79
+ <bit-toc child-tag =" ol" ></bit-toc >
80
+ ```
81
+
82
+ ## Methods
83
+
84
+ Call ` .highlight() ` to force an update of the ` active ` or ` completed `
85
+ class names on the ` <li> ` elements:
86
+
87
+ ``` js
88
+ document .querySelector (" bit-toc" ).highlight ()
89
+ ```
90
+
91
+ This happens automatically when the ` heading-container-selector `
92
+ element is scrolled.
0 commit comments