Skip to content

Commit 0168f8e

Browse files
khos2owbep
authored andcommitted
Fix TOC rendering issues
While rendering TOC, some items were lost. For example: - if last h1 has some children or grand children - if any h1 has multiple h2 (without any h3) Signed-off-by: Khosrow Moossavi <[email protected]>
1 parent 7210745 commit 0168f8e

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

exampleSite/content/errors.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ title: Errors
1010

1111
The Kittn API uses the following error codes:
1212

13+
## 4xx
1314

1415
Error Code | Meaning
1516
---------- | -------
@@ -22,5 +23,10 @@ Error Code | Meaning
2223
410 | Gone -- The kitten requested has been removed from our servers
2324
418 | I'm a teapot
2425
429 | Too Many Requests -- You're requesting too many kittens! Slow down!
26+
27+
## 5xx
28+
29+
Error Code | Meaning
30+
---------- | -------
2531
500 | Internal Server Error -- We had a problem with our server. Try again later.
2632
503 | Service Unavailable -- We're temporarially offline for maintanance. Please try again later.

layouts/partials/funcs/toc_from_pages.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@
4040
{{ $h2s = $h2s | append $tocItem }}
4141
{{ $h3s = slice }}
4242
{{ end }}
43+
{{ if eq $previousLevel 2 }}
44+
{{ $h2s = $h2s | append $previousH2 }}
45+
{{ end }}
4346
{{ $previousH2 = $item }}
4447
{{ else }}
4548
{{ $h3s = $h3s | append $item }}
@@ -50,6 +53,9 @@
5053
{{ end }}
5154

5255
{{ if ne $previousLevel 0 }}
56+
{{ $tocItem := merge $previousH2 (dict "sub" $h3s) }}
57+
{{ $h2s = $h2s | append $tocItem }}
58+
5359
{{ $item := merge $previousH1 (dict "sub" $h2s) }}
5460
{{ $toc = $toc | append $item }}
5561
{{ end }}

0 commit comments

Comments
 (0)