| ; | |
| Object.defineProperty(exports, "__esModule", { | |
| value: true | |
| }); | |
| exports.default = citation; | |
| var _core = require("@citation-js/core"); | |
| var _engines = _interopRequireDefault(require("./engines.js")); | |
| function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } | |
| function prepareCiteItem(citeItem) { | |
| return typeof citeItem === 'object' ? citeItem : { | |
| id: citeItem | |
| }; | |
| } | |
| function prepareCitation(citation) { | |
| if (citation.citationItems) { | |
| return citation; | |
| } | |
| return { | |
| citationItems: [].concat(citation).map(prepareCiteItem), | |
| properties: { | |
| noteIndex: 0 | |
| } | |
| }; | |
| } | |
| function prepareCitations(context) { | |
| if (!context) { | |
| return []; | |
| } | |
| return context.map(prepareCitation); | |
| } | |
| function citation(data, options = {}) { | |
| const { | |
| template = 'apa', | |
| lang, | |
| format = 'text' | |
| } = options; | |
| const ids = data.map(({ | |
| id | |
| }) => id); | |
| const entries = options.entry ? options.entry : ids; | |
| data = _core.util.downgradeCsl(data); | |
| const citeproc = (0, _engines.default)(data, template, lang, format); | |
| const before = prepareCitations(options.citationsPre); | |
| const citation = prepareCitation(entries); | |
| const after = prepareCitations(options.citationsPost); | |
| const output = citeproc.rebuildProcessorState([...before, citation, ...after], format, []); | |
| return output[before.length][2]; | |
| } |
Xet Storage Details
- Size:
- 1.36 kB
- Xet hash:
- 6e6c9ecb16bf889f8a22c3501addf9fcb9c724fe6cf5fcd7c09418950f11dbd9
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.