@@ -109,7 +109,7 @@ const CustomHit = ({ hit, routing, that, sortItems, recent, storage, advanced /*
109
109
const hidden_if_no_match_and_not_locale_en = [ "summary" ]
110
110
111
111
if ( hit ) {
112
- for ( const name of [ "prefLabel" , "altLabel" , /* "authorName",*/ "publisherName" , "publisherLocation" , "summary" , "authorshipStatement" , "comment" , "seriesName" ] ) {
112
+ for ( const name of [ "prefLabel" , "altLabel" , "authorName" , "publisherName" , "publisherLocation" , "summary" , "authorshipStatement" , "comment" , "seriesName" ] ) {
113
113
if ( ! labels [ name ] ) labels [ name ] = [ ]
114
114
for ( const k of Object . keys ( hit ) ) {
115
115
if ( k . startsWith ( name ) && ! k . endsWith ( "_res" ) ) {
@@ -143,7 +143,7 @@ const CustomHit = ({ hit, routing, that, sortItems, recent, storage, advanced /*
143
143
}
144
144
const idx = withHL . indexOf ( untagged )
145
145
let start = "" , end = ""
146
- console . log ( "wHL:" , hit . objectID , k , c , h , idx , num )
146
+ // console.log("wHL:",hit.objectID,k,c,h,idx,num)
147
147
if ( idx >= 0 && num === i ) {
148
148
start = withHL . substring ( 0 , idx )
149
149
if ( idx + untagged . length <= withHL . length ) end = withHL . substring ( idx + untagged . length )
@@ -220,7 +220,7 @@ const CustomHit = ({ hit, routing, that, sortItems, recent, storage, advanced /*
220
220
const newShow = { }
221
221
out = [ ]
222
222
let tag = "note"
223
- for ( const name of [ "seriesName" , "summary" , "comment" , "authorshipStatement" /* , "authorName"*/ ] ) {
223
+ for ( const name of [ "seriesName" , "summary" , "comment" , "authorshipStatement" , "authorName" ] ) {
224
224
if ( labels [ name ] ?. length ) {
225
225
const byLang = labels [ name ] . reduce ( ( acc , l ) => ( {
226
226
...acc ,
@@ -229,9 +229,13 @@ const CustomHit = ({ hit, routing, that, sortItems, recent, storage, advanced /*
229
229
230
230
//console.log("byL:", byLang, labels[name])
231
231
232
- const hasMatchInLang = Object . values ( byLang ) . some ( b => b . includes ( "↦" ) )
232
+ if ( name === "authorName" ) {
233
+ const matchingAuthorNames = labels [ name ] . filter ( n => n . value ?. includes ( "↦" ) ) . map ( n => ( sortLangScriptLabels ( [ { value :n . value , lang :n . lang } ] , langs . flat , langs . translit ) ?? [ ] ) [ 0 ] ) . map ( n => ( { ...n , k :n . value . replace ( / [ ↦ ↤ ] / g, "" ) . replace ( / ( ^ + ) | ( + $ ) / g, "" ) } ) )
234
+ setAuthorName ( matchingAuthorNames )
235
+ continue ;
236
+ }
233
237
234
- const sortLabels = sortLangScriptLabels ( Object . keys ( byLang ) . filter ( k => ! hasMatchInLang || byLang [ k ] ?. includes ( "↦" ) ) . map ( k => ( { lang :k , value :byLang [ k ] } ) ) , langs . flat , langs . translit )
238
+ const sortLabels = sortLangScriptLabels ( Object . keys ( byLang ) . map ( k => ( { lang :k , value :byLang [ k ] } ) ) , langs . flat , langs . translit )
235
239
236
240
if ( hidden_if_no_match_and_not_locale_en . includes ( name ) && sortLabels . length && ! sortLabels [ 0 ] . value ?. includes ( "↦" ) && ( ! sortLabels [ 0 ] . lang . startsWith ( "en" ) || that . props . locale != "en" ) ) continue ;
237
241
@@ -275,9 +279,9 @@ const CustomHit = ({ hit, routing, that, sortItems, recent, storage, advanced /*
275
279
} else if ( name === "authorshipStatement" ) {
276
280
setAuthorshipStatement ( out )
277
281
out = [ ]
278
- tag = "authorName"
279
- } else if ( name === "authorName" ) {
280
- setAuthorName ( out )
282
+ // tag = "authorName"
283
+ // } else if(name === "authorName") {
284
+ // setAuthorName(out)
281
285
} else if ( name === "seriesName" ) {
282
286
if ( out . length ) setSeriesName ( out )
283
287
out = [ ]
@@ -441,6 +445,20 @@ const CustomHit = ({ hit, routing, that, sortItems, recent, storage, advanced /*
441
445
if ( top ) top . scrollIntoView ( )
442
446
}
443
447
448
+ const memoAuthors = useMemo ( ( ) => (
449
+ ( hit . author ?? [ ] ) //.concat(hit.translator ?? [])
450
+ . map ( a => {
451
+ const label = getPropLabel ( that , fullUri ( "bdr:" + a ) , true , true , "" , 1 , storage , true , authorName ) ?? a
452
+
453
+ return ( < span data-id = { a } >
454
+ { /* <Link to={"/show/bdr:"+a+backLink}> */ }
455
+ { label }
456
+ { /* </Link> */ }
457
+ </ span > )
458
+ }
459
+ )
460
+ ) , [ hit . author , storage , authorName ] )
461
+
444
462
return ( < div class = { "result " + hit . type } >
445
463
< div class = "main" >
446
464
< Link to = { link } className = "BG-link" onClick = { scrollToTop } > </ Link >
@@ -538,19 +556,7 @@ const CustomHit = ({ hit, routing, that, sortItems, recent, storage, advanced /*
538
556
< span class = "label" > { I18n . t ( "result.workBy" ) } < span class = "colon" > :</ span > </ span >
539
557
< span >
540
558
< span className = "author-links" >
541
- { false && authorName ?
542
- < span > { authorName } </ span >
543
- : ( hit . author ?? [ ] ) //.concat(hit.translator ?? [])
544
- . map ( a => {
545
- return ( < span data-id = { a } >
546
- { /* <Link to={"/show/bdr:"+a+backLink}> */ }
547
- {
548
- getPropLabel ( that , fullUri ( "bdr:" + a ) , true , true , "" , 1 , storage , true ) ?? a
549
- }
550
- { /* </Link> */ }
551
- </ span > )
552
- }
553
- ) }
559
+ { memoAuthors }
554
560
</ span >
555
561
{ authorshipStatement . length > 0 && < span className = "authorship" >
556
562
{ authorshipStatement }
@@ -559,7 +565,18 @@ const CustomHit = ({ hit, routing, that, sortItems, recent, storage, advanced /*
559
565
</ span >
560
566
</ span >
561
567
}
562
-
568
+
569
+ { /* // debug
570
+ authorName && <span class="names author noNL">
571
+ <span class="label">{I18n.t("result.workBy")}<span class="colon">:</span></span>
572
+ <span>
573
+ <span className="author-links">
574
+ { authorName && <span>{JSON.stringify(authorName)}</span> }
575
+ </span>
576
+ </span>
577
+ </span>
578
+ */ }
579
+
563
580
{
564
581
isMetaMatch && nbEtextHits > 0 && < span class = "names" >
565
582
< span class = "label" > { I18n . t ( "result.nHitET" , { count : nbEtextHits } ) } < span class = "colon" > :</ span > </ span >
0 commit comments