Closed AquaGeneral closed 4 years ago
@sintaxi Sorry to both but I really still would like some guidance on this.
You may find this blog post useful. It teaches some techniques that I think you will find helpful.
https://medium.com/@magician03/how-to-host-portfolio-and-blog-using-github-pages-harpjs-bb301dd901ac
I'm trying to create a automatically generated table of contents in my documentation page. Basically I need to go through the documentation text, find the elements I'm interested in by name and add those to the table of contents accordingly. It should also link directly to the elements.
I've placed the contents of the documentation into
_documentationBase.jade
. There is then adocumentation.jade
page that will add the table of contents and the documentation itself. What I am stuck on is I want to get a DOM represntation of the partial_documentationBase.jade
.The partial gives me a big string, and to find the parts I want out of that I want it to be a Document so I can call things like
getElementsByName
and more. To create a DOM object out of the string, it's possible to use the following:new Document().createElement('div').innerHTML = ...;
new DOMParser().parseFromString(...)
.Constructing a JS Document or DOMParser as unbuffered code in Jade results in the following error:
So what is the best way to go about this? I could easily make the table of contents on the client side, but that really is not a good use of Harp. I'm guessing there's possibly some much more simple way to go about this?