Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/myllaume/eleventy-plugin-citeproc
Use citeproc.js in Eleventy, to process citations and generate bibliographies for your Eleventy projects.
https://github.com/myllaume/eleventy-plugin-citeproc
11ty 11ty-plugin citeproc-js csl-json
Last synced: 3 months ago
JSON representation
Use citeproc.js in Eleventy, to process citations and generate bibliographies for your Eleventy projects.
- Host: GitHub
- URL: https://github.com/myllaume/eleventy-plugin-citeproc
- Owner: Myllaume
- Created: 2022-09-17T12:17:11.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-01T09:39:41.000Z (4 months ago)
- Last Synced: 2024-10-14T07:04:48.401Z (3 months ago)
- Topics: 11ty, 11ty-plugin, citeproc-js, csl-json
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/eleventy-plugin-citeproc
- Size: 15.6 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
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](https://pandoc.org/MANUAL.html#citations-in-note-styles).
### Code
**Liquid, Nunjucks**
```html
{{ content | references | safe }}
{{ content | bibliography | safe }}
```
**11ty.js**
```js
module.exports = function(content) {
return `${this.references(content)}${this.bibliography(content)}`;
};
```### Result
```html
On writing as a technology of the intellect (Goody 1977, p. 12).
GOODY, Jack, 1977. The Domestication of the Savage Mind. Cambridge : Cambridge University Press. ISBN 978-0-521-21726-2.```
## 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](https://www.zotero.org/styles).
- **Bibliographic localization** : `.xml` file, containing localized bibliographic terms (e.g. publisher, issue…) in the language of your choice. Dowloaded from [CSL project repository](https://github.com/citation-style-language/locales/tree/6b0cb4689127a69852f48608b6d1a879900f418b)```js
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*.
```json
[
{
"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**
```html
{{ content | bibliography({ className: 'custom' }) | safe }}
```
**11ty.js**
```js
module.exports = function(content) {
return `${this.bibliography(content, { className: 'custom' })}`;
};
```**Output**
```html
GOODY, Jack, 1977...```
## 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](https://github.com/infologie) about this documentation.