JavaScript templates
Last updated
Was this helpful?
Last updated
Was this helpful?
Custom functions must be defined with the syntax
window.customMetadata = function(item) { ... }
rather than
function customMetadata(item){ ... }
otherwise an error will be thrown. This syntax is needed to make the function globally available, so that it can be found by the extension.
All formatting functions must have the structure described below.
The function must take up to 3 arguments, in order :
The item's data object, as returned by the Zotero Web API. for an example from the Zotero API docs.
The item's linked PDFs
The item's linked notes/annotations
The function must return a single array, containing the blocks to be added to the item's Roam page. Each element of the array will be processed as a top-level Roam block to be added to the item's Roam page. The array's order will be the final block order in Roam.
Blocks can be provided in two forms:
A simple string of text, which will create a childless block
An Object with a string
property, and an optional children
property:
{ string: "The block's contents", children: [...] }
Objects will be processed recursively, which means you can specify as much nesting levels as you'd like (see ).
To start writing your own functions, feel free to make use of this , which has a few examples and demos: