@citation-js/plugin-bibjson
Advanced tools
Comparing version 0.6.9 to 0.7.0
import * as json from './json.js'; | ||
import { plugins } from '@citation-js/core'; | ||
const scraperLinks = ['fulltext_html', 'fulltext_xml', 'fulltext_pdf']; | ||
const authorNameFields = ['name', 'lastname', 'lastName', 'firstname', 'firstName']; | ||
const ref = '@bibjson'; | ||
@@ -33,3 +34,3 @@ const parsers = { | ||
value(authors) { | ||
return Array.isArray(authors) && authors[0] && 'name' in authors[0]; | ||
return Array.isArray(authors) && authors[0] && authorNameFields.some(field => field in authors[0]); | ||
} | ||
@@ -36,0 +37,0 @@ }] |
@@ -67,7 +67,5 @@ import { parse as parseDate } from '@citation-js/date'; | ||
const output = { | ||
type: typeMap[input.type] || 'document' | ||
type: typeMap[input.type] || 'document', | ||
title: input.title | ||
}; | ||
if (input.title) { | ||
output.title = input.title; | ||
} | ||
if (input.author) { | ||
@@ -93,10 +91,4 @@ output.author = input.author.map(nameProps).filter(Boolean); | ||
} | ||
if (input.date && Object.keys(input.date).length > 0) { | ||
const dates = input.date; | ||
if (dates.submitted) { | ||
output.submitted = parseDate(dates.submitted); | ||
} | ||
if (dates.published) { | ||
output.issued = parseDate(dates.published); | ||
} | ||
if (input.date && input.date.published) { | ||
output.issued = parseDate(input.date.published); | ||
} else if (input.year) { | ||
@@ -107,2 +99,5 @@ output.issued = { | ||
} | ||
if (input.date && input.date.submitted) { | ||
output.submitted = parseDate(input.date.submitted); | ||
} | ||
if (input.journal) { | ||
@@ -114,6 +109,6 @@ const journal = input.journal; | ||
if (journal.volume) { | ||
output.volume = +journal.volume; | ||
output.volume = journal.volume; | ||
} | ||
if (journal.issue) { | ||
output.issue = +journal.issue; | ||
output.issue = journal.issue; | ||
} | ||
@@ -120,0 +115,0 @@ Object.assign(output, idProps(journal, journalIdentifiers)); |
@@ -12,2 +12,3 @@ "use strict"; | ||
const scraperLinks = ['fulltext_html', 'fulltext_xml', 'fulltext_pdf']; | ||
const authorNameFields = ['name', 'lastname', 'lastName', 'firstname', 'firstName']; | ||
const ref = '@bibjson'; | ||
@@ -44,3 +45,3 @@ exports.ref = ref; | ||
value(authors) { | ||
return Array.isArray(authors) && authors[0] && 'name' in authors[0]; | ||
return Array.isArray(authors) && authors[0] && authorNameFields.some(field => field in authors[0]); | ||
} | ||
@@ -47,0 +48,0 @@ }] |
@@ -73,7 +73,5 @@ "use strict"; | ||
const output = { | ||
type: typeMap[input.type] || 'document' | ||
type: typeMap[input.type] || 'document', | ||
title: input.title | ||
}; | ||
if (input.title) { | ||
output.title = input.title; | ||
} | ||
if (input.author) { | ||
@@ -99,10 +97,4 @@ output.author = input.author.map(nameProps).filter(Boolean); | ||
} | ||
if (input.date && Object.keys(input.date).length > 0) { | ||
const dates = input.date; | ||
if (dates.submitted) { | ||
output.submitted = (0, _date.parse)(dates.submitted); | ||
} | ||
if (dates.published) { | ||
output.issued = (0, _date.parse)(dates.published); | ||
} | ||
if (input.date && input.date.published) { | ||
output.issued = (0, _date.parse)(input.date.published); | ||
} else if (input.year) { | ||
@@ -113,2 +105,5 @@ output.issued = { | ||
} | ||
if (input.date && input.date.submitted) { | ||
output.submitted = (0, _date.parse)(input.date.submitted); | ||
} | ||
if (input.journal) { | ||
@@ -120,6 +115,6 @@ const journal = input.journal; | ||
if (journal.volume) { | ||
output.volume = +journal.volume; | ||
output.volume = journal.volume; | ||
} | ||
if (journal.issue) { | ||
output.issue = +journal.issue; | ||
output.issue = journal.issue; | ||
} | ||
@@ -126,0 +121,0 @@ Object.assign(output, idProps(journal, journalIdentifiers)); |
{ | ||
"name": "@citation-js/plugin-bibjson", | ||
"version": "0.6.9", | ||
"version": "0.7.0", | ||
"description": "Plugin for BibJSON formats for Citation.js", | ||
@@ -27,3 +27,3 @@ "keywords": [ | ||
"engines": { | ||
"node": ">=14.0.0" | ||
"node": ">=16.0.0" | ||
}, | ||
@@ -42,3 +42,3 @@ "files": [ | ||
"devDependencies": { | ||
"@citation-js/core": "^0.6.9" | ||
"@citation-js/core": "^0.7.0" | ||
}, | ||
@@ -48,3 +48,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "59f96717266615ebfe4a621e9e791c5f47b43916" | ||
"gitHead": "763c634bc8723570f9cca34bbf46a3e7b3ffd439" | ||
} |
15058
11825
414