Closed adamflott closed 4 years ago
Hrmm, I'm not sure about this one!
I believe the $table-of-contents$
syntax is part of a pandoc template, so you'll probably have to enable that somehow too? I'm afraid I'm definitely not an expert on pandoc internals 😬 I probably won't be much help on this one, but if you can figure it out I'd love to hear how it goes 😄
Seems it is $toc
per https://svejcar.dev/posts/2019/11/27/table-of-contents-in-hakyll/
Thanks @srid that was it!!
How I got it working
myHtml5Options :: Template T.Text -> WriterOptions
myHtml5Options t =
defaultHtml5Options {
writerNumberSections = True
, writerTableOfContents = True
, writerTOCDepth = 20
, writerTemplate = Just t
}
buildPost :: FilePath -> Action (Maybe Post)
buildPost srcPath = cacheAction ("build" :: T.Text, srcPath) $ do
-- stuff from slick-template
Right x <- liftIO $ compileTemplate "" "$toc$\n$body$"
postData <- markdownToHTMLWithOpts defaultMarkdownOptions (myHtml5Options x) . T.pack $ postContent
Nice, thanks everyone 👍
Is there a way to include a table of contents in my posts? I tried altering the
WriterOptions
and using the pandoc template variables ($table-of-contents$
) but those didn't work. Any hints where else to look?