npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

eleventy-plugin-citeproc

v0.1.3

Published

Eleventy filters to process citations and generate bibliographies from Citation Style Language

Downloads

5

Readme

eleventy-plugin-citeproc

Use citeproc.js in Eleventy, to process citations and generate bibliographies for your Eleventy projects.

Bibliographic data and styles use the Citation Style Language (CSL) standard. The insertion of citations in files uses the Pandoc citation syntax.

Features

Process citations and generate bibliographies with filters :

Sample text

On writing as a technology of the intellect [@Goody1977, 12].

See how to write citations at Pandoc manual.

Code

Liquid, Nunjucks

<main>
    {{ content | references | safe }}
</main>

<footer>
    {{ content | bibliography | safe }}
</footer>

11ty.js

module.exports = function(content) {
    return `<main>${this.references(content)}</main><footer>${this.bibliography(content)}</footer>`;
};

Result

<main>
    On writing as a technology of the intellect (Goody 1977, p. 12).
</main>

<footer>
    <div class="csl-entry">GOODY, Jack, 1977. <i>The Domestication of the Savage Mind</i>. Cambridge : Cambridge University Press. ISBN 978-0-521-21726-2. </div>
</footer>

Installation

Download

Requires Eleventy 1.0.0 or newer & NodeJs 15 or newer.

npm i eleventy-plugin-citeproc

Configuration

Global options

You need three files to get citations and bibliographies :

  • Bibliographic data : .json file, containing metadata describing bibliographic references (example further down). Dowloaded from your Zotero public group?
  • Bibliographic style : .csl file, containing formatting rules for citations and bibliographies. Dowloaded from Zotero CSL styles directory.
  • Bibliographic localization : .xml file, containing localized bibliographic terms (e.g. publisher, issue…) in the language of your choice. Dowloaded from CSL project repository
const path = require('path');

const eleventyCiteproc = require("eleventy-plugin-citeproc");

module.exports = function (eleventyConfig) {
    eleventyConfig.addPlugin(eleventyCiteproc, {
        bibliographicStylePath: path.join(__dirname, 'iso690-author-date-fr-no-abstract.csl'),
        bibliographicLocalizationPath: path.join(__dirname, 'locales-en-GB.xml'),
        bibliographicDataPath: path.join(__dirname, 'bib-data.json')
    });

    return {
        dir: {
            input: "views",
            output: "dist"
        }
    };
};

Bibliographic data file

The string on id property (goody1977 on below exemple) is the key you need to write on your content.

[
    {
        "id": "goody1977",
        "author": [
            {
                "family": "Goody",
                "given": "Jack"
            }
        ],
        "event-place": "Cambridge",
        "ISBN": "978-0-521-21726-2",
        "issued": {
            "date-parts": [
                [
                    1977
                ]
            ]
        },
        "language": "en",
        "number-of-pages": "179",
        "publisher": "Cambridge University Press",
        "publisher-place": "Cambridge",
        "title": "The Domestication of the Savage Mind",
        "type": "book"
    }
]

Local options

Custom bibliography entries class name

Liquid, Nunjucks

<footer>
    {{ content | bibliography({ className: 'custom' }) | safe }}
</footer>

11ty.js

module.exports = function(content) {
    return `<main>${this.bibliography(content, { className: 'custom' })}</main>`;
};

Output

<main>
    <div class="custom">GOODY, Jack, 1977...</div>
</main>

Test

npm i
npm test

See directories /test and /utils. Add /utils/**.11ty.js files to check in /test/**.js files content.

Credits

Thanks to Arthur Perret about this documentation.