zoteroRoam
Report an issueRoadmap
v0.7
v0.7
  • Introduction
  • โ–ถ๏ธDemo by Cortex Futura
  • ๐Ÿ”„Updating from older versions
  • ๐Ÿš€Changelog
  • ๐Ÿ†˜Help/Getting Support
  • ๐Ÿ Getting Started
    • Pre-requisites
    • Basic Setup
  • ๐ŸงชUsing the extension
    • The search panel
    • In-text references
    • Contextual menus
    • On-page menu
    • The dashboard
    • Web import
  • ๐Ÿ› ๏ธCustomizations
    • What's Available
    • Formatting metadata
      • SmartBlock templates
      • JavaScript templates
        • Helper functions
        • Nesting metadata
    • Formatting annotations
    • Formatting notes
    • Keyboard Shortcuts
    • CSS Themes
    • Other Settings
      • Autocomplete
      • Copy Settings
      • Page Menus
      • Scite Badge
      • Typemap
      • Web Import
      • Other
    • Advanced : Event Hooks
    • Advanced : Extension API
  • About the Zotero API
    • Zotero API Docs (v3)
  • Support the project
    • How to support/contribute
    • Buy a (virtual) coffee
    • Sponsor on GitHub
Powered by GitBook
On this page
  • Syntax
  • Specifications
  • Getting Started

Was this helpful?

  1. Customizations
  2. Formatting metadata

JavaScript templates

Last updated 2 years ago

Was this helpful?

Syntax

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.

Specifications

All formatting functions must have the structure described below.

Arguments

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

Return Value

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 ).

Getting Started

To start writing your own functions, feel free to make use of this , which has a few examples and demos:

๐Ÿ› ๏ธ
See here
Nesting metadata
Observable interactive notebook
zoteroRoam : Metadata formatting ๐Ÿ› 
Logo