From dbaca137f7ddd28ffbfee5119a108b9ac3602653 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Wed, 20 Jul 2022 12:00:00 +0100 Subject: [PATCH] feat: add table of contents to blog posts --- .../source/_includes/post/heading-with-anchor.html.twig | 3 +++ .../source/_includes/post/table-of-contents.html.twig | 9 +++++++++ website/source/_layouts/post.html.twig | 2 ++ 3 files changed, 14 insertions(+) create mode 100644 website/source/_includes/post/heading-with-anchor.html.twig create mode 100644 website/source/_includes/post/table-of-contents.html.twig diff --git a/website/source/_includes/post/heading-with-anchor.html.twig b/website/source/_includes/post/heading-with-anchor.html.twig new file mode 100644 index 00000000..46a7de25 --- /dev/null +++ b/website/source/_includes/post/heading-with-anchor.html.twig @@ -0,0 +1,3 @@ + + +

{{ text }}

diff --git a/website/source/_includes/post/table-of-contents.html.twig b/website/source/_includes/post/table-of-contents.html.twig new file mode 100644 index 00000000..65e92ba5 --- /dev/null +++ b/website/source/_includes/post/table-of-contents.html.twig @@ -0,0 +1,9 @@ +{% if toc %} + +{% endif %} diff --git a/website/source/_layouts/post.html.twig b/website/source/_layouts/post.html.twig index ac820d2b..764e0f5f 100644 --- a/website/source/_layouts/post.html.twig +++ b/website/source/_layouts/post.html.twig @@ -16,6 +16,8 @@
+ {% include "post/table-of-contents" with { toc: page.toc } only %} + {{ parent() }}