Skip to content

Commit

Permalink
Fix broken getCiteKey() resulting from recent BBT update
Browse files Browse the repository at this point in the history
'citekey' has been renamed to 'citationKey' in BBT.
See retorquere/zotero-better-bibtex@63028dc
  • Loading branch information
RoBaaaT committed Jan 9, 2024
1 parent 53fa5de commit 1bfef9c
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions content/mdnotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,11 @@ function getDateAdded(item) {
return simpleISODate(date)
}
function getCiteKey(item) {
if (typeof Zotero.BetterBibTeX === "object" && Zotero.BetterBibTeX !== null) {
var bbtItem = Zotero.BetterBibTeX.KeyManager.get(item.getField("id"));
return bbtItem.citekey;
}

return "undefined";
try {
return item.getField('citationKey');
} catch (_) {
return undefined;
}
}

function getLocalZoteroLink(item) {
Expand Down Expand Up @@ -523,7 +522,7 @@ function replace_wildcards(str, args) {


/**
*
*
* @param {string} str The string to be replaced
* @param {Object} args An array with the placeholder name as key and the (formatted) contents as values
* @returns {string} A string with the placeholders replaced
Expand Down Expand Up @@ -728,7 +727,7 @@ async function getZoteroNoteFileContents(item) {
let fileContents = remove_invalid_placeholders(
replace_placeholders(template, formattedPlaceholders)
);

fileContents = replace_wildcards(fileContents, note);
return { content: fileContents, name: fileName };
}
Expand Down Expand Up @@ -953,10 +952,10 @@ Zotero.Mdnotes =
async getRegularItemContents(item) {
let metadata = getItemMetadata(item);
let template = await readTemplate("Zotero Metadata Template");

// Add custom placeholders
get_placeholder_contents(template, metadata);

// Add formatting
let formattedPlaceholders = format_placeholders(metadata);
let newContents = remove_invalid_placeholders(
Expand Down

0 comments on commit 1bfef9c

Please sign in to comment.