From df244f21af6078f9456d8281da3a19e7c1e1a2f3 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Mon, 26 Jan 2026 17:49:33 -0400 Subject: data: Contribution.annotationFront, is{Featuring,EditsForWiki}Credit --- src/data/things/contrib/Contribution.js | 53 +++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 9 deletions(-) (limited to 'src/data/things/contrib/Contribution.js') diff --git a/src/data/things/contrib/Contribution.js b/src/data/things/contrib/Contribution.js index 4048709b..57a5c301 100644 --- a/src/data/things/contrib/Contribution.js +++ b/src/data/things/contrib/Contribution.js @@ -121,16 +121,51 @@ export class Contribution extends Thing { isContribution: exposeConstant(V(true)), - annotationParts: { - flags: {expose: true}, - expose: { - dependencies: ['annotation'], - compute: ({annotation}) => - (annotation - ? annotation.split(',').map(part => part.trim()) - : []), + recognizedAnnotationFronts: exposeConstant(V([])), + + annotationFront: [ + exitWithoutDependency('annotation'), + + { + dependencies: ['recognizedAnnotationFronts', 'annotation'], + compute: ({recognizedAnnotationFronts, annotation}) => + recognizedAnnotationFronts + .find(front => + annotation.startsWith(front) && ( + annotation === front || + annotation.at(front.length) === ':' || + annotation.at(front.length) === ',' + )) ?? null, }, - }, + ], + + annotationBack: [ + exitWithoutDependency('annotation'), + + exitWithoutDependency({ + dependency: 'annotationFront', + value: 'annotation', + }), + + { + dependencies: ['annotation', 'annotationFront'], + compute: ({annotation, annotationFront}) => + annotation.slice(annotationFront.length + 1).trim() + || null, + }, + ], + + annotationParts: [ + exitWithoutDependency('annotationBack', V([])), + + { + dependencies: ['annotationBack'], + compute: ({annotationBack}) => + annotationBack + .split(',') + .map(part => part.trim()), + }, + ], context: [ withContributionContext(), -- cgit 1.3.0-6-gf8a5