small fixes to meta

This commit is contained in:
Christopher Olah
2017-01-09 10:27:37 -08:00
parent 59f60d025f
commit 9a99c0726f
2 changed files with 28 additions and 6 deletions
+18
View File
@@ -0,0 +1,18 @@
import fetch from "fetch";
let fetchUrl = fetch.fetchUrl
export default function(dom, data) {
var includeTags = [].slice.apply(dom.querySelectorAll("dt-include"));
includeTags.forEach(el => {
let src = el.getAttribute("src");
fetchUrl(src, (err, meta, body) => {
console.log(err, meta, body);
el.innerHTML = body.toString();
})
});
data.bibliography = bibliography;
data.citations = citations;
}
+10 -6
View File
@@ -51,23 +51,27 @@ export default function(dom, data) {
<!-- https://scholar.google.com/intl/en/scholar/inclusion.html#indexing -->
`);
let journal = data.journal || {};
let zeroPad = (n) => { return n < 10 ? "0" + n : n; };
let publishedYear = data.published.getFullYear();
let publishedMonthPadded = zeroPad(data.published.getMonth() + 1);
let publishedDayPadded = zeroPad(data.published.getDate());
meta("citation_title", data.title);
meta("citation_publication_date", data.published? `${publishedYear}/${publishedMonthPadded}/${publishedDayPadded}` : undefined);
meta("citation_fulltext_html_url", data.url);
meta("citation_volume", data.volume);
meta("citation_issue", data.issue);
meta("citation_firstpage", data.doiSuffix? `e${data.doiSuffix}` : undefined);
meta("citation_doi", data.doi);
let journal = data.journal || {};
meta("citation_journal_title", journal.name);
meta("citation_journal_abbrev", journal.nameAbbrev);
meta("citation_issn", journal.issn);
meta("citation_publisher", journal.publisher);
if (data.published){
let zeroPad = (n) => { return n < 10 ? "0" + n : n; };
let publishedYear = data.published.getFullYear();
let publishedMonthPadded = zeroPad(data.published.getMonth() + 1);
let publishedDayPadded = zeroPad(data.published.getDate());
meta("citation_publication_date", `${publishedYear}/${publishedMonthPadded}/${publishedDayPadded}`);
}
(data.authors || []).forEach((a) => {
meta("citation_author", `${a.lastName}, ${a.firstName}`);
meta("citation_author_institution", a.affiliation);