« get me outta code hell

data, yaml: store data step info on Thing constructors - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/things/news-entry.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-01-29 08:10:30 -0400
committer(quasar) nebula <qznebula@protonmail.com>2024-01-30 07:59:40 -0400
commiteb8b316bb9af7d34720de1fa8f8dbd4b81513b32 (patch)
tree22d435e702b89344304928b7a860a5326357f192 /src/data/things/news-entry.js
parentb30585187480a270826767eaf97e1acc66126072 (diff)
data, yaml: store data step info on Thing constructors
Diffstat (limited to 'src/data/things/news-entry.js')
-rw-r--r--src/data/things/news-entry.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/data/things/news-entry.js b/src/data/things/news-entry.js
index 5a02244..658453b 100644
--- a/src/data/things/news-entry.js
+++ b/src/data/things/news-entry.js
@@ -1,4 +1,7 @@
+export const NEWS_DATA_FILE = 'news.yaml';
+
 import Thing from '#thing';
+import {sortChronologically} from '#wiki-data';
 import {parseDate} from '#yaml';
 
 import {contentString, directory, name, simpleDate}
@@ -43,4 +46,22 @@ export class NewsEntry extends Thing {
       'Content': {property: 'content'},
     },
   };
+
+  static [Thing.getYamlLoadingSpec] = ({
+    documentModes: {allInOne},
+    thingConstructors: {NewsEntry},
+  }) => ({
+    title: `Process news data file`,
+    file: NEWS_DATA_FILE,
+
+    documentMode: allInOne,
+    documentThing: NewsEntry,
+
+    save(newsData) {
+      sortChronologically(newsData);
+      newsData.reverse();
+
+      return {newsData};
+    },
+  });
 }