« get me outta code hell

data: parse contribs & additional names from object shape - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-11-21 07:20:16 -0400
committer(quasar) nebula <qznebula@protonmail.com>2023-11-21 07:50:14 -0400
commitc9847299d6a31b5fb39f82f80c92e80d53c44234 (patch)
tree4c430b4bd8bff289bf9ad45dfad84a6682b70eae /src
parentbde469f4cede426bd9baa8981b876e82ae290972 (diff)
data: parse contribs & additional names from object shape
Diffstat (limited to 'src')
-rw-r--r--src/data/yaml.js22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/data/yaml.js b/src/data/yaml.js
index cde4413b..5da66c93 100644
--- a/src/data/yaml.js
+++ b/src/data/yaml.js
@@ -730,11 +730,14 @@ export function parseContributors(contributionStrings) {
     return contributionStrings;
   }
 
-  return contributionStrings.map(contribString => {
-    if (typeof contribString !== 'string') return contribString;
+  return contributionStrings.map(item => {
+    if (typeof item === 'object' && item['Who'])
+      return {who: item['Who'], what: item['What'] ?? null};
 
-    const match = contribString.match(extractAccentRegex);
-    if (!match) return contribString;
+    if (typeof item !== 'string') return item;
+
+    const match = item.match(extractAccentRegex);
+    if (!match) return item;
 
     return {
       who: match.groups.main,
@@ -748,11 +751,14 @@ export function parseAdditionalNames(additionalNameStrings) {
     return additionalNameStrings;
   }
 
-  return additionalNameStrings.map(additionalNameString => {
-    if (typeof additionalNameString !== 'string') return additionalNameString;
+  return additionalNameStrings.map(item => {
+    if (typeof item === 'object' && item['Name'])
+      return {name: item['Name'], annotation: item['Annotation'] ?? null};
+
+    if (typeof item !== 'string') return item;
 
-    const match = additionalNameString.match(extractAccentRegex);
-    if (!match) return additionalNameString;
+    const match = item.match(extractAccentRegex);
+    if (!match) return item;
 
     return {
       name: match.groups.main,