Skip to content

feat: support relations in templates#433

Open
OliverDudgeon wants to merge 1 commit into
aidenlx:masterfrom
OliverDudgeon:relations
Open

feat: support relations in templates#433
OliverDudgeon wants to merge 1 commit into
aidenlx:masterfrom
OliverDudgeon:relations

Conversation

@OliverDudgeon

Copy link
Copy Markdown

Overview

This PR adds support for related items in Obsidian note templates, allowing users to access citation keys, backlinks, and relation metadata for connected Zotero items.

Addresses Issues:

Relations in Templates

  • relatedItems array: Full access to related items in template context
  • Citation keys: Related items include relatedCiteKey for Better BibTeX integration
  • Backlinks: Automatic zotero:// links for easy navigation to related items
  • Relation metadata: Access to relation types and Zotero keys
  • Cross-library support: Works with relations between user and group libraries

Template Example:

<%# Related Items Section %>
<%~ if (it.relatedItems && it.relatedItems.length > 0) { -%>
## Related Items

<%~ it.relatedItems.forEach(item => { -%>
- **<%~ item.relationType %>**: 
  <%~ if (item.relatedCiteKey) { -%>
    [[<%~ item.relatedCiteKey %>]] 
  <%~ } else { -%>
    <%~ item.relatedZoteroKey %>
  <%~ } -%>
  ([Open in Zotero](<%~ item.backlink %>))
<%~ }) -%>

<%~ } -%>

Implementation Details

Provides:

  • relatedItems array in template context
  • relatedCiteKey for Better BibTeX citation keys
  • relatedZoteroKey for Zotero item keys
  • relationType (e.g., "dc:relation", "owl:sameAs")
  • backlink for direct Zotero navigation

Updated Data Structure:

{
  itemID: 230,
  relatedItemKey: "http://zotero.org/users/5370407/items/DKPQSMUT",
  relationType: "dc:relation",
  relatedZoteroKey: "DKPQSMUT",      // new: Extracted Zotero key
  relatedCiteKey: "author2023title", // new: Better BibTeX citation key
  backlink: "zotero://select/library/items/DKPQSMUT" // new: Direct link
}

Notes

This PR is unfinished as it removes compatibility with the old bbt database format. I was unfamiliar with the codebase and just cobelled something together that worked for me.


Resolves: Template support for related items functionality
Partially addresses: #203 and #312 (related items in templates)
Type: Feature enhancement

@OliverDudgeon OliverDudgeon marked this pull request as ready for review February 9, 2026 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant