« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/content/dependencies/generateAdditionalFilesList.js10
-rw-r--r--src/content/dependencies/generateAlbumAdditionalFilesList.js77
2 files changed, 37 insertions, 50 deletions
diff --git a/src/content/dependencies/generateAdditionalFilesList.js b/src/content/dependencies/generateAdditionalFilesList.js
index 92948c7a..fc24ee52 100644
--- a/src/content/dependencies/generateAdditionalFilesList.js
+++ b/src/content/dependencies/generateAdditionalFilesList.js
@@ -27,12 +27,10 @@ function validateFileMapping(v, validateValue) {
 export default {
   extraDependencies: ['html', 'language'],
 
-  data(additionalFiles) {
-    return {
-      // Additional files are already a serializable format.
-      additionalFiles,
-    };
-  },
+  data: (additionalFiles) => ({
+    // Additional files are already a serializable format.
+    additionalFiles,
+  }),
 
   slots: {
     fileLinks: {
diff --git a/src/content/dependencies/generateAlbumAdditionalFilesList.js b/src/content/dependencies/generateAlbumAdditionalFilesList.js
index 23f32bf5..06694c95 100644
--- a/src/content/dependencies/generateAlbumAdditionalFilesList.js
+++ b/src/content/dependencies/generateAlbumAdditionalFilesList.js
@@ -4,56 +4,45 @@ export default {
     'linkAlbumAdditionalFile',
   ],
 
-  extraDependencies: [
-    'getSizeOfAdditionalFile',
-    'html',
-    'urls',
-  ],
+  extraDependencies: ['getSizeOfAdditionalFile', 'html', 'urls'],
 
-  data(album, additionalFiles) {
-    return {
-      albumDirectory: album.directory,
-      fileLocations: additionalFiles.flatMap(({files}) => files),
-    };
-  },
+  data: (album, additionalFiles) => ({
+    albumDirectory: album.directory,
 
-  relations(relation, album, additionalFiles) {
-    return {
-      additionalFilesList:
-        relation('generateAdditionalFilesList', additionalFiles),
+    fileLocations:
+      additionalFiles.flatMap(({files}) => files),
+  }),
 
-      additionalFileLinks:
-        Object.fromEntries(
-          additionalFiles
-            .flatMap(({files}) => files)
-            .map(file => [
-              file,
-              relation('linkAlbumAdditionalFile', album, file),
-            ])),
-    };
-  },
+  relations: (relation, album, additionalFiles) => ({
+    additionalFilesList:
+      relation('generateAdditionalFilesList', additionalFiles),
+
+    additionalFileLinks:
+      Object.fromEntries(
+        additionalFiles
+          .flatMap(({files}) => files)
+          .map(file => [
+            file,
+            relation('linkAlbumAdditionalFile', album, file),
+          ])),
+  }),
 
   slots: {
     showFileSizes: {type: 'boolean', default: true},
   },
 
-  generate(data, relations, slots, {
-    getSizeOfAdditionalFile,
-    urls,
-  }) {
-    return relations.additionalFilesList
-      .slots({
-        fileLinks: relations.additionalFileLinks,
-        fileSizes:
-          Object.fromEntries(data.fileLocations.map(file => [
-            file,
-            (slots.showFileSizes
-              ? getSizeOfAdditionalFile(
-                  urls
-                    .from('media.root')
-                    .to('media.albumAdditionalFile', data.albumDirectory, file))
-              : 0),
-          ])),
-      });
-  },
+  generate: (data, relations, slots, {getSizeOfAdditionalFile, urls}) =>
+    relations.additionalFilesList.slots({
+      fileLinks: relations.additionalFileLinks,
+      fileSizes:
+        Object.fromEntries(data.fileLocations.map(file => [
+          file,
+          (slots.showFileSizes
+            ? getSizeOfAdditionalFile(
+                urls
+                  .from('media.root')
+                  .to('media.albumAdditionalFile', data.albumDirectory, file))
+            : 0),
+        ])),
+    }),
 };