« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/yaml.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/data/yaml.js')
-rw-r--r--src/data/yaml.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/data/yaml.js b/src/data/yaml.js
index 58acb7c8..60017b3d 100644
--- a/src/data/yaml.js
+++ b/src/data/yaml.js
@@ -733,6 +733,26 @@ export function parseContributors(entries) {
   });
 }
 
+export function parseURLs(entries) {
+  return parseArrayEntries(entries, item => {
+    if (typeof item === 'object' && item['URL'])
+      return {
+        url: item['URL'],
+        annotation: item['Annotation'] ?? null,
+      };
+
+    if (typeof item !== 'string') return item;
+
+    const match = item.match(extractAccentRegex);
+    if (!match) return item;
+
+    return {
+      url: match.groups.main,
+      annotation: match.groups.accent,
+    };
+  });
+}
+
 export function parseAdditionalFiles(entries, {subdoc, AdditionalFile}) {
   return parseArrayEntries(entries, item => {
     if (typeof item !== 'object') return item;