Skip to content

Commit 7976a7a

Browse files
authored
Merge branch 'main' into theletterf-patch-1
2 parents 73d48c6 + a280475 commit 7976a7a

File tree

20 files changed

+1382
-485
lines changed

20 files changed

+1382
-485
lines changed

.github/actions/bootstrap/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ runs:
2424
run: |
2525
git config --global init.defaultBranch main
2626
27-
- uses: actions/setup-dotnet@v4
27+
- uses: actions/setup-dotnet@v5
2828
with:
2929
global-json-file: global.json
3030

Directory.Packages.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
<PackageVersion Include="Sep" Version="0.11.0" />
6161
<PackageVersion Include="Slugify.Core" Version="4.0.1" />
6262
<PackageVersion Include="SoftCircuits.IniFileParser" Version="2.7.0" />
63-
<PackageVersion Include="System.IO.Abstractions" Version="22.0.15" />
63+
<PackageVersion Include="System.IO.Abstractions" Version="22.0.16" />
6464
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="9.0.4" />
6565
<PackageVersion Include="Utf8StreamReader" Version="1.3.2" />
6666
<PackageVersion Include="Vecc.YamlDotNet.Analyzers.StaticGenerator" Version="16.1.3" PrivateAssets="All" />
@@ -87,7 +87,7 @@
8787
<PackageVersion Include="GitHubActionsTestLogger" Version="2.4.1" />
8888
<PackageVersion Include="JetBrains.Annotations" Version="2024.3.0" />
8989
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
90-
<PackageVersion Include="System.IO.Abstractions.TestingHelpers" Version="22.0.15" />
90+
<PackageVersion Include="System.IO.Abstractions.TestingHelpers" Version="22.0.16" />
9191
<PackageVersion Include="Unquote" Version="7.0.1" />
9292
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.0">
9393
<PrivateAssets>all</PrivateAssets>

src/Elastic.Documentation.Configuration/Elastic.Documentation.Configuration.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
</ItemGroup>
1919

2020
<ItemGroup>
21+
<PackageReference Include="System.IO.Abstractions" />
2122
<EmbeddedResource Include="$(SolutionRoot)\config\versions.yml" />
2223
<EmbeddedResource Include="$(SolutionRoot)\config\assembler.yml" />
2324
<EmbeddedResource Include="$(SolutionRoot)\config\navigation.yml" />

src/Elastic.Documentation.Site/package-lock.json

Lines changed: 83 additions & 82 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Elastic.Documentation.Site/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"@types/testing-library__jest-dom": "6.0.0",
5050
"babel-jest": "30.1.2",
5151
"eslint": "9.35.0",
52-
"globals": "16.3.0",
52+
"globals": "16.4.0",
5353
"identity-obj-proxy": "3.0.0",
5454
"jest": "30.1.3",
5555
"jest-environment-jsdom": "30.1.2",
@@ -63,19 +63,19 @@
6363
"react": "18.3.1",
6464
"react-dom": "18.3.1",
6565
"text-diff": "1.0.1",
66-
"typescript-eslint": "8.42.0"
66+
"typescript-eslint": "8.43.0"
6767
},
6868
"browserslist": [
6969
"defaults"
7070
],
7171
"dependencies": {
72-
"@elastic/eui": "106.4.0",
72+
"@elastic/eui": "106.6.0",
7373
"@elastic/highlightjs-esql": "1.2.0",
7474
"@emotion/css": "11.13.5",
7575
"@emotion/react": "11.14.0",
7676
"@microsoft/fetch-event-source": "2.0.1",
7777
"@r2wc/react-to-web-component": "2.0.4",
78-
"@tanstack/react-query": "^5.85.6",
78+
"@tanstack/react-query": "^5.87.4",
7979
"@uidotdev/usehooks": "2.4.1",
8080
"clipboard": "2.0.11",
8181
"highlight.js": "11.11.1",
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Licensed to Elasticsearch B.V under one or more agreements.
2+
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
// See the LICENSE file in the project root for more information
4+
5+
using System.Text.Json.Serialization;
6+
7+
namespace Elastic.Markdown;
8+
9+
// Model structure based on https://developers.google.com/search/docs/appearance/structured-data/breadcrumb#json-ld
10+
public record BreadcrumbsList
11+
{
12+
[JsonPropertyName("@context")]
13+
public string Context => "https://schema.org";
14+
[JsonPropertyName("@type")]
15+
public string Type => "BreadcrumbList";
16+
[JsonPropertyName("itemListElement")]
17+
public required List<BreadcrumbListItem> ItemListElement { get; init; }
18+
}
19+
20+
public record BreadcrumbListItem
21+
{
22+
[JsonPropertyName("@type")]
23+
public string Type => "ListItem";
24+
[JsonPropertyName("position")]
25+
public required int Position { get; init; }
26+
[JsonPropertyName("name")]
27+
public required string Name { get; init; }
28+
29+
[JsonPropertyName("item")]
30+
public string? Item { get; init; }
31+
}
32+
33+
[JsonSourceGenerationOptions(WriteIndented = true, PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)]
34+
[JsonSerializable(typeof(BreadcrumbsList))]
35+
public sealed partial class BreadcrumbsContext : JsonSerializerContext;

src/Elastic.Markdown/HtmlWriter.cs

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// See the LICENSE file in the project root for more information
44

55
using System.IO.Abstractions;
6+
using System.Text.Json;
67
using Elastic.Documentation;
78
using Elastic.Documentation.Configuration.Builder;
89
using Elastic.Documentation.Legacy;
@@ -113,6 +114,11 @@ private async Task<RenderResult> RenderLayout(MarkdownFile markdown, MarkdownDoc
113114
fullNavigationRenderResult
114115
);
115116

117+
//TODO should we even distinctby
118+
var breadcrumbs = parents.Reverse().DistinctBy(p => p.Url).ToArray();
119+
var breadcrumbsList = CreateStructuredBreadcrumbsData(markdown, breadcrumbs);
120+
var structuredBreadcrumbsJsonString = JsonSerializer.Serialize(breadcrumbsList, BreadcrumbsContext.Default.BreadcrumbsList);
121+
116122

117123
var slice = Page.Index.Create(new IndexViewModel
118124
{
@@ -124,12 +130,11 @@ private async Task<RenderResult> RenderLayout(MarkdownFile markdown, MarkdownDoc
124130
TitleRaw = markdown.TitleRaw ?? "[TITLE NOT SET]",
125131
MarkdownHtml = html,
126132
PageTocItems = [.. markdown.PageTableOfContent.Values],
127-
Tree = DocumentationSet.Tree,
128133
CurrentDocument = markdown,
129134
CurrentNavigationItem = current,
130135
PreviousDocument = previous,
131136
NextDocument = next,
132-
Parents = parents,
137+
Breadcrumbs = breadcrumbs,
133138
NavigationHtml = navigationHtmlRenderResult.Html,
134139
NavigationFileName = navigationFileName,
135140
UrlPathPrefix = markdown.UrlPathPrefix,
@@ -147,7 +152,8 @@ private async Task<RenderResult> RenderLayout(MarkdownFile markdown, MarkdownDoc
147152
LegacyPages = legacyPages?.Skip(1).ToArray(),
148153
VersionDropdownItems = VersionDrownDownItemViewModel.FromLegacyPageMappings(legacyPages?.Skip(1).ToArray()),
149154
Products = allProducts,
150-
VersionsConfig = DocumentationSet.Context.VersionsConfiguration
155+
VersionsConfig = DocumentationSet.Context.VersionsConfiguration,
156+
StructuredBreadcrumbsJson = structuredBreadcrumbsJsonString
151157
});
152158

153159
return new RenderResult
@@ -159,6 +165,31 @@ private async Task<RenderResult> RenderLayout(MarkdownFile markdown, MarkdownDoc
159165

160166
}
161167

168+
private BreadcrumbsList CreateStructuredBreadcrumbsData(MarkdownFile markdown, INavigationItem[] crumbs)
169+
{
170+
List<BreadcrumbListItem> breadcrumbItems = [];
171+
var position = 1;
172+
// Add parents
173+
breadcrumbItems.AddRange(crumbs.Select(parent => new BreadcrumbListItem
174+
{
175+
Position = position++,
176+
Name = parent.NavigationTitle,
177+
Item = new Uri(DocumentationSet.Context.CanonicalBaseUrl ?? new Uri("http://localhost"), Path.Combine(DocumentationSet.Context.UrlPathPrefix ?? string.Empty, parent.Url)).ToString()
178+
}));
179+
// Add current page
180+
breadcrumbItems.Add(new BreadcrumbListItem
181+
{
182+
Position = position,
183+
Name = markdown.Title ?? markdown.NavigationTitle,
184+
Item = null,
185+
});
186+
var breadcrumbsList = new BreadcrumbsList
187+
{
188+
ItemListElement = breadcrumbItems
189+
};
190+
return breadcrumbsList;
191+
}
192+
162193
public async Task<MarkdownDocument> WriteAsync(IDirectoryInfo outBaseDir, IFileInfo outputFile, MarkdownFile markdown, IConversionCollector? collector, Cancel ctx = default)
163194
{
164195
if (outputFile.Directory is { Exists: false })
@@ -203,5 +234,4 @@ public record RenderResult
203234
public required string Html { get; init; }
204235
public required string FullNavigationPartialHtml { get; init; }
205236
public required string NavigationFileName { get; init; }
206-
207237
}

src/Elastic.Markdown/Layout/_Breadcrumbs.cshtml

Lines changed: 12 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,54 +2,27 @@
22
@{
33
var targets =
44
Model.Features.PrimaryNavEnabled
5-
? Model.Parents.Reverse()
6-
: Model.Parents.Reverse().Skip(1);
7-
8-
//TODO should we even distinctby
9-
var parents = targets.DistinctBy(p => p.Url).ToList();
10-
var firstCrumb = parents.FirstOrDefault();
11-
var crumbs = parents.Skip(1).TakeLast(2).ToList();
5+
? Model.Breadcrumbs
6+
: Model.Breadcrumbs.Skip(1);
7+
var crumbs = targets.ToList();
128
}
139

14-
<ol id="breadcrumbs" class="block items-center w-full py-6" itemscope="" itemtype="https://schema.org/BreadcrumbList">
15-
@if (firstCrumb != null)
16-
{
17-
<li class="inline text-ink-light text-sm leading-[1.2em]" itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem">
18-
<a
19-
hx-disable="true"
20-
itemprop="item"
21-
href="@firstCrumb.Url"
22-
@Htmx.GetHxAttributes( Model.CurrentNavigationItem?.NavigationRoot.Id == firstCrumb.NavigationRoot.Id)
23-
>
24-
<span itemprop="name" class="hover:text-black">@firstCrumb.NavigationTitle</span>
25-
</a>
26-
<meta itemprop="position" content="1">
27-
</li>
28-
}
29-
@if (crumbs.Count > 0 && parents.Count > 3)
30-
{
31-
<li class="inline text-ink-light text-sm leading-[1.2em]" itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem">
32-
<span class="px-1">/</span>
33-
34-
</li>
35-
}
36-
10+
<ol id="breadcrumbs" class="flex flex-wrap gap-1 items-center w-full py-6">
3711
@for (var i = 0; i < crumbs.Count; i++)
3812
{
39-
var item = crumbs[i];
40-
<li class="inline text-ink-light text-sm leading-[1.2em]" itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem">
41-
<span class="px-1">/</span>
13+
var item = crumbs[i];
14+
<li class="text-ink-light text-sm leading-[1.2em]">
4215
<a
43-
itemprop="item"
16+
itemprop="item"
4417
href="@item.Url"
4518
@Htmx.GetHxAttributes(Model.CurrentNavigationItem?.NavigationRoot.Id == item.NavigationRoot.Id)
4619
>
47-
<span itemprop="name" class="hover:text-black">@item.NavigationTitle</span>
20+
<span class="hover:text-black">@item.NavigationTitle</span>
4821
</a>
49-
<meta itemprop="position" content="@(i+2)">
22+
@if (i < crumbs.Count - 1)
23+
{
24+
<span class="px-1">/</span>
25+
}
5026
</li>
5127
}
52-
<li class="inline text-ink-light text-sm leading-[1.2em]" itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem">
53-
<span class="px-1">/</span>
54-
</li>
5528
</ol>

src/Elastic.Markdown/Layout/_LandingPage.cshtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@
4343

4444
<section class="w-full px-8 lg:px-6 bg-grey-10">
4545
<div class="container mx-auto py-10">
46-
<div class="heading-wrapper" id="elastic-products">
46+
<div class="heading-wrapper" id="solutions-use-cases">
4747
<h2 class="font-bold font-sans text-3xl text-ink-dark">
48-
<a href="#elastic-products">Elastic products</a>
48+
<a href="#solutions-use-cases">Solutions and use cases</a>
4949
</h2>
5050
</div>
5151
<div class="grid md:grid-cols-2 lg:grid-cols-3 gap-6 mt-6">

src/Elastic.Markdown/MarkdownLayoutViewModel.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ public record MarkdownLayoutViewModel : GlobalLayoutViewModel
1717
public required bool HideEditThisPage { get; init; }
1818
public required string? ReportIssueUrl { get; init; }
1919

20-
public required INavigationItem[] Parents { get; init; }
21-
22-
public required LegacyPageMapping[]? LegacyPages { get; init; }
20+
public required INavigationItem[] Breadcrumbs { get; init; }
2321

2422
public required IReadOnlyCollection<PageTocItem> PageTocItems { get; init; }
2523

0 commit comments

Comments
 (0)