Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/Elastic.ApiExplorer/Landing/LandingView.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@
var apiHxAttrs = LayoutModel.HxAttributes;
}
<section id="elastic-docs-v3">
<h1>@Model.ApiInfo.Title</h1>
<div class="api-landing-heading">
@if (Model.IconSvg is not null)
{
<span class="api-landing-icon">@(new HtmlString(Model.IconSvg))</span>
}
<h1>@Model.ApiInfo.Title</h1>
</div>
<p>@Model.RenderMarkdown(Model.ApiInfo.Description)</p>
<p>License: @Model.ApiInfo.License?.Name</p>
<p>Download source: <a href="@Model.JsonUrl" download>JSON</a> <a href="@Model.YamlUrl" download>YAML</a></p>
Expand Down
3 changes: 3 additions & 0 deletions src/Elastic.ApiExplorer/Landing/LandingViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
15 changes: 14 additions & 1 deletion src/Elastic.Documentation.Site/Assets/api-docs.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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("<h1>Elasticsearch main</h1>");
html.Should().Contain("<span class=\"api-landing-icon\">");
html.Should().Contain("viewBox=\"8 4.9995 47.7276 54.001\"");
}

[Fact]
public async Task Generate_StillWritesProductsAndCatalog()
{
Expand Down
Loading