From 80b752ccdbe313b9b0ca8bec6adffb0e92363419 Mon Sep 17 00:00:00 2001 From: Christopher Olah Date: Fri, 13 Jan 2017 13:46:38 -0800 Subject: [PATCH] update meta data generator --- components/meta.js | 63 ++++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/components/meta.js b/components/meta.js index f8b6f7b..4b2768d 100644 --- a/components/meta.js +++ b/components/meta.js @@ -48,41 +48,44 @@ export default function(dom, data) { `); - appendHead(` - `); + // if this is a proprer article, generate Google Scholar meta data + if (data.doiSuffix){ + appendHead(` + \n`); - meta("citation_title", data.title); - 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); + meta("citation_title", data.title); + 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); + 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.publishedDate){ - let zeroPad = (n) => { return n < 10 ? "0" + n : n; }; - meta("citation_publication_date", `${data.publishedYear}/${data.publishedMonthPadded}/${data.publishedDayPadded}`); - } + if (data.publishedDate){ + let zeroPad = (n) => { return n < 10 ? "0" + n : n; }; + meta("citation_publication_date", `${data.publishedYear}/${data.publishedMonthPadded}/${data.publishedDayPadded}`); + } - (data.authors || []).forEach((a) => { - meta("citation_author", `${a.lastName}, ${a.firstName}`); - meta("citation_author_institution", a.affiliation); - }); - - if (data.citations) { - data.citations.forEach(key => { - let d = data.bibliography[key]; - if(!d) { - console.warn("No bibliography data fround for " + key) - } else { - meta("citation_reference", citation_meta_content(data.bibliography[key]) ) - }; + (data.authors || []).forEach((a) => { + meta("citation_author", `${a.lastName}, ${a.firstName}`); + meta("citation_author_institution", a.affiliation); }); + + if (data.citations) { + data.citations.forEach(key => { + let d = data.bibliography[key]; + if(!d) { + console.warn("No bibliography data fround for " + key) + } else { + meta("citation_reference", citation_meta_content(data.bibliography[key]) ) + }; + }); + } } }