File tree Expand file tree Collapse file tree 4 files changed +18
-3
lines changed Expand file tree Collapse file tree 4 files changed +18
-3
lines changed Original file line number Diff line number Diff line change 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 . Security . Cryptography ;
6+ using System . Text ;
7+
8+ namespace Elastic . Markdown . Helpers ;
9+
10+ public static class ShortId
11+ {
12+ public static string Create ( params string [ ] text ) => Convert . ToHexString ( SHA256 . HashData ( Encoding . UTF8 . GetBytes ( string . Join ( "" , text ) ) ) ) [ ..8 ] ;
13+ }
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ DocumentationSet set
5353 _configurationFile = build . Configuration . SourceFile ;
5454 _globalSubstitutions = build . Configuration . Substitutions ;
5555 _set = set ;
56- Id = Convert . ToHexString ( SHA256 . HashData ( Encoding . UTF8 . GetBytes ( FilePath ) ) ) [ .. 8 ] ;
56+ Id = ShortId . Create ( FilePath ) ;
5757 //may be updated by DocumentationGroup.ProcessTocItems
5858 //todo refactor mutability of MarkdownFile as a whole
5959 ScopeDirectory = build . Configuration . ScopeDirectory ;
Original file line number Diff line number Diff line change 88using System . Text ;
99using Elastic . Documentation ;
1010using Elastic . Documentation . Configuration . TableOfContents ;
11+ using Elastic . Markdown . Helpers ;
1112
1213namespace Elastic . Markdown . IO . Navigation ;
1314
@@ -198,7 +199,7 @@ protected DocumentationGroup(
198199 GroupsInOrder = groups ;
199200 FilesInOrder = files ;
200201 NavigationItems = navigationItems ;
201- Id = Convert . ToHexString ( SHA256 . HashData ( Encoding . UTF8 . GetBytes ( NavigationSource + FolderName + depth ) ) ) [ .. 8 ] ;
202+ Id = ShortId . Create ( NavigationSource . ToString ( ) , FolderName ) ;
202203 if ( Index is not null )
203204 FilesInOrder = [ .. FilesInOrder . Except ( [ Index ] ) ] ;
204205 }
Original file line number Diff line number Diff line change 44
55using System . Security . Cryptography ;
66using System . Text ;
7+ using Elastic . Markdown . Helpers ;
78using Elastic . Markdown . Myst . Settings ;
89
910namespace Elastic . Markdown . Slices . Directives ;
@@ -64,7 +65,7 @@ public class ImageViewModel
6465 public string UniqueImageId =>
6566 _uniqueImageId ??= string . IsNullOrEmpty ( ImageUrl )
6667 ? Guid . NewGuid ( ) . ToString ( "N" ) [ ..8 ] // fallback to a random ID if ImageUrl is null or empty
67- : Convert . ToHexString ( SHA256 . HashData ( Encoding . UTF8 . GetBytes ( ImageUrl ) ) ) [ .. 8 ] ;
68+ : ShortId . Create ( ImageUrl ) ;
6869 public required string ? Screenshot { get ; init ; }
6970
7071 public string Style
You can’t perform that action at this time.
0 commit comments