Skip to content

Commit

Permalink
Fix result breadcrumb
Browse files Browse the repository at this point in the history
Fix for issue #373500. Display simple breadcrumb in green following the latest indexing fix, using the format [hostname] > [1st element of breadcrumb]. Default to printableuri if not available.
  • Loading branch information
bblaisATcoveo committed Dec 3, 2024
1 parent 960a66c commit b3166bc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/connector.js
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ function initEngine() {

resultListController = buildResultList( headlessEngine, {
options: {
fieldsToInclude: [ "author", "date", "language", "urihash", "objecttype", "collection", "source", "permanentid", "displaynavlabel" ]
fieldsToInclude: [ "author", "date", "language", "urihash", "objecttype", "collection", "source", "permanentid", "displaynavlabel", "hostname" ]
}
} );
querySummaryController = buildQuerySummary( headlessEngine );
Expand Down Expand Up @@ -872,6 +872,11 @@ function updateResultListState( newState ) {

author = author.replaceAll( ';' , '</li> <li>' );
}

let breadcrumb = "";
if ( result.raw.hostname && result.raw.displaynavlabel ) {
const splittedNavLabel = ( Array.isArray( result.raw.displaynavlabel ) ? result.raw.displaynavlabel[0] : result.raw.displaynavlabel).split( '>' );
breadcrumb = result.raw.hostname + '&nbsp;</li><li>' + splittedNavLabel[splittedNavLabel.length-1];
}

sectionNode.innerHTML = resultTemplateHTML
Expand All @@ -880,7 +885,7 @@ function updateResultListState( newState ) {
.replace( '%[result.clickUri]', filterProtocol( result.clickUri ) )
.replace( '%[result.title]', result.title )
.replace( '%[result.raw.author]', author )
.replace( '%[result.breadcrumb]', result.raw.displaynavlabel ? result.raw.displaynavlabel : result.printableUri )
.replace( '%[result.breadcrumb]', breadcrumb ? breadcrumb : result.printableUri )
.replace( '%[result.printableUri]', result.printableUri.replaceAll( '&' , '&amp;' ) )
.replace( '%[short-date-en]', getShortDateFormat( resultDate ) )
.replace( '%[short-date-fr]', getShortDateFormat( resultDate ) )
Expand Down

0 comments on commit b3166bc

Please sign in to comment.