- Source:
Methods
(static) bibliography(data, optionsopt) → {String}
This plugin adds the output format bibliography
, and accepts the following specific options:
prepend
(String
,Function
): prepend static or dynamic text to each entryappend
(String
,Function
): append static or dynamic text to each entrynosort
(Boolean
, default:false
): do not sort according to the style-defined rulesasEntryArray
(Boolean
, default:false
): return an array of entries consisting of an id and the output for that individual entry
Here's an example for prepend
and append
:
let cite = new Cite({ id: 'a', title: 'Item A' })
cite.format('bibliography', { append: ' [foobar]' })
// 'Item A. (n.d.). [foobar]\n'
cite.format('bibliography', { prepend (entry) { return `${entry.id}: ` } })
// 'a: Item A. (n.d.).\n'
And here's another example, possibly more realistic:
let cite = new Cite('Q30000000')
let date = (new Date()).toLocaleDateString()
cite.format('bibliography', {
format: 'html',
template: 'apa',
prepend (entry) {
return `[${entry.id}]: `
},
append: ` [Retrieved on ${date}]`
})
// `<div class="csl-bib-body">
// <div data-csl-entry-id="Q30000000" class="csl-entry">
// [Q30000000]: Miccadei, S., De Leo, R., Zammarchi, E., Natali, P. G., & Civitareale, D. (2002). The Synergistic Activity of Thyroid Transcription Factor 1 and Pax 8 Relies on the Promoter/Enhancer Interplay. <i>Molecular Endocrinology</i>, <i>16</i>(4), 837–846. https://doi.org/10.1210/MEND.16.4.0808 [Retrieved on 2018-7-10]
// </div>
// </div>`
This prepends [$ID]:
to each entry, where $ID
is the ID of that entry, and appends [Retrieved on $DATE]
, where $DATE
is today (constant for all entries).
Here's an example for asEntryArray
:
const cite = new Cite([
{ id: 'a', title: 'Item A', issued: { literal: 2021 } },
{ id: 'b', title: 'Item B', issued: { literal: 2021 } }
])
cite.format('bibliography', { asEntryArray: true })
// [
// [
// "a"
// "Item A. (2021).\n"
// ],
// [
// "b"
// "Item B. (2021).\n"
// ]
// ]
Parameters:
Name | Type | Attributes | Default | Description | |||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
Array.<CSL> | ||||||||||||||||||||||||||||||||||||||||||||||||
options |
Object |
<optional> |
{} |
Properties
|
- Implements:
- Source:
Returns:
output
- Type
- String
(static) citation(data, optionsopt) → {String}
Here's an example for entry
:
let cite = new Cite([
{ id: 'a', title: 'Item A', issued: { 'date-parts': [[2016]] } },
{ id: 'b', title: 'Item B', issued: { 'date-parts': [[2017]] } },
{ id: 'c', title: 'Item C', issued: { 'date-parts': [[2018]] } }
])
cite.format('citation')
// '(“Item A,” 2016; “Item B,” 2017; “Item C,” 2018)'
cite.format('citation', { entry: ['a', 'b'] })
// '(“Item A,” 2016; “Item B,” 2017)'
cite.format('citation', { entry: 'a' })
// '(“Item A,” 2016)'
cite.format('citation', { entry: [{ id: 'a', label: 'page', locator: 123 }] })
// '(“Item A,” 2016, p. 123)'
Parameters:
Name | Type | Attributes | Default | Description | |||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
Array.<CSL> | ||||||||||||||||||||||||||||||||||||||
options |
Object |
<optional> |
{} |
Properties
|
- Implements:
- Source:
Returns:
output
- Type
- String
Type Definitions
Citation
https://citeproc-js.readthedocs.io/en/latest/csl-json/markup.html#citations
Type:
- Object
Properties:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
citationItems |
Array.<module:@citation-js/plugin-csl.output~CiteItem> | |||||||
properties |
Object |
Properties
|
- Source:
CiteItem
https://citeproc-js.readthedocs.io/en/latest/csl-json/markup.html#cite-items
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
id |
String |
- Source:
DetailedEntry
Corresponds directly to the cite-items of citeproc-js.
Type:
- Object
Properties:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
locator |
Number | String |
<optional> |
page, figure, section etc. number of the citation |
|
label |
String |
<optional> |
'page' | type of locator to accompany the locator number |
suppress-author |
Boolean |
<optional> |
false | |
author-only |
Boolean |
<optional> |
false | |
prefix |
String |
<optional> |
||
suffix |
String |
<optional> |
- Source:
Entries
Type:
- Source:
Entry
Type:
- Source: