Include item link in Header #557
macrospecter
started this conversation in
Note Templates
Replies: 2 comments 5 replies
-
Thank you so much, but I think this template just puts the link in the body of the note. I’m trying to put it in the yaml header that only shows in the note exported to Obsidian, not in Zotero. Do you by chance know how to do that? It involves editing the Header default template, and that file seems to accept a different coding language only.
…On Jul 26, 2023 at 7:26 PM -0700, nilleo ***@***.***>, wrote:
If I understand correctly, this link might be helpful to you. #588
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
1 reply
-
# This template is specifically for importing/sharing, using better
# notes 'import from clipboard': copy the content and
# goto Zotero menu bar, click Edit->New Template from Clipboard.
# Do not copy-paste this to better notes template editor directly.
name: "[ExportMDFileHeaderV2]"
content: |-
${await new Promise(async (r) => {
let header = {};
header.tags = noteItem.getTags().map((_t) => _t.tag);
header.parent = noteItem.parentItem
? noteItem.parentItem.getField("title")
: "";
header.collections = (
await Zotero.Collections.getCollectionsContainingItems([
(noteItem.parentItem || noteItem).id,
])
).map((c) => c.name);
header.noteLink = Zotero.BetterNotes.api.convert.note2link(noteItem);
r(JSON.stringify(header));
})} |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm hoping to include in the YAML data in the header a link back to the Zotero item. I don't care if it goes back to the note, the Zotero entry, or the PDF in the PDF reader--just some way to get back to the Zotero note from within the exported note.
Here is my current ExportMDFileHeaderV2 template, without the link:
${await new Promise(async (r) => { let header = {}; header.title = noteItem.parentItem ? noteItem.parentItem.getField("title") : ""; header.authors = noteItem.parentItem ? noteItem.parentItem.getCreators().map((au) => au.firstName + " " + au.lastName).join("; ") :""; header.tags = noteItem.parentItem.getTags().map((_t) => _t.tag); r(JSON.stringify(header)); })}
Ideally, the final note would look like this, with the link:
title: x
authors: y
tags: z
link: a
[all required fields-note id, library id, etc.]
I am aware of the following template for getting the PDF link, and I can make it work for a note template, but I cannot seem to make it work within the ExportMDFileHeader template, despite a lot of trial and error and searching through the discussions here.
${{ async function getPDFLink(item) { const att = await item.getBestAttachment(); if (!att || !att.isPDFAttachment()) { return ""; } key = att.key; if (att.libraryID === 1) { return
zotero://open-pdf/library/items/${key}; } else { groupID = Zotero.Libraries.get(att.libraryID).id; return
zotero://open-pdf/groups/${groupID}/items/${key}; } } sharedObj.getPDFLink = getPDFLink; return await getPDFLink(topItem); }}$
Would greatly appreciate anyone's help in how to implement this!
Beta Was this translation helpful? Give feedback.
All reactions