From d4d183885d5017e22ae3b3ce12dc94da1e5afad7 Mon Sep 17 00:00:00 2001 From: BurnyLlama Date: Wed, 28 Jul 2021 20:42:10 +0200 Subject: [PATCH] Working table of contents. (Not how I want to work.) --- content/components/toc.njk | 13 +++++++++++++ content/pages/wiki/index.njk | 18 ++++++++++++++++++ content/templates/article.njk | 18 ++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 content/components/toc.njk create mode 100644 content/pages/wiki/index.njk create mode 100644 content/templates/article.njk diff --git a/content/components/toc.njk b/content/components/toc.njk new file mode 100644 index 0000000..679f39b --- /dev/null +++ b/content/components/toc.njk @@ -0,0 +1,13 @@ +{% macro header(size, text, tocList) %} + {% set tocList = (tocList.push([size, text]), tocList) %} + + <{{ size }}> + {{ text }} + +{% endmacro %} + +{% macro generate(tocList) %} + {% for size, text in tocList %} + {{ text }} + {% endfor %} +{% endmacro %} \ No newline at end of file diff --git a/content/pages/wiki/index.njk b/content/pages/wiki/index.njk new file mode 100644 index 0000000..e8319a9 --- /dev/null +++ b/content/pages/wiki/index.njk @@ -0,0 +1,18 @@ +{% extends "templates/article.njk" %} +{% import "components/toc.njk" as toc with context %} + +{% block body %} + {{ super() }} + +
+ {{ toc.header("h1", "Testing", tocList) }} +

Hello World!

+ + {{ toc.header("h1", "Development", tocList) }} +

Lorem ipsum dolor sit amet consectetur adipisicing elit. Fugiat optio earum unde reiciendis cumque, corrupti ipsum quia nemo deleniti officia quos laudantium error nobis at! Praesentium, officia vero! Ut, saepe vitae maiores velit ad quis! Cum quisquam ipsam nulla laudantium rerum sint eos magni, sunt porro fuga hic nihil obcaecati iure animi impedit repellendus nisi voluptas dolore, alias tenetur fugiat? Maiores quibusdam corporis recusandae unde eaque consectetur, officia harum optio fuga architecto beatae, reprehenderit aspernatur magnam debitis consequatur. Vero recusandae obcaecati harum minus facilis illo aliquid quis! Ipsam assumenda molestiae molestias quisquam illum nesciunt. Quam dolorem fuga saepe ratione labore tenetur in laborum, quae beatae quisquam, possimus doloremque iusto eum ex odit! Suscipit iste molestias nam cupiditate distinctio veniam sint laborum, culpa odio, voluptatem fugiat exercitationem, incidunt at.

+
+ +
+ {{ toc.generate(tocList) }} +
+{% endblock %} \ No newline at end of file diff --git a/content/templates/article.njk b/content/templates/article.njk new file mode 100644 index 0000000..496133b --- /dev/null +++ b/content/templates/article.njk @@ -0,0 +1,18 @@ + + + + {% include "./defaultTags.njk" %} + {% block head %} + {{ serverName }} + {% endblock %} + + + {% set tocList = [] %} + +
+ {% block body %} + + {% endblock %} +
+ + \ No newline at end of file