Public
Edited
Mar 19, 2023
1 fork
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
zoteroRoam.getItemMetadata(item, pdfs, notes)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
zoteroRoam.getItemCollections(item)
Insert cell
Insert cell
zoteroRoam.getItemCreators(item)
Insert cell
Insert cell
zoteroRoam.getItemDateAdded(item)
Insert cell
Insert cell
zoteroRoam.getItemLink(item, "local")
Insert cell
zoteroRoam.getItemLink(item, "web")
Insert cell
Insert cell
zoteroRoam.getItemType(item)
Insert cell
Insert cell
zoteroRoam.formatNotes(notes)
Insert cell
Insert cell
zoteroRoam.formatPDFs(pdfs)
Insert cell
Insert cell
zoteroRoam.getItemPublication(item)
Insert cell
Insert cell
zoteroRoam.getItemRelated(item)
Insert cell
Insert cell
zoteroRoam.getItemTags(item)
Insert cell
Insert cell
function customFunction(item, pdfs, notes){
const metadata = [];

// Data that is always present can be accessed directly, like the item's title:
metadata.push(`Title:: ${item.data.title}`);

// But some data might be missing, in which case you may not want to add a block at all.
// A good pattern is to test if there is any data, with an `if` statement - then only adding a block if the condition is true:
if (item.data.creators.length > 0) {
metadata.push(`Author(s):: ${zoteroRoam.getItemCreators(item, { return_as: "string", brackets: true, use_type: true })}`);
}

// And so on. For example, not all items have an abstract:
if (item.data.abstractNote) {
metadata.push(`Abstract:: ${item.data.abstractNote}`);
}
// But all have a type:
metadata.push(`Type:: ${zoteroRoam.getItemType(item, { brackets: true })}`);

// Starting with v0.7, your custom function will now receive the item's linked PDFs, notes, and annotations,
// without requiring you to explicitly ask for them.
// You have access to their full metadata, and helpers that can format it for you.
// As above, it is recommended to test for the presence of any linked content before adding Roam blocks:
if (pdfs.length > 0) {
metadata.push(`PDF links : ${zoteroRoam.formatPDFs(pdfs, "links").join(", ")}`);
}
if (notes.length > 0) {
metadata.push({
string: "[[Notes]]",
children: zoteroRoam.formatNotes(notes)
});
}

return metadata;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more