« get me outta code hell

data, yaml: store sorting info on getYamlLoadingSpec - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/things
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-01-29 08:22:53 -0400
committer(quasar) nebula <qznebula@protonmail.com>2024-01-30 07:59:40 -0400
commit2960fb60606ce0e356f7cb62c3b17e9d41e742fc (patch)
tree0976c8866912ed81d757a53c4315361cdf01aed6 /src/data/things
parenteb8b316bb9af7d34720de1fa8f8dbd4b81513b32 (diff)
data, yaml: store sorting info on getYamlLoadingSpec
Diffstat (limited to 'src/data/things')
-rw-r--r--src/data/things/album.js7
-rw-r--r--src/data/things/art-tag.js6
-rw-r--r--src/data/things/flash.js5
-rw-r--r--src/data/things/news-entry.js7
-rw-r--r--src/data/things/static-page.js6
5 files changed, 21 insertions, 10 deletions
diff --git a/src/data/things/album.js b/src/data/things/album.js
index 9d4729e4..318979cc 100644
--- a/src/data/things/album.js
+++ b/src/data/things/album.js
@@ -8,6 +8,8 @@ import {traverse} from '#node-utils';
 import {empty} from '#sugar';
 import Thing from '#thing';
 import {isDate} from '#validators';
+import {sortAlbumsTracksChronologically, sortChronologically}
+  from '#wiki-data';
 import {parseAdditionalFiles, parseContributors, parseDate, parseDimensions}
   from '#yaml';
 
@@ -369,6 +371,11 @@ export class Album extends Thing {
 
       return {albumData, trackData};
     },
+
+    sort({albumData, trackData}) {
+      sortChronologically(albumData);
+      sortAlbumsTracksChronologically(trackData);
+    },
   });
 }
 
diff --git a/src/data/things/art-tag.js b/src/data/things/art-tag.js
index 29cd2990..4d423db5 100644
--- a/src/data/things/art-tag.js
+++ b/src/data/things/art-tag.js
@@ -86,10 +86,10 @@ export class ArtTag extends Thing {
     documentMode: allInOne,
     documentThing: ArtTag,
 
-    save(artTagData) {
-      sortAlphabetically(artTagData);
+    save: (results) => ({artTagData: results}),
 
-      return {artTagData};
+    sort({artTagData}) {
+      sortAlphabetically(artTagData);
     },
   });
 }
diff --git a/src/data/things/flash.js b/src/data/things/flash.js
index ad80cbf2..93653548 100644
--- a/src/data/things/flash.js
+++ b/src/data/things/flash.js
@@ -4,6 +4,7 @@ import {input} from '#composite';
 import find from '#find';
 import Thing from '#thing';
 import {anyOf, isColor, isDirectory, isNumber, isString} from '#validators';
+import {sortFlashesChronologically} from '#wiki-data';
 import {parseDate, parseContributors} from '#yaml';
 
 import {exposeDependency, exposeUpdateValueOrContinue}
@@ -250,5 +251,9 @@ export class FlashAct extends Thing {
 
       return {flashData, flashActData};
     },
+
+    sort({flashData}) {
+      sortFlashesChronologically(flashData);
+    },
   });
 }
diff --git a/src/data/things/news-entry.js b/src/data/things/news-entry.js
index 658453b0..e0ec7f7b 100644
--- a/src/data/things/news-entry.js
+++ b/src/data/things/news-entry.js
@@ -57,11 +57,10 @@ export class NewsEntry extends Thing {
     documentMode: allInOne,
     documentThing: NewsEntry,
 
-    save(newsData) {
-      sortChronologically(newsData);
-      newsData.reverse();
+    save: (results) => ({newsData: results}),
 
-      return {newsData};
+    sort({newsData}) {
+      sortChronologically(newsData, {latestFirst: true});
     },
   });
 }
diff --git a/src/data/things/static-page.js b/src/data/things/static-page.js
index 1e8cb7c6..9c7fec65 100644
--- a/src/data/things/static-page.js
+++ b/src/data/things/static-page.js
@@ -64,10 +64,10 @@ export class StaticPage extends Thing {
     documentMode: onePerFile,
     documentThing: StaticPage,
 
-    save(staticPageData) {
-      sortAlphabetically(staticPageData);
+    save: (results) => ({staticPageData: results}),
 
-      return {staticPageData};
+    sort({staticPageData}) {
+      sortAlphabetically(staticPageData);
     },
   });
 }