From d905aff7cbf6baa8f898d1153d23bfbd33cefc2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9l=C3=A8ne=20MJ?= Date: Thu, 9 May 2024 10:59:17 +0200 Subject: [PATCH] Fix import bug for one contributor --- js/codemeta_generation.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/js/codemeta_generation.js b/js/codemeta_generation.js index 6f1d00d..2c1a8d7 100644 --- a/js/codemeta_generation.js +++ b/js/codemeta_generation.js @@ -50,7 +50,7 @@ const initJsonldLoader = contexts => { jsonld.documentLoader = getJsonldCustomLoader(contexts); }; -const getAllCodemetaContextUrls= () => { +const getAllCodemetaContextUrls = () => { return Object.values(CODEMETA_CONTEXTS).map(context => context.url); } @@ -450,8 +450,10 @@ async function importCodemeta() { setIfDefined(`#${key}`, value); } - importPersons('author', 'Author', doc['author']) - importPersons('contributor', 'Contributor', doc['contributor']) + importPersons('author', 'Author', doc['author']); + // If only one contributor, it is compacted to an object + const contributors = Array.isArray(doc['contributor'])? doc['contributor'] : [doc['contributor']]; + importPersons('contributor', 'Contributor', contributors); } function loadStateFromStorage() {