diff --git a/website/common/models.py b/website/common/models.py
index 1d9ef92..d8068d2 100644
--- a/website/common/models.py
+++ b/website/common/models.py
@@ -2,11 +2,13 @@ from typing import Any
from django.db import models
from django.http.request import HttpRequest
-from django.utils.functional import classproperty
+from django.utils.functional import cached_property, classproperty
from wagtail.admin.panels import FieldPanel
from wagtail.images import get_image_model_string
from wagtail.models import Page
+from .utils import TocEntry, get_table_of_contents
+
class BasePage(Page):
show_in_menus_default = True
@@ -26,6 +28,10 @@ class BasePage(Page):
"""
return self.get_ancestors().reverse().exclude(depth__lte=2)
+ @cached_property
+ def table_of_contents(self) -> list[TocEntry]:
+ return get_table_of_contents()
+
class BaseContentMixin(models.Model):
subtitle = models.CharField(max_length=255, blank=True)
diff --git a/website/common/templates/common/hero.html b/website/common/templates/common/hero.html
index 06a380a..b7c9b6e 100644
--- a/website/common/templates/common/hero.html
+++ b/website/common/templates/common/hero.html
@@ -16,23 +16,28 @@
{% endif %}
-
-
-
-
-
diff --git a/website/common/templates/common/toc-item.html b/website/common/templates/common/toc-item.html
new file mode 100644
index 0000000..0389dd8
--- /dev/null
+++ b/website/common/templates/common/toc-item.html
@@ -0,0 +1,10 @@
+
+ {{ toc_item.title }}
+ {% if toc_item.children %}
+
+ {% for toc_item in toc_item.children %}
+ {% include "common/toc-item.html" %}
+ {% endfor %}
+
+ {% endif %}
+
diff --git a/website/common/utils.py b/website/common/utils.py
index 649ef31..6056c3a 100644
--- a/website/common/utils.py
+++ b/website/common/utils.py
@@ -1,4 +1,4 @@
-from typing import Type
+from typing import NamedTuple, Type
from django.conf import settings
from django.http.request import HttpRequest
@@ -6,6 +6,28 @@ from wagtail.models import Page
from wagtail.models import get_page_models as get_wagtail_page_models
+class TocEntry(NamedTuple):
+ title: str
+ slug: str
+ children: list
+
+
+def get_table_of_contents() -> list[TocEntry]:
+ return [
+ TocEntry(
+ "Title 1",
+ "title-1",
+ [
+ TocEntry("Title 1.1", "title-11", []),
+ TocEntry("Title 1.2", "title-12", []),
+ TocEntry("Title 1.3", "title-13", []),
+ ],
+ ),
+ TocEntry("Title 2", "title-2", []),
+ TocEntry("Title 3", "title-3", []),
+ ]
+
+
def get_page_models() -> list[Type[Page]]:
page_models = get_wagtail_page_models().copy()
page_models.remove(Page)