diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2025-04-14 20:59:17 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2025-04-16 13:03:14 -0300 |
commit | 14f9c99b13e499068b36ca67142fc20c3b3732a2 (patch) | |
tree | 057838c7f6b70f26e5b84c6e341bb2873cf7e4d2 /src/data/composite/things/commentary-entry/withWebArchiveDate.js | |
parent | d250ab8005783d722ac6a702995e8acd3c7cadc5 (diff) |
data: CommentaryEntry
Fully integrated, all in one commit! Wow!
Diffstat (limited to 'src/data/composite/things/commentary-entry/withWebArchiveDate.js')
-rw-r--r-- | src/data/composite/things/commentary-entry/withWebArchiveDate.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/data/composite/things/commentary-entry/withWebArchiveDate.js b/src/data/composite/things/commentary-entry/withWebArchiveDate.js new file mode 100644 index 00000000..3aaa4f64 --- /dev/null +++ b/src/data/composite/things/commentary-entry/withWebArchiveDate.js @@ -0,0 +1,41 @@ +import {input, templateCompositeFrom} from '#composite'; + +import {raiseOutputWithoutDependency} from '#composite/control-flow'; + +export default templateCompositeFrom({ + annotation: `withWebArchiveDate`, + + outputs: ['#webArchiveDate'], + + steps: () => [ + { + dependencies: ['annotation'], + + compute: (continuation, {annotation}) => + continuation({ + ['#dateText']: + annotation + ?.match(/https?:\/\/web.archive.org\/web\/([0-9]{8,8})[0-9]*\//) + ?.[1] ?? + null, + }), + }, + + raiseOutputWithoutDependency({ + dependency: '#dateText', + output: input.value({['#webArchiveDate']: null}), + }), + + { + dependencies: ['#dateText'], + compute: (continuation, {['#dateText']: dateText}) => + continuation({ + ['#webArchiveDate']: + new Date( + dateText.slice(0, 4) + '/' + + dateText.slice(4, 6) + '/' + + dateText.slice(6, 8)), + }), + }, + ], +}); |