« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content-function.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/content-function.js')
-rw-r--r--src/content-function.js16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/content-function.js b/src/content-function.js
index e141a686..04f2ce90 100644
--- a/src/content-function.js
+++ b/src/content-function.js
@@ -2,7 +2,7 @@ import {inspect as nodeInspect} from 'node:util';
 
 import {decorateError} from '#aggregate';
 import {colors, decorateTime, ENABLE_COLOR} from '#cli';
-import {Template} from '#html';
+import {Tag, Template} from '#html';
 import {empty} from '#sugar';
 
 function inspect(value, opts = {}) {
@@ -103,6 +103,20 @@ function prepareWorkingGenerateFunction(spec, boundExtraDependencies) {
     }
   };
 
+  generate = (baseGenerate => (...args) => {
+    const result = baseGenerate(...args);
+
+    if (result instanceof Template || result instanceof Tag) {
+      if (Object.hasOwn(result, Symbol.for('hsmusic.content.via'))) {
+        result[Symbol.for('hsmusic.contentFunction.via')].push(dependency);
+      } else {
+        result[Symbol.for('hsmusic.contentFunction.via')] = [dependency];
+      }
+    }
+
+    return result;
+  })(generate);
+
   generate = optionalDecorateTime(`generate`, dependency, generate);
 
   if (spec.slots) {