« get me outta code hell

yaml: allTogether documentMode - 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>2025-07-07 14:24:31 -0300
committer(quasar) nebula <qznebula@protonmail.com>2025-07-15 17:27:05 -0300
commit73f29a3f34f5d7f608c151e03098671c3695d675 (patch)
treec563ee881013cd95d072310c6519d06ae26f3ed6 /src
parentfa0914c3f929fcd903f96e3fe1ee52e5c6deee0e (diff)
yaml: allTogether documentMode
Diffstat (limited to 'src')
-rw-r--r--src/data/yaml.js14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/data/yaml.js b/src/data/yaml.js
index 9788f19f..71887fc1 100644
--- a/src/data/yaml.js
+++ b/src/data/yaml.js
@@ -1009,6 +1009,12 @@ export const documentModes = {
   // array of processed documents (wiki objects).
   allInOne: Symbol('Document mode: allInOne'),
 
+  // allTogether: One or more documens, spread across any number of files.
+  // Expects files array (or function) and processDocument function.
+  // Calls save with an array of processed documents (wiki objects) - this is
+  // a flat array, *not* an array of the documents processed from *each* file.
+  allTogether: Symbol('Document mode: allTogether'),
+
   // oneDocumentTotal: Just a single document, represented in one file.
   // Expects file string (or function) and processDocument function. Calls
   // save with the single processed wiki document (data object).
@@ -1119,6 +1125,7 @@ export async function getFilesFromDataStep(dataStep, {dataPath}) {
       }
     }
 
+    case documentModes.allTogether:
     case documentModes.headerAndEntries:
     case documentModes.onePerFile: {
       if (!dataStep.files) {
@@ -1274,7 +1281,8 @@ export function processThingsFromDataStep(documents, dataStep) {
   const {documentMode} = dataStep;
 
   switch (documentMode) {
-    case documentModes.allInOne: {
+    case documentModes.allInOne:
+    case documentModes.allTogether: {
       const result = [];
       const aggregate = openAggregate({message: `Errors processing documents`});
 
@@ -1549,6 +1557,10 @@ export function saveThingsFromDataStep(thingLists, dataStep) {
       return dataStep.save(thing);
     }
 
+    case documentModes.allTogether: {
+      return dataStep.save(thingLists.flat());
+    }
+
     case documentModes.headerAndEntries:
     case documentModes.onePerFile: {
       return dataStep.save(thingLists);