Skip to content

Commit 52448d1

Browse files
committed
Don't display version dropdowns when the page refers to a versionless product
1 parent 5465984 commit 52448d1

File tree

5 files changed

+16
-7
lines changed

5 files changed

+16
-7
lines changed

src/Elastic.Markdown/HtmlWriter.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ private async Task<RenderResult> RenderLayout(MarkdownFile markdown, MarkdownDoc
147147
LegacyPages = legacyPages?.ToArray(),
148148
VersionDropdownItems = VersionDropDownItemViewModel.FromLegacyPageMappings(legacyPages?.ToArray()),
149149
Products = pageProducts,
150+
VersioningSystem = pageVersioning,
150151
VersionsConfig = DocumentationSet.Context.VersionsConfiguration,
151152
StructuredBreadcrumbsJson = structuredBreadcrumbsJsonString
152153
});

src/Elastic.Markdown/Layout/_TableOfContents.cshtml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1+
@using Elastic.Documentation.Configuration.Versions
12
@inherits RazorSlice<Elastic.Markdown.MarkdownLayoutViewModel>
23
<aside class="sidebar md:block w-full lg:max-w-65 md:order-2 px-6 md:px-10 lg:px-0">
34
<nav id="toc-nav" class="sidebar-nav lg:h-full flex flex-row-reverse lg:block items-center gap-4">
4-
<div class="mt-6">
5-
<version-dropdown all-versions-url="@Model.AllVersionsUrl" current-version='@(Model.CurrentVersion)' items='@(new HtmlString(Model.VersionDropdownSerializedModel))'>
6-
<div class="h-8">@*height of dropdown button*@</div>
7-
</version-dropdown>
8-
</div>
5+
@if (Model.VersioningSystem.Id is not
6+
(VersioningSystemId.All or VersioningSystemId.Serverless or VersioningSystemId.Ech or VersioningSystemId.Ess))
7+
{
8+
<div class="mt-6">
9+
<version-dropdown all-versions-url="@Model.AllVersionsUrl" current-version='@(Model.CurrentVersion)' items='@(new HtmlString(Model.VersionDropdownSerializedModel))'>
10+
<div class="h-8">@*height of dropdown button*@</div>
11+
</version-dropdown>
12+
</div>
13+
}
914
<ul class="mt-6 hidden md:flex items-center lg:block gap-4">
1015
<li class="view-as-markdown hidden lg:block lg:not-first:mt-1">
1116
<a href="@Model.MarkdownUrl" class="link text-sm" target="_blank">

src/Elastic.Markdown/MarkdownLayoutViewModel.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
33
// See the LICENSE file in the project root for more information
44

5-
using Elastic.Documentation.Configuration.LegacyUrlMappings;
5+
using Elastic.Documentation.Configuration.Versions;
66
using Elastic.Documentation.Site;
77
using Elastic.Documentation.Site.Navigation;
88

@@ -23,6 +23,8 @@ public record MarkdownLayoutViewModel : GlobalLayoutViewModel
2323

2424
public required MarkdownPageLayout? Layout { get; init; }
2525

26+
public required VersioningSystem VersioningSystem { get; init; }
27+
2628
public required string? VersionDropdownSerializedModel { get; init; }
2729

2830
public required string? CurrentVersion { get; init; }

src/Elastic.Markdown/Page/Index.cshtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
Breadcrumbs = Model.Breadcrumbs,
4040
CurrentVersion = Model.CurrentDocument.YamlFrontMatter?.Layout == MarkdownPageLayout.LandingPage ? Model.VersionsConfig.VersioningSystems[0].Current : Model.CurrentVersion,
4141
AllVersionsUrl = Model.AllVersionsUrl,
42+
VersioningSystem = Model.VersioningSystem,
4243
VersionDropdownSerializedModel = JsonSerializer.Serialize(Model.VersionDropdownItems,
4344
ViewModelSerializerContext.Default.VersionDropDownItemViewModelArray),
4445
};

src/Elastic.Markdown/Page/IndexViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
using Elastic.Documentation.Site.FileProviders;
1313
using Elastic.Documentation.Site.Navigation;
1414
using Elastic.Markdown.IO;
15-
using Elastic.Markdown.IO.Navigation;
1615

1716
namespace Elastic.Markdown.Page;
1817

@@ -55,6 +54,7 @@ public class IndexViewModel
5554

5655
public required HashSet<Product> Products { get; init; }
5756

57+
public required VersioningSystem VersioningSystem { get; init; }
5858
public required VersionsConfiguration VersionsConfig { get; init; }
5959

6060
// https://developers.google.com/search/docs/appearance/structured-data/breadcrumb#json-ld

0 commit comments

Comments
 (0)