How to use citation-js - 10 common examples

To help you get started, we’ve selected a few citation-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pubpub / pubpub / server / utils / citations.js View on Github external
DOI: pubData.doi,
		// ISSN: pubData.doi ? (communityData.issn || '2471–2388') : null,
		ISSN: pubData.doi ? communityData.issn : null,
		issued: [
			{
				'date-parts': [
					pubIssuedDate.getFullYear(),
					pubIssuedDate.getMonth() + 1,
					pubIssuedDate.getDate(),
				],
			},
		],
		note: pubLink,
		URL: pubLink,
	});
	const versionCiteObject = new Cite({
		...commonData,
		id: pubData.activeVersion ? pubData.activeVersion.id : 'Draft',
		DOI:
			pubData.doi && pubData.activeVersion.id
				? `${pubData.doi}/${pubData.activeVersion.id.split('-')[0]}`
				: null,
		// ISSN: pubData.doi ? (communityData.issn || '2471–2388') : null,
		ISSN: pubData.doi ? communityData.issn : null,
		issued: [
			{
				'date-parts': [
					versionIssuedDate.getFullYear(),
					versionIssuedDate.getMonth() + 1,
					versionIssuedDate.getDate(),
				],
			},
github pubpub / pubpub / server / utils / citations.js View on Github external
return 0;
		})
		.map((attribution) => {
			return {
				given: attribution.user.firstName,
				family: attribution.user.lastName,
			};
		});
	const authorsEntry = authorData.length ? { author: authorData } : {};
	const commonData = {
		type: 'article-journal',
		title: pubData.title,
		...authorsEntry,
		'container-title': communityData.title,
	};
	const pubCiteObject = new Cite({
		...commonData,
		id: pubData.id,
		DOI: pubData.doi,
		// ISSN: pubData.doi ? (communityData.issn || '2471–2388') : null,
		ISSN: pubData.doi ? communityData.issn : null,
		issued: [
			{
				'date-parts': [
					pubIssuedDate.getFullYear(),
					pubIssuedDate.getMonth() + 1,
					pubIssuedDate.getDate(),
				],
			},
		],
		note: pubLink,
		URL: pubLink,
github seulibrary / Sorin / apps / frontend / assets / js / components / Citation / index.js View on Github external
let citationMLA = cData.map(data => {
            let json = this.parseCitation(data)
            let cite = new Cite(json)

            return cite.format("bibliography", {
                format: "html",
                template: "mla"
            })
        })
github seulibrary / Sorin / apps / frontend / assets / js / components / Citation / index.js View on Github external
let citationAPA = cData.map(data => {
            let cite = new Cite()
            let json = this.parseCitation(data)

            return cite.set(json).get(opt)
        })
github seulibrary / Sorin / apps / frontend / assets / js / components / Citation / index.js View on Github external
if (cData.itemtype != null) {
            let itemtype = cData.itemtype

            if (cData.itemtype == "article") {
                itemtype = "article-journal"
            }

            json.type = itemtype
        }

        if (cData.volume != null) {
            json.volume = cData.volume
        }

        return Cite.parse.csl([json])
    }
github seulibrary / Sorin / apps / frontend / assets / js / components / Citation / index.js View on Github external
buildCHI = () => {
        let cData = this.props.data

        Cite.CSL.register.addTemplate("chicago", chicago)

        if (!Array.isArray(cData)) {
            cData = [cData]
        }

        let citationCHI = cData.map(data => {
            let json = this.parseCitation(data)
            let cite = new Cite(json)

            return cite.format("bibliography", {
                format: "html",
                template: "chicago"
            })
        })

        return citationCHI.join("")
github seulibrary / Sorin / apps / frontend / assets / js / components / Citation / index.js View on Github external
buildMLA = () => {
        let cData = this.props.data

        Cite.CSL.register.addTemplate("mla", mla)

        if (!Array.isArray(cData)) {
            cData = [cData]
        }

        let citationMLA = cData.map(data => {
            let json = this.parseCitation(data)
            let cite = new Cite(json)

            return cite.format("bibliography", {
                format: "html",
                template: "mla"
            })
        })

        return citationMLA.join("")
github pubpub / pubpub / server / utils / citations.js View on Github external
})
		.map((attribution) => {
			return {
				given: attribution.user.firstName,
				family: attribution.user.lastName,
			};
		});
	const authorsEntry = authorData.length ? { author: authorData } : {};
	const commonData = {
		type: 'article-journal',
		title: pubData.title,
		...authorsEntry,
		'container-title': communityData.title,
		...getCollectionLevelData(primaryCollectionPub),
	};
	const pubCiteObject = await Cite.async({
		...commonData,
		id: pubData.id,
		DOI: pubData.doi,
		ISSN: pubData.doi ? communityData.issn : null,
		issued: pubIssuedDate && [getDatePartsObject(pubIssuedDate)],
		note: pubLink,
		URL: pubLink,
	});

	return {
		pub: {
			apa: pubCiteObject
				.get({ format: 'string', type: 'html', style: 'citation-apa', lang: 'en-US' })
				.replace(/\n/gi, ''),
			harvard: pubCiteObject
				.get({ format: 'string', type: 'html', style: 'citation-harvard', lang: 'en-US' })

citation-js

Citation.js converts formats like BibTeX, Wikidata JSON and ContentMine JSON to CSL-JSON to convert to other formats like APA, Vancouver and back to BibTeX.

MIT
Latest version published 3 months ago

Package Health Score

68 / 100
Full package analysis