diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2025-04-14 20:59:17 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2025-04-14 21:35:13 -0300 |
commit | 7342b35d0da518fa5559dadc3239fd574a105432 (patch) | |
tree | a17ec409c03b6ab1a01c2f4cc2ec8ef2f8f85d4b /src/data/composite/things | |
parent | 6d811c36d2b9795ad58fd0bf11f6033d93863fed (diff) |
data: CommentaryEntry
Fully integrated, all in one commit! Wow!
Diffstat (limited to 'src/data/composite/things')
-rw-r--r-- | src/data/composite/things/commentary-entry/index.js | 1 | ||||
-rw-r--r-- | src/data/composite/things/commentary-entry/withWebArchiveDate.js | 41 |
2 files changed, 42 insertions, 0 deletions
diff --git a/src/data/composite/things/commentary-entry/index.js b/src/data/composite/things/commentary-entry/index.js new file mode 100644 index 00000000..091bae1a --- /dev/null +++ b/src/data/composite/things/commentary-entry/index.js @@ -0,0 +1 @@ +export {default as withWebArchiveDate} from './withWebArchiveDate.js'; 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)), + }), + }, + ], +}); |