From 6c9da90f7a3ad3a28460681616eb151e1e85c8f5 Mon Sep 17 00:00:00 2001 From: david-swift Date: Tue, 25 Mar 2025 14:27:51 +0100 Subject: [PATCH] Add sections to docs #3 --- content/docs/_index.md | 5 +++++ content/docs/details/index.md | 8 ++++++++ content/docs/overview/index.md | 4 +++- content/docs/page2/index.md | 2 ++ templates/partials/docs_toc.html | 19 ++++++++++++++++--- 5 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 content/docs/details/index.md diff --git a/content/docs/_index.md b/content/docs/_index.md index 1229271..a94e515 100644 --- a/content/docs/_index.md +++ b/content/docs/_index.md @@ -3,4 +3,9 @@ title = "Docs" sort_by = "weight" template = "docs.html" page_template = "documentation_page.html" + +[extra] +sections = [ + "More" +] +++ diff --git a/content/docs/details/index.md b/content/docs/details/index.md new file mode 100644 index 0000000..d983ed6 --- /dev/null +++ b/content/docs/details/index.md @@ -0,0 +1,8 @@ ++++ +weight = 2 +title = "Details" +[extra] +section = 1 ++++ + +This is overview's content! diff --git a/content/docs/overview/index.md b/content/docs/overview/index.md index f9bf481..aba104c 100644 --- a/content/docs/overview/index.md +++ b/content/docs/overview/index.md @@ -1,6 +1,8 @@ +++ -weight = 1 +weight = 0 title = "Overview" +[extra] +section = 0 +++ This is overview's content! diff --git a/content/docs/page2/index.md b/content/docs/page2/index.md index 3d67baf..f3713b0 100644 --- a/content/docs/page2/index.md +++ b/content/docs/page2/index.md @@ -1,6 +1,8 @@ +++ weight = 1 title = "Page 2" +[extra] +section = 1 +++ Another page diff --git a/templates/partials/docs_toc.html b/templates/partials/docs_toc.html index ca3d0a7..8999073 100644 --- a/templates/partials/docs_toc.html +++ b/templates/partials/docs_toc.html @@ -1,7 +1,20 @@
{%- for page in section.pages %} -
  • - {{ page.title }} -
  • + {%- if page.extra.section == 0 %} +
  • + {{ page.title }} +
  • + {%- endif %} + {%- endfor %} + {%- for page_section, pages in section.pages | group_by(attribute="extra.section") %} + {% set int_section = page_section | int %} + {%- if int_section > 0 %} +

    {{ section.extra.sections | nth(n=int_section - 1) }}

    + {%- for page in pages %} +
  • + {{ page.title }} +
  • + {%- endfor %} + {%- endif %} {%- endfor %}