mirror of
https://github.com/wassname/template.git
synced 2026-07-07 19:58:43 +08:00
fix meta to be more compliant with scholar
This commit is contained in:
+33
-8
@@ -1,12 +1,13 @@
|
||||
import favicon from './distill-favicon.base64';
|
||||
import escape from 'escape-html';
|
||||
|
||||
export default function(dom, data) {
|
||||
let head = dom.querySelector("head");
|
||||
let appendHead = html => appendHtml(head, html);
|
||||
|
||||
function meta(name, content) {
|
||||
if (content)
|
||||
appendHead(` <meta name="${name}" content="${content}" >\n`);
|
||||
function meta(name, content, force) {
|
||||
if (content || force)
|
||||
appendHead(` <meta name="${name}" content="${escape(content)}" >\n`);
|
||||
}
|
||||
|
||||
appendHead(`
|
||||
@@ -55,20 +56,23 @@ export default function(dom, data) {
|
||||
<!-- https://scholar.google.com/intl/en/scholar/inclusion.html#indexing -->\n`);
|
||||
|
||||
meta("citation_title", data.title);
|
||||
meta("citation_fulltext_html_url", data.url);
|
||||
//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_journal_title", journal.full_title || journal.title);
|
||||
meta("citation_journal_abbrev", journal.abbrev_title);
|
||||
meta("citation_issn", journal.issn);
|
||||
meta("citation_publisher", journal.publisher);
|
||||
meta("citation_fulltext_world_readable", "", true);
|
||||
|
||||
if (data.publishedDate){
|
||||
let zeroPad = (n) => { return n < 10 ? "0" + n : n; };
|
||||
meta("citation_online_date", `${data.publishedYear}/${data.publishedMonthPadded}/${data.publishedDayPadded}`);
|
||||
// Should we do something different here?
|
||||
meta("citation_publication_date", `${data.publishedYear}/${data.publishedMonthPadded}/${data.publishedDayPadded}`);
|
||||
}
|
||||
|
||||
@@ -95,10 +99,31 @@ function appendHtml(el, html) {
|
||||
}
|
||||
|
||||
function citation_meta_content(ref){
|
||||
// Special test for arxiv
|
||||
var content = `citation_title=${ref.title};`;
|
||||
ref.author.split(" and ").forEach(author => {
|
||||
content += `citation_author=${author.trim()};`;
|
||||
|
||||
let name_strings = ref.author.split(" and ").forEach(name => {
|
||||
name = name.trim();
|
||||
if (name.indexOf(",") != -1){
|
||||
var last = name.split(",")[0].trim();
|
||||
var firsts = name.split(",")[1].trim();
|
||||
} else {
|
||||
var last = name.split(" ").slice(-1)[0].trim();
|
||||
var firsts = name.split(" ").slice(0,-1).join(" ");
|
||||
}
|
||||
content += `citation_author=${firsts} ${last};`;
|
||||
});
|
||||
|
||||
if ("year" in ref) {
|
||||
content += `citation_publication_date=${ref.year};`;
|
||||
}
|
||||
|
||||
var arxiv_id_search = /https?:\/\/arxiv\.org\/pdf\/([0-9]*\.[0-9]*)\.pdf/.exec(ref.url);
|
||||
arxiv_id_search = arxiv_id_search || /https?:\/\/arxiv\.org\/abs\/([0-9]*\.[0-9]*)/.exec(ref.url);
|
||||
if (arxiv_id_search && arxiv_id_search[1]){
|
||||
content += `citation_arxiv_id=${arxiv_id_search[1]};`;
|
||||
return content;
|
||||
}
|
||||
if ("journal" in ref){
|
||||
content += `citation_journal_title=${ref.journal};`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user