Problem: an empty Table of Contents is published at the top of posts without headings.
The code now checks for headings to have a length greater than 0 (meaning there is at least one heading). If True the ToC gets published at the top of the post. Otherwise, it's skipped.
If the markdown post does not have headings, an empty Table of Contents component will not be displayed anymore.
Problem: an empty Table of Contents is published at the top of posts without headings.
The code now checks for
headings
to have a length greater than 0 (meaning there is at least one heading). IfTrue
the ToC gets published at the top of the post. Otherwise, it's skipped.If the markdown post does not have headings, an empty Table of Contents component will not be displayed anymore.