77
88namespace Elastic . Markdown . IO . State ;
99
10+ public record LinkMetadata
11+ {
12+ [ JsonPropertyName ( "anchors" ) ]
13+ [ JsonIgnore ( Condition = JsonIgnoreCondition . WhenWritingNull ) ]
14+ public required string [ ] ? Anchors { get ; init ; } = [ ] ;
15+ }
16+
1017public record LinkReference
1118{
1219 [ JsonPropertyName ( "origin" ) ]
@@ -17,7 +24,7 @@ public record LinkReference
1724
1825 /// Mapping of relative filepath and all the page's anchors for deeplinks
1926 [ JsonPropertyName ( "links" ) ]
20- public required Dictionary < string , string [ ] > Links { get ; init ; } = [ ] ;
27+ public required Dictionary < string , LinkMetadata > Links { get ; init ; } = [ ] ;
2128
2229 [ JsonPropertyName ( "cross_links" ) ]
2330 public required string [ ] CrossLinks { get ; init ; } = [ ] ;
@@ -27,7 +34,11 @@ public static LinkReference Create(DocumentationSet set)
2734 var crossLinks = set . Context . Collector . CrossLinks . ToHashSet ( ) . ToArray ( ) ;
2835 var links = set . MarkdownFiles . Values
2936 . Select ( m => ( m . RelativePath , m . Anchors ) )
30- . ToDictionary ( k => k . RelativePath , v => v . Anchors . ToArray ( ) ) ;
37+ . ToDictionary ( k => k . RelativePath , v =>
38+ {
39+ var anchors = v . Anchors . Count == 0 ? null : v . Anchors . ToArray ( ) ;
40+ return new LinkMetadata { Anchors = anchors } ;
41+ } ) ;
3142 return new LinkReference
3243 {
3344 UrlPathPrefix = set . Context . UrlPathPrefix ,
0 commit comments