|
1 | 1 | @using Elastic.Markdown.Helpers
|
2 | 2 | @using Elastic.Markdown.IO.Navigation
|
3 | 3 | @inherits RazorSlice<NavigationTreeItem>
|
4 |
| -@if (Model.IsRedesign) |
| 4 | +@foreach (var item in Model.SubTree.NavigationItems) |
5 | 5 | {
|
6 |
| - @foreach (var item in Model.SubTree.NavigationItems) |
| 6 | + if (item is FileNavigation file) |
7 | 7 | {
|
8 |
| - if (item is FileNavigation file) |
9 |
| - { |
10 |
| - var f = file.File; |
11 |
| - var isCurrent = f == Model.CurrentDocument; |
12 |
| - <li class="block ml-2 pl-2 border-l-1 border-l-gray-200 group/li @(isCurrent ? "current" : string.Empty)"> |
13 |
| - <div class="flex"> |
14 |
| - <a |
15 |
| - class="sidebar-link my-1 ml-5 group-[.current]/li:text-blue-elastic! @(isCurrent ? "" : string.Empty)" |
16 |
| - href="@f.Url" |
17 |
| - @(isCurrent ? "aria-current=page" : string.Empty)> |
18 |
| - @f.NavigationTitle |
19 |
| - </a> |
20 |
| - </div> |
21 |
| - </li> |
22 |
| - } |
23 |
| - else if (item is GroupNavigation folder) |
24 |
| - { |
25 |
| - var g = folder.Group; |
26 |
| - var isCurrent = g.Index == Model.CurrentDocument; |
27 |
| - var slug = g.Index?.Title.Slugify(); |
28 |
| - const int initialExpandLevel = 1; |
29 |
| - var containsCurrent = g.HoldsCurrent(Model.CurrentDocument) || g.ContainsCurrentPage(Model.CurrentDocument); |
30 |
| - var shouldInitiallyExpand = containsCurrent || g.Depth <= initialExpandLevel; |
31 |
| - <li class="flex flex-wrap @(g.Depth > 1 ? "ml-2 pl-2 border-l-1 border-l-gray-200" : string.Empty)"> |
32 |
| - <label for="@slug" class="peer group/label flex items-center overflow-hidden @(g.Depth == 1 ? "mt-2" : "")"> |
33 |
| - <svg |
34 |
| - xmlns="http://www.w3.org/2000/svg" |
35 |
| - fill="none" |
36 |
| - viewBox="0 0 24 24" |
37 |
| - stroke-width="1.5" |
38 |
| - stroke="currentColor" |
39 |
| - class="w-4 mr-1 shrink -rotate-90 group-has-checked/label:rotate-0 cursor-pointer text-ink"> |
40 |
| - <path stroke-linecap="round" stroke-linejoin="round" d="m19.5 8.25-7.5 7.5-7.5-7.5"/> |
41 |
| - </svg> |
42 |
| - <input |
43 |
| - id="@slug" |
44 |
| - type="checkbox" |
45 |
| - class="hidden" |
46 |
| - aria-hidden="true" |
47 |
| - data-should-expand="@((containsCurrent).ToLowerString())" |
48 |
| - @(shouldInitiallyExpand ? "checked" : string.Empty) |
49 |
| - > |
50 |
| - <a |
51 |
| - href="@g.Index?.Url" |
52 |
| - class="sidebar-link inline-block my-1 @(g.Depth == 1 ? "uppercase tracking-[0.05em] text-ink-light font-semibold" : string.Empty) @(containsCurrent ? "font-semibold" : string.Empty) @(isCurrent ? "current text-blue-elastic!" : string.Empty)"> |
53 |
| - @g.Index?.NavigationTitle |
54 |
| - </a> |
55 |
| - </label> |
56 |
| - @if (g.NavigationItems.Count > 0) |
57 |
| - { |
58 |
| - <ul class="h-0 w-full overflow-y-hidden peer-has-checked:h-auto peer-has-[:focus]:h-auto has-[:focus]:h-auto peer-has-checked:my-1" data-has-current="@g.ContainsCurrentPage(Model.CurrentDocument)"> |
59 |
| - @await RenderPartialAsync(_TocTreeNav.Create(new NavigationTreeItem |
60 |
| - { |
61 |
| - Level = g.Depth, |
62 |
| - CurrentDocument = Model.CurrentDocument, |
63 |
| - SubTree = g |
64 |
| - })) |
65 |
| - </ul> |
66 |
| - } |
67 |
| - </li> |
68 |
| - } |
| 8 | + var f = file.File; |
| 9 | + var isCurrent = f == Model.CurrentDocument; |
| 10 | + <li class="block ml-2 pl-2 border-l-1 border-l-gray-200 group/li @(isCurrent ? "current" : string.Empty)"> |
| 11 | + <div class="flex"> |
| 12 | + <a |
| 13 | + class="sidebar-link my-1 ml-5 group-[.current]/li:text-blue-elastic! @(isCurrent ? "" : string.Empty)" |
| 14 | + href="@f.Url" |
| 15 | + @(isCurrent ? "aria-current=page" : string.Empty)> |
| 16 | + @f.NavigationTitle |
| 17 | + </a> |
| 18 | + </div> |
| 19 | + </li> |
69 | 20 | }
|
70 |
| -} |
71 |
| -else |
72 |
| -{ |
73 |
| - @foreach (var item in Model.SubTree.NavigationItems) |
| 21 | + else if (item is GroupNavigation folder) |
74 | 22 | {
|
75 |
| - if (item is FileNavigation file) |
76 |
| - { |
77 |
| - var f = file.File; |
78 |
| - var current = f == Model.CurrentDocument ? " current" : string.Empty; |
79 |
| - <li class="toctree-l@(Model.SubTree.Depth + 1)@current"><a class="@(current.Trim()) reference internal" href="@f.Url">@f.NavigationTitle</a></li> |
80 |
| - } |
81 |
| - else if (item is GroupNavigation folder) |
82 |
| - { |
83 |
| - var g = folder.Group; |
84 |
| - var current = g.HoldsCurrent(Model.CurrentDocument) ? " current" : string.Empty; |
85 |
| - var currentFile = g.Index == Model.CurrentDocument ? " current" : string.Empty; |
86 |
| - <li class="toctree-l@(g.Depth)@current"><a class="reference internal@(currentFile)" href="@g.Index?.Url">@g.Index?.NavigationTitle</a>@if (@g.NavigationItems.Count > 0) {<ul class="@(current.Trim())"> |
87 |
| - @await RenderPartialAsync(_TocTreeNav.Create(new NavigationTreeItem |
88 |
| - { |
89 |
| - Level = g.Depth, |
90 |
| - CurrentDocument = Model.CurrentDocument, |
91 |
| - SubTree = g |
92 |
| - })) |
93 |
| - </ul> |
94 |
| - } |
95 |
| - </li> |
96 |
| - } |
| 23 | + var g = folder.Group; |
| 24 | + var isCurrent = g.Index == Model.CurrentDocument; |
| 25 | + var slug = g.Index?.Title.Slugify(); |
| 26 | + const int initialExpandLevel = 1; |
| 27 | + var containsCurrent = g.HoldsCurrent(Model.CurrentDocument) || g.ContainsCurrentPage(Model.CurrentDocument); |
| 28 | + var shouldInitiallyExpand = containsCurrent || g.Depth <= initialExpandLevel; |
| 29 | + <li class="flex flex-wrap @(g.Depth > 1 ? "ml-2 pl-2 border-l-1 border-l-gray-200" : string.Empty)"> |
| 30 | + <label for="@slug" class="peer group/label flex items-center overflow-hidden @(g.Depth == 1 ? "mt-2" : "")"> |
| 31 | + <svg |
| 32 | + xmlns="http://www.w3.org/2000/svg" |
| 33 | + fill="none" |
| 34 | + viewBox="0 0 24 24" |
| 35 | + stroke-width="1.5" |
| 36 | + stroke="currentColor" |
| 37 | + class="w-4 mr-1 shrink -rotate-90 group-has-checked/label:rotate-0 cursor-pointer text-ink"> |
| 38 | + <path stroke-linecap="round" stroke-linejoin="round" d="m19.5 8.25-7.5 7.5-7.5-7.5"/> |
| 39 | + </svg> |
| 40 | + <input |
| 41 | + id="@slug" |
| 42 | + type="checkbox" |
| 43 | + class="hidden" |
| 44 | + aria-hidden="true" |
| 45 | + data-should-expand="@((containsCurrent).ToLowerString())" |
| 46 | + @(shouldInitiallyExpand ? "checked" : string.Empty) |
| 47 | + > |
| 48 | + <a |
| 49 | + href="@g.Index?.Url" |
| 50 | + class="sidebar-link inline-block my-1 @(g.Depth == 1 ? "uppercase tracking-[0.05em] text-ink-light font-semibold" : string.Empty) @(containsCurrent ? "font-semibold" : string.Empty) @(isCurrent ? "current text-blue-elastic!" : string.Empty)"> |
| 51 | + @g.Index?.NavigationTitle |
| 52 | + </a> |
| 53 | + </label> |
| 54 | + @if (g.NavigationItems.Count > 0) |
| 55 | + { |
| 56 | + <ul class="h-0 w-full overflow-y-hidden peer-has-checked:h-auto peer-has-[:focus]:h-auto has-[:focus]:h-auto peer-has-checked:my-1" data-has-current="@g.ContainsCurrentPage(Model.CurrentDocument)"> |
| 57 | + @await RenderPartialAsync(_TocTreeNav.Create(new NavigationTreeItem |
| 58 | + { |
| 59 | + Level = g.Depth, |
| 60 | + CurrentDocument = Model.CurrentDocument, |
| 61 | + SubTree = g |
| 62 | + })) |
| 63 | + </ul> |
| 64 | + } |
| 65 | + </li> |
97 | 66 | }
|
98 | 67 | }
|
0 commit comments