-
Notifications
You must be signed in to change notification settings - Fork 5
/
Markdown Item URI.js
38 lines (31 loc) · 981 Bytes
/
Markdown Item URI.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
{
"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-11-30"
}
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 = getValidAuthor(item);
var title = item.title ? "*" + item.title + "*" : "";
var key = item.key;
Zotero.write(`[${author_lastname}${year}${title}](zotero://select/items/${library_id}_${key})`);
}
}
function getValidAuthor(item){
if(item.creators && item.creators[0] && item.creators[0].lastName){
return item.creators[0].lastName + ". ";
}else{
return "";
}
}