|
4 | 4 |
|
5 | 5 | using System.IO.Abstractions; |
6 | 6 | using System.Text.RegularExpressions; |
7 | | -using Elastic.Codex.Category; |
| 7 | +using Elastic.Codex.Group; |
8 | 8 | using Elastic.Codex.Landing; |
9 | 9 | using Elastic.Codex.Navigation; |
10 | 10 | using Elastic.Documentation.Configuration; |
@@ -63,14 +63,9 @@ public async Task Generate(CodexNavigation codexNavigation, Cancel ctx = default |
63 | 63 | // Render the codex landing page |
64 | 64 | await RenderLandingPage(codexNavigation, renderContext, navigationRenderer, ctx); |
65 | 65 |
|
66 | | - // Render category pages |
67 | | - foreach (var item in codexNavigation.NavigationItems) |
68 | | - { |
69 | | - if (item is CategoryNavigation category) |
70 | | - { |
71 | | - await RenderCategoryPage(category, renderContext, navigationRenderer, ctx); |
72 | | - } |
73 | | - } |
| 66 | + // Render group landing pages (/g/slug) |
| 67 | + foreach (var groupNav in codexNavigation.GroupNavigations) |
| 68 | + await RenderGroupLandingPage(groupNav, renderContext, navigationRenderer, ctx); |
74 | 69 | } |
75 | 70 |
|
76 | 71 | private async Task ExtractEmbeddedStaticResources(Cancel ctx) |
@@ -138,42 +133,40 @@ private async Task RenderLandingPage( |
138 | 133 |
|
139 | 134 | await using var stream = _writeFileSystem.FileStream.New(outputFile.FullName, FileMode.Create); |
140 | 135 | await slice.RenderAsync(stream, cancellationToken: ctx); |
141 | | - |
142 | | - |
143 | 136 | _logger.LogDebug("Generated codex landing page: {Path}", outputFile.FullName); |
144 | 137 | } |
145 | 138 |
|
146 | | - private async Task RenderCategoryPage( |
147 | | - CategoryNavigation category, |
| 139 | + private async Task RenderGroupLandingPage( |
| 140 | + GroupNavigation groupNav, |
148 | 141 | CodexRenderContext renderContext, |
149 | 142 | CodexNavigationHtmlWriter navigationRenderer, |
150 | 143 | CancellationToken ctx) |
151 | 144 | { |
152 | 145 | var navigationRenderResult = await navigationRenderer.RenderNavigation( |
153 | | - category.NavigationRoot, |
154 | | - category.Index, |
| 146 | + groupNav, |
| 147 | + groupNav.Index, |
155 | 148 | ctx); |
156 | 149 |
|
157 | 150 | renderContext = renderContext with |
158 | 151 | { |
159 | | - CurrentNavigation = category.Index, |
| 152 | + CurrentNavigation = groupNav.Index, |
160 | 153 | NavigationHtml = navigationRenderResult.Html |
161 | 154 | }; |
162 | 155 |
|
163 | | - var viewModel = new CategoryViewModel(renderContext) |
| 156 | + var viewModel = new GroupLandingViewModel(renderContext) |
164 | 157 | { |
165 | | - Category = category |
| 158 | + Group = groupNav |
166 | 159 | }; |
167 | 160 |
|
168 | | - var outputFile = GetOutputFile(category.Url); |
| 161 | + var outputFile = GetOutputFile(groupNav.Url); |
169 | 162 | if (!outputFile.Directory!.Exists) |
170 | 163 | outputFile.Directory.Create(); |
171 | 164 |
|
172 | 165 | await using var stream = _writeFileSystem.FileStream.New(outputFile.FullName, FileMode.Create); |
173 | | - var slice = CategoryView.Create(viewModel); |
| 166 | + var slice = GroupLandingView.Create(viewModel); |
174 | 167 | await slice.RenderAsync(stream, cancellationToken: ctx); |
175 | 168 |
|
176 | | - _logger.LogDebug("Generated category page: {Path}", outputFile.FullName); |
| 169 | + _logger.LogDebug("Generated group landing page: {Path}", outputFile.FullName); |
177 | 170 | } |
178 | 171 |
|
179 | 172 | private IFileInfo GetOutputFile(string url) |
|
0 commit comments