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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more