diff --git a/components/include.js b/components/include.js new file mode 100644 index 0000000..a1e7a05 --- /dev/null +++ b/components/include.js @@ -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; + +} diff --git a/components/meta.js b/components/meta.js index 7581a3b..7bbc58f 100644 --- a/components/meta.js +++ b/components/meta.js @@ -51,23 +51,27 @@ export default function(dom, data) { `); - 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);