Skip to content

Commit bcaa17f

Browse files
committed
stage
1 parent 306941e commit bcaa17f

File tree

6 files changed

+21
-8
lines changed

6 files changed

+21
-8
lines changed

src/Elastic.Documentation.Navigation/Assembler/AssembledNavigation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ void IAssignableChildrenNavigation.SetNavigationItems(IReadOnlyCollection<INavig
209209
// Set the navigation index
210210
node.Parent = parent;
211211
node.NavigationIndex = index;
212-
homeAccessor.HomeProvider = new NavigationHomeProvider(pathPrefix, root);
212+
homeAccessor.HomeProvider = new NavigationHomeProvider(pathPrefix, root, true);
213213

214214
//var wrapped = new SiteTableOfContentsNavigation<IDocumentationFile>(node, homeAccessor.HomeProvider, parent, root);
215215
//parent = wrapped;

src/Elastic.Documentation.Navigation/Isolated/DocumentationSetNavigation.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ public DocumentationSetNavigation(
9696
/// </summary>
9797
public string PathPrefix => HomeProvider == this ? _pathPrefix : HomeProvider.PathPrefix;
9898

99+
bool INavigationHomeProvider.RelativeToTableOfContents => false;
100+
99101
public INavigationHomeProvider HomeProvider { get; set; }
100102

101103
public GitCheckoutInformation Git { get; }
@@ -376,7 +378,7 @@ int depth
376378
context.ReadFileSystem.Path.Combine(context.DocumentationSourceDirectory.FullName, fullTocPath)
377379
);
378380

379-
var isolatedHomeProvider = new NavigationHomeProvider(homeAccessor.HomeProvider.PathPrefix, homeAccessor.HomeProvider.NavigationRoot);
381+
var isolatedHomeProvider = new NavigationHomeProvider(homeAccessor.HomeProvider.PathPrefix, homeAccessor.HomeProvider.NavigationRoot, homeAccessor.HomeProvider.RelativeToTableOfContents);
380382

381383
// Create the TOC navigation with empty children initially
382384
// We use null parent temporarily - we'll set it properly at the end using the public setter

src/Elastic.Documentation.Navigation/Isolated/FileNavigationLeaf.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
namespace Elastic.Documentation.Navigation.Isolated;
99

1010
public record FileNavigationArgs(
11-
string RelativePath,
11+
string RelativePathToDocumentationSet,
12+
string RelativePathToTableOfContents,
1213
bool Hidden,
1314
int NavigationIndex,
1415
INodeNavigationItem<INavigationModel, INavigationItem>? Parent,
@@ -31,7 +32,7 @@ public string Url
3132
{
3233
var rootUrl = args.HomeAccessor.HomeProvider.PathPrefix.TrimEnd('/');
3334
// Remove extension while preserving the directory path
34-
var relativePath = args.RelativePath;
35+
var relativePath = args.RelativePathToDocumentationSet;
3536
var path = relativePath.EndsWith(".md", StringComparison.OrdinalIgnoreCase)
3637
? relativePath[..^3] // Remove last 3 characters (.md)
3738
: relativePath;

src/Elastic.Documentation.Navigation/Isolated/IPathPrefixProvider.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public interface INavigationHomeProvider
1010
{
1111
string PathPrefix { get; }
1212
IRootNavigationItem<INavigationModel, INavigationItem> NavigationRoot { get; }
13+
bool RelativeToTableOfContents { get; }
1314
}
1415

1516
public interface INavigationHomeAccessor
@@ -18,11 +19,17 @@ public interface INavigationHomeAccessor
1819
}
1920

2021
[DebuggerDisplay("{PathPrefix} => {NavigationRoot.Url}")]
21-
public class NavigationHomeProvider(string pathPrefix, IRootNavigationItem<INavigationModel, INavigationItem> navigationRoot) : INavigationHomeProvider
22+
public class NavigationHomeProvider(
23+
string pathPrefix,
24+
IRootNavigationItem<INavigationModel, INavigationItem> navigationRoot,
25+
bool relativeToTableOfContents
26+
) : INavigationHomeProvider
2227
{
2328
/// <inheritdoc />
2429
public string PathPrefix { get; } = pathPrefix;
2530

31+
public bool RelativeToTableOfContents { get; } = relativeToTableOfContents;
32+
2633
/// <inheritdoc />
2734
public IRootNavigationItem<INavigationModel, INavigationItem> NavigationRoot { get; } = navigationRoot;
2835

src/Elastic.Documentation.Navigation/Isolated/TableOfContentsNavigation.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ INavigationHomeProvider homeProvider
6060
/// </summary>
6161
public string PathPrefix { get; }
6262

63+
bool INavigationHomeProvider.RelativeToTableOfContents => false;
64+
6365
/// <inheritdoc />
6466
public string Url => Index.Url;
6567

src/Elastic.Documentation.Navigation/Isolated/VirtualFileNavigation.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
namespace Elastic.Documentation.Navigation.Isolated;
1010

1111
public record VirtualFileNavigationArgs(
12-
string RelativePath,
12+
string RelativePathToDocumentationSet,
13+
string RelativePathToTableOfContents,
1314
bool Hidden,
1415
int NavigationIndex,
1516
int Depth,
@@ -48,11 +49,11 @@ public class VirtualFileNavigation<TModel>(TModel model, IFileInfo fileInfo, Vir
4849
public int Depth { get; init; } = args.Depth;
4950

5051
/// <inheritdoc />
51-
public string Id { get; } = ShortId.Create(args.RelativePath);
52+
public string Id { get; } = ShortId.Create(args.RelativePathToDocumentationSet);
5253

5354
/// <inheritdoc />
5455
public ILeafNavigationItem<TModel> Index { get; } =
55-
new FileNavigationLeaf<TModel>(model, fileInfo, new FileNavigationArgs(args.RelativePath, args.Hidden, args.NavigationIndex, args.Parent, args.HomeAccessor));
56+
new FileNavigationLeaf<TModel>(model, fileInfo, new FileNavigationArgs(args.RelativePathToDocumentationSet, args.RelativePathToDocumentationSet, args.Hidden, args.NavigationIndex, args.Parent, args.HomeAccessor));
5657

5758
public IReadOnlyCollection<INavigationItem> NavigationItems { get; private set; } = [];
5859

0 commit comments

Comments
 (0)