Skip to content

Commit

Permalink
Fixed Issue with Date
Browse files Browse the repository at this point in the history
  • Loading branch information
silentdot committed Nov 20, 2020
1 parent 299b8be commit 03e99dc
Showing 1 changed file with 29 additions and 28 deletions.
57 changes: 29 additions & 28 deletions Markdown Item URI with Citekey.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
{
"translatorID":"8dbf9b92-f796-4153-8f2e-ac6c157500dc",
"translatorType":2,
"label":"Markdown Item URI",
"creator":"Silent",
"target":"markdown",
"minVersion":"2.0",
"maxVersion":"",
"priority":200,
"inRepository":false,
"lastUpdated":"2020-10-15",
"local": ""
}


function doExport() {
var item;
while(item = Zotero.nextItem()) {
var date = Zotero.Utilities.strToDate(item.date).year;
var year = date && !isNaN(date) ? date + ". " : (typeof item.date == 'undefined'? "" : item.date + ". ");
var library_id = item.libraryID ? item.libraryID : "";
var author_lastname = item.creators[0].lastName ? item.creators[0].lastName + ". " : "";
var title = item.title ? "*" + item.title + "*" : "";
var key = item.key;

Zotero.write(`[${author_lastname}${year}${title}](zotero://select/items/${library_id}_${key})`)
}
}

"translatorID":"d90fd4af-9eeb-4232-9feb-8fd05bcf6f8b",
"translatorType":2,
"label":"Markdown Item URI with Citekey",
"creator":"Silent",
"target":"markdown",
"minVersion":"2.0",
"maxVersion":"",
"priority":200,
"inRepository":false,
"lastUpdated":"2020-10-14"
}



function doExport() {
var item;
while(item = Zotero.nextItem()) {
var date = Zotero.Utilities.strToDate(item.date).year;

var year = date && !isNaN(date) ? date + ". " : (typeof item.date == 'undefined'? "" : item.date + ". ");
var library_id = item.libraryID ? item.libraryID : "";
var author_lastname = item.creators[0].lastName ? item.creators[0].lastName + ". " : "";
var title = item.title ? "*" + item.title + "*" : "";
var key = item.key;
var citekey = item.citationKey ? `[[${item.citationKey}]]` : "";

Zotero.write(`[${author_lastname}${year}${title}](zotero://select/items/${library_id}_${key})${citekey}`);
}
}

0 comments on commit 03e99dc

Please sign in to comment.