File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed
Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -138,9 +138,28 @@ const hitsToResult = (payload) => {
138138 } else {
139139 rdfTypes . push ( `http://id.loc.gov/ontologies/bibframe/${ types } ` )
140140 }
141+ // Extract label from JSON-LD format if needed
142+ const mainTitle = hit . data . title . mainTitle
143+ let label = mainTitle
144+
145+ // Handle array of titles
146+ if ( Array . isArray ( mainTitle ) ) {
147+ // Map each title to extract @value if it's an object, otherwise use as-is
148+ const titles = mainTitle . map ( title => {
149+ if ( title && typeof title === 'object' && '@value' in title ) {
150+ return title [ '@value' ]
151+ }
152+ return title
153+ } )
154+ // Join multiple titles with a separator
155+ label = titles . join ( ' / ' )
156+ } else if ( mainTitle && typeof mainTitle === 'object' && '@value' in mainTitle ) {
157+ // Handle single JSON-LD object
158+ label = mainTitle [ '@value' ]
159+ }
141160 results . push ( {
142161 uri : hit . uri ,
143- label : hit . data . title . mainTitle ,
162+ label : label ,
144163 created : hit . created_at ,
145164 modified : hit . updated_at ,
146165 type : rdfTypes ,
You can’t perform that action at this time.
0 commit comments