jordanshurmer / eleventy-plugin-nesting-toc Goto Github PK
View Code? Open in Web Editor NEWThis project forked from jdsteinbach/eleventy-plugin-toc
11ty plugin to generate a TOC from page content
This project forked from jdsteinbach/eleventy-plugin-toc
11ty plugin to generate a TOC from page content
This comes from an issue in the upstream fork:
Apparently, in certain situations the content
is not coming through as String. The error that gets thrown is:
`Error` was thrown:
Error: cheerio.load() expects a string
The crux of the problem, in the words of @netmikey
I found out that this happens when you try to use content on a content template itself. I guess you have to use this outside the content, e.g. on the layout template.
Need to find out what kind of object content
is when used in a content file. Then turn it into the expected string (if possible) before passing it to cheerio.
When enabling markdown-it-anchor's permalinks (so permalinks are added next to titles), this plugin includes them in the toc (which is in most case, not desired)
It leads to results like this:
This didn't happen with eleventy-plugin-toc
, the upstream version. In the upstream version, a simple hardcoded replace just removed the anchors, see here. This work for my specific use case of having # as my permalink character however I'm sure a smarter solution could be found
A simple way to do it would be to replace $el.text
by $el.contents().first().text()
, however this would probably break when using the markdown-it-anchor setting to put the permalink before the text
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.