SEO - jsonld: parse all subjects put keep at most 10

This commit is contained in:
argirok 2022-06-10 11:19:40 +03:00
parent ec4d727aaa
commit c1213b9836
1 changed files with 3 additions and 3 deletions

View File

@ -314,7 +314,7 @@ convertDatasource(datasource: any, URL, otherUrl): Organization {
return array;
}
private getKeyword(result: any): String[] {
private getKeyword(result: any, classification:'FOS'|'SDG' |null = null): String[] {
const subjects = _.get(result, "result.metadata.oaf:entity.oaf:result.subject", null);
if (!subjects) return null;
if (!Array.isArray(subjects)) return null;
@ -324,7 +324,7 @@ convertDatasource(datasource: any, URL, otherUrl): Organization {
const subjectArray = subjects as Array<any>;
for (var i = 0; i < subjectArray.length; i += 1) {
const classid = _.get(subjectArray[i], "classid", null);
if (classid !== "keyword") continue;
if(classification && classid !==classification) continue;
const sub = _.get(subjectArray[i], "content", null);
if (!sub) return null;
@ -332,7 +332,7 @@ convertDatasource(datasource: any, URL, otherUrl): Organization {
array.push(sub as String);
}
if (array.length == 0) return null;
return array;
return array.slice(0,10);
}
private getCreator(result: any): Person[] {