diff --git a/components/citation.js b/components/citation.js index 1fdf992..5ee83ec 100644 --- a/components/citation.js +++ b/components/citation.js @@ -28,7 +28,7 @@ export default function(dom, data) { let ol = dom.createElement("ol"); citations.forEach(key => { let el = dom.createElement("li"); - el.textContent = bibliography_cite(data.bibliography[key]); + el.innerHTML = bibliography_cite(data.bibliography[key]); ol.appendChild(el); }) bibEl.appendChild(ol); @@ -103,15 +103,36 @@ export default function(dom, data) { return cite; } + function link_string(ent){ + if ("url" in ent){ + if (ent.url.slice(-4) == ".pdf"){ + var label = "PDF"; + } else if (ent.url.slice(-5) == ".html") { + var label = "HTML"; + } + return `  [${label||"link"}]`; + }/* else if ("doi" in ent){ + return `  [DOI]`; + }*/ else { + return ""; + } + } + function doi_string(ent, new_line){ + if ("doi" in ent) { + return `${new_line?"
":""} DOI: ${ent.doi}`; + } else { + return ""; + } + } + function bibliography_cite(ent, fancy){ if (ent){ var cite = author_string(ent, "L, I", ", ", " and "); cite += ", " + ent.year + ". " - cite += ent.title + ". "; + cite += "" + ent.title + ". "; cite += venue_string(ent); - if (fancy && ent.url && ent.url.slice(-4) == ".pdf") { - cite = `${cite} [pdf]` - } + cite += doi_string(ent); + cite += link_string(ent); return cite } else { return "?"; @@ -122,18 +143,11 @@ export default function(dom, data) { if (ent){ var cite = ""; cite += "" + ent.title + ""; - if (ent.url && ent.url.slice(-4) == ".pdf") { - cite = `${cite}  [PDF]` - } - if (ent.url && ent.url.slice(-5) == ".html") { - cite = `${cite}  [HTML]` - } + cite += link_string(ent); cite += "
" cite += author_string(ent, "I L", ", ") + ".
"; cite += venue_string(ent).trim() + " " + ent.year + ". " - if ("doi" in ent) { - cite += `
DOI: ${ent.doi}` - } + cite += doi_string(ent, true); return cite } else { return "?"; @@ -142,7 +156,7 @@ export default function(dom, data) { //https://scholar.google.com/scholar?q=allintitle%3ADocument+author%3Aolah - function get_URL(ent){ + function get_GS_URL(ent){ if (ent){ var names = ent.author.split(" and "); names = names.map(name => name.split(",")[0].trim())