diff --git a/src/Elastic.ApiExplorer/Landing/LandingView.cshtml b/src/Elastic.ApiExplorer/Landing/LandingView.cshtml index 602060c30c..f4a74541de 100644 --- a/src/Elastic.ApiExplorer/Landing/LandingView.cshtml +++ b/src/Elastic.ApiExplorer/Landing/LandingView.cshtml @@ -9,7 +9,13 @@ var apiHxAttrs = LayoutModel.HxAttributes; }
-

@Model.ApiInfo.Title

+
+ @if (Model.IconSvg is not null) + { + @(new HtmlString(Model.IconSvg)) + } +

@Model.ApiInfo.Title

+

@Model.RenderMarkdown(Model.ApiInfo.Description)

License: @Model.ApiInfo.License?.Name

Download source: JSON YAML

diff --git a/src/Elastic.ApiExplorer/Landing/LandingViewModel.cs b/src/Elastic.ApiExplorer/Landing/LandingViewModel.cs index b95206132a..a1f136dac9 100644 --- a/src/Elastic.ApiExplorer/Landing/LandingViewModel.cs +++ b/src/Elastic.ApiExplorer/Landing/LandingViewModel.cs @@ -5,6 +5,7 @@ using Elastic.ApiExplorer.Infrastructure; using Elastic.ApiExplorer.Model; using Elastic.ApiExplorer.Operations; +using Elastic.Documentation.Site.Icons; using Microsoft.OpenApi; namespace Elastic.ApiExplorer.Landing; @@ -20,5 +21,7 @@ public class LandingViewModel(ApiRenderContext context) : ApiViewModel(context) public string JsonUrl { get; } = ApiOutputPaths.JsonUrl(context.CurrentNavigation.Url); public string YamlUrl { get; } = ApiOutputPaths.YamlUrl(context.CurrentNavigation.Url); + public string? IconSvg { get; } = ProductIcons.Get(context.Product?.Id ?? context.CurrentApiKey); + protected override string BreadcrumbCurrentTitle => ApiInfo.Title ?? CurrentNavigationItem.NavigationTitle; } diff --git a/src/Elastic.Documentation.Site/Assets/api-docs.css b/src/Elastic.Documentation.Site/Assets/api-docs.css index 7559ea2d03..5776f6f785 100644 --- a/src/Elastic.Documentation.Site/Assets/api-docs.css +++ b/src/Elastic.Documentation.Site/Assets/api-docs.css @@ -2457,7 +2457,8 @@ button.example-response-tab:focus-visible { border-bottom: 1px solid var(--color-grey-20); } -.api-catalog-header h1 { +.api-catalog-header h1, +.api-landing-heading h1 { margin: 0; font-size: var(--text-4xl); font-weight: 700; @@ -2612,3 +2613,15 @@ button.example-response-tab:focus-visible { .api-catalog-card-actions a:focus-visible { text-decoration: underline; } + +.api-landing-heading { + display: flex; + align-items: center; + column-gap: 14px; +} + +.api-landing-icon, +.api-landing-icon svg { + width: auto; + height: 40px; +} diff --git a/tests/Elastic.ApiExplorer.Tests/OpenApiGeneratorCatalogSplitTests.cs b/tests/Elastic.ApiExplorer.Tests/OpenApiGeneratorCatalogSplitTests.cs index fbf661f5e9..c41dd0bcdb 100644 --- a/tests/Elastic.ApiExplorer.Tests/OpenApiGeneratorCatalogSplitTests.cs +++ b/tests/Elastic.ApiExplorer.Tests/OpenApiGeneratorCatalogSplitTests.cs @@ -89,6 +89,33 @@ public async Task GenerateCatalog_WritesCombinedCatalogFromMultipleEntries() html.Should().NotContain("id=\"pages-nav\""); } + [Fact] + public async Task GenerateProducts_LandingHeading_ShowsSpecTitleAndProductMark() + { + var outputRoot = Path.Join(Paths.WorkingDirectoryRoot.FullName, $"api-catalog-split-{Guid.NewGuid():N}"); + var context = CreateGenerateContext(outputRoot); + using var versionIndexClient = new VersionIndexClient(BaseUri, MultiVersionHandler(), sleep: (_, _) => Task.CompletedTask); + var reader = CreateSequentialReader(SpecDocument("Elasticsearch main")); + var generator = new OpenApiGenerator( + NullLoggerFactory.Instance, + context, + NoopMarkdownStringRenderer.Instance, + versionIndexClient, + reader + ); + + _ = await generator.GenerateProducts(ctx: TestContext.Current.CancellationToken); + + var html = await context + .WriteFileSystem + .File + .ReadAllTextAsync(Path.Join(outputRoot, "api", "doc", "elasticsearch", "index.html"), TestContext.Current.CancellationToken); + html.Should().Contain("api-landing-heading"); + html.Should().Contain("

Elasticsearch main

"); + html.Should().Contain(""); + html.Should().Contain("viewBox=\"8 4.9995 47.7276 54.001\""); + } + [Fact] public async Task Generate_StillWritesProductsAndCatalog() {