With paged.js, the table of content need to be generated before that paged.js fragmented the content into pages. You need to the hook `before` to call the script.
Add this code in the `head` of you html document:
```html
<script>
window.PagedConfig={
before:function(){
createToc({
tocElement:'#my-toc-content',
titleElements:['h1','h2','h3']
});
}
};
</script>
```
Additionnaly, add the `async` property to the paged.js script:
```html
<script asyncsrc="http://localhost:9090/dist/paged.polyfill.js"></script><!-- if you use paged.js with npm -->
<script asyncsrc="http://unpkg.com/pagedjs/dist/paged.polyfill.js"></script><!-- if you use the online script of paged.js -->
```
The folder contain also a minimal stylesheet to add the corresponding page numbers with paged.js and add some style to the toc list:
`tocElement`: define the id element where the toc list will be create
`titleElements`: array of the title element you want in the toc list. You can add as many as you want and the elements can be classes like `.title-1` or `.my-content h1`