[ 
https://issues.apache.org/jira/browse/SLING-10686?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17389762#comment-17389762
 ] 

Konrad Windszus commented on SLING-10686:
-----------------------------------------

The TOC JS doesn't reuse the already generated anchors (by the flexmark 
extension https://github.com/vsch/flexmark-java/wiki/Extensions#anchorlink) but 
instead generates dynamically its own ones in 
https://github.com/nghuuphuoc/tocjs/blob/09e1aaa07dc83c50aeb3c30bcd423aa321a9e148/dist/js/toc.js#L209.

> Site: Fix TOC links
> -------------------
>
>                 Key: SLING-10686
>                 URL: https://issues.apache.org/jira/browse/SLING-10686
>             Project: Sling
>          Issue Type: Improvement
>          Components: Site
>            Reporter: Konrad Windszus
>            Priority: Major
>
> Currently the table of contents is generated by 
> https://github.com/apache/sling-site/blob/ac12de1fa98bd50958d6d0e606e7cc35f05f99aa/src/main/jbake/templates/toc-brick.tpl
>  with the help of the https://github.com/nghuuphuoc/tocjs (which is no longer 
> maintained).
> It generates anchor links with a `-1` suffix like 
> `https://sling.apache.org/documentation/bundles/scripting/scripting-htl.html#type-conversions-1`
>  which don't work when called outside the page.
> To fix this we should either
> 1.  switch to the markdown TOC macro (as outlined in 
> https://github.com/vsch/flexmark-java/wiki/Table-of-Contents-Extension). This 
> requires adjustments though of the TOC macro in almost every MD source as 
> this by default only renders entries for h2-h3.
> 2. generate the TOC in the template with another JS library
> 3. generate the TOC in the template purely server-side (requires parsing of 
> HTML and probably a lot of groovy code)



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to