function customAnnots2Function(annotations){
const annots_grouped_by_date = annotations
.filter(annot => annot.data.annotationType == "highlight")
.reduce((list, annot) => {
const ymd = new Date(annot.data.dateAdded).toLocaleDateString("en-CA");
if(list[ymd]){
list[ymd].push(annot);
} else {
list[ymd] = [annot];
}
return list;
}, {});
return Object.keys(annots_grouped_by_date)
.sort((a,b) => new Date(a.split("-")) < new Date(b.split("-")) ? -1 : 1)
.map(date => {
const annots = annots_grouped_by_date[date];
return {
string: zoteroRoam.getItemDateAdded(annots[0], { brackets: true }),
children: annots
.map(annot => ({
string: annot.data.annotationText,
children: annot.data.annotationComment ? [annot.data.annotationComment + " #me"] : []
}))
};
});
}