resultLanding: update jsonld to include isPartOf url with FOS/SDG search pages

This commit is contained in:
argirok 2022-06-22 16:13:28 +03:00
parent 18b403bec0
commit d12138bc2a
5 changed files with 20 additions and 6 deletions

View File

@ -113,8 +113,10 @@
<div [attr.style]="'margin-top: '+(graph_height? 'calc(40px + 20px - '+graph_height+'px)': '40px')">
<!-- schema.org-->
<schema2jsonld *ngIf="resultLandingInfo.record" [data]=resultLandingInfo.record
[URL]="canonicalUrl"></schema2jsonld>
<!-- Actions for mobile viewport -->
[URL]="canonicalUrl"
[searchActionRoute]="properties.searchLinkToResults"></schema2jsonld>
<!-- Actions for mobile viewport -->
<div class="uk-flex uk-flex-right uk-margin-medium-bottom uk-hidden@s">
<!-- Share -->
<div class="uk-margin-small-right">

View File

@ -17,7 +17,8 @@ export class Dataset extends JsonldDocument {
keyword: String[];
issn:String[];
headline:String[];
alternativeHeadline:String[];
alternativeHeadline:String[];
isPartOf;
}
export interface Identifier {

View File

@ -59,7 +59,7 @@ export class Schema2jsonldComponent implements OnInit, OnChanges {
} else if (this.type == 'search') {
this.json = this.documentParser.createSearchPage(this.name, this.URL, this.logoURL, this.searchAction, this.description, this.searchActionRoute);
} else if (this.type == 'result') {
docOvject = this.documentParser.convertResult(this.data, this.URL);
docOvject = this.documentParser.convertResult(this.data, this.URL, this.searchActionRoute);
this.json = this.documentSerializer.serializeDataset(docOvject);
} else {
this.json = this.documentParser.createSimplePage(this.name, this.URL, this.description);

View File

@ -88,7 +88,9 @@ export class JsonldDocumentSerializerService {
else if (doc.keyword && doc.keyword.length > 1) {
buffer["keywords"] = _.join(doc.keyword, ", ");
}
if(doc.isPartOf && doc.isPartOf.length > 0){
buffer["isPartOf"] = doc.isPartOf;
}
if (doc.citation && doc.citation.length == 1) {
buffer["citation"] = this.buildCitation(doc.citation[0]);
}

View File

@ -92,7 +92,7 @@ export class OpenAireJsonldConverterService {
}
return buffer;
}
convertResult(result: any, URL): Dataset {
convertResult(result: any, URL, searchActionRoute = null): Dataset {
const doc = new Dataset();
doc.title = this.getTitle(result);
@ -111,6 +111,15 @@ export class OpenAireJsonldConverterService {
doc.citation = this.getCitation(result);
doc.license = this.getLicense(result);
doc.keyword = this.getKeyword(result);
doc.isPartOf = [];
let fosSubjects = this.getKeyword(result,"FOS");
let sdgSubjects = this.getKeyword(result,"SDG");
for(let fos of fosSubjects?fosSubjects:[]){
doc.isPartOf.push(URL.split('/search/')[0]+ searchActionRoute + "?fos=" + encodeURIComponent('"'+fos+'"'));
}
for(let sdg of sdgSubjects?sdgSubjects:[] ){
doc.isPartOf.push(URL.split('/search/')[0]+ searchActionRoute + "?sdg=" + encodeURIComponent('"'+sdg+'"'));
}
return doc;
}