Closed iagovar closed 5 years ago
If you want to create a TOC automatically, you'll have to write a plugin to extend Parsedown (the Markdown parser Pico uses).
Besides that you can use the ### This is a headline {#this-is-a-headline}
Markdown syntax in your content files to add anchors to headlines. You can then add a list of all anchors and their respective title to the YAML header of your content file and use this information to create a TOC using Twig. See "Table of contents" on http://picocms.org/cookbook/
If you want to create a TOC automatically, you'll have to write a plugin to extend Parsedown (the Markdown parser Pico uses).
Besides that you can use the
### This is a headline {#this-is-a-headline}
Markdown syntax in your content files to add anchors to headlines. You can then add a list of all anchors and their respective title to the YAML header of your content file and use this information to create a TOC using Twig. See "Table of contents" on http://picocms.org/cookbook/
Ok, thanks!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in two days if no further activity occurs. Thank you for your contributions! :+1:
Just for the record:
https://github.com/caseyamcl/toc
# GIS, Geolocation
[TOC]
Links to location related stuff.
## Linklist
- bla
## More
Plugin
<?php
class TableOfContent extends AbstractPicoPlugin
{
const API_VERSION = 2;
protected $enabled = true;
public function onContentParsed(&$content)
{
$markupFixer = new TOC\MarkupFixer();
$tocGenerator = new TOC\TocGenerator();
$content = $markupFixer->fix($content);
$toc = '<div class="toc">' . $tocGenerator->getHtmlMenu($content, 1,2) . '</div>';
if(strpos($content,'[TOC]') !== false)
{
$content = str_replace(['<p>[TOC]</p>','[TOC]'], $toc, $content);
}
}
}
Is it possible to hierarchically list h1's and h2's in posts with twig? Like the Table of Contents plugin in wordpress.