|
| 1 | +<div align="center"> |
| 2 | + <br> |
| 3 | + <img style="width: 500px; margin:3rem 0 1.5rem;" src="https://metascraper.js.org/static/logo-banner.png" alt="metascraper"> |
| 4 | + <br> |
| 5 | + <br> |
| 6 | + <p align="center"><strong>metascraper-citation</strong>: Get title, author, date, and publisher from Highwire Press <code>citation_*</code> and Dublin Core <code>dc.*</code> / <code>dcterms.*</code> meta tags.</p> |
| 7 | + <p align="center">See our <a href="https://metascraper.js.org" target='_blank' rel='noopener noreferrer'>website</a> for more information.</p> |
| 8 | + <br> |
| 9 | +</div> |
| 10 | + |
| 11 | +## Install |
| 12 | + |
| 13 | +```bash |
| 14 | +$ npm install metascraper-citation --save |
| 15 | +``` |
| 16 | + |
| 17 | +Load it **before** the generic property packages so these values win over Open Graph (e.g. a clean `citation_title` instead of `og:title` with a site suffix). |
| 18 | + |
| 19 | +```js |
| 20 | +const metascraper = require('metascraper')([ |
| 21 | + require('metascraper-citation')(), |
| 22 | + require('metascraper-author')(), |
| 23 | + require('metascraper-date')(), |
| 24 | + require('metascraper-publisher')(), |
| 25 | + require('metascraper-title')() |
| 26 | +]) |
| 27 | +``` |
| 28 | + |
| 29 | +## Supported tags |
| 30 | + |
| 31 | +The bundle is a no-op unless [`test`](#test) finds at least one Highwire or Dublin Core tag. Highwire selectors run first; Dublin Core fills gaps (and covers repositories that only emit DC). Missing fields fall through to the generic rules. |
| 32 | + |
| 33 | +Only the four properties below are set. Bibliographic extras (`citation_doi`, `dc.identifier`, ISSN, volume, issue, pages, PDF URL, language, abstract) are ignored. |
| 34 | + |
| 35 | +| Property | Tags (first match wins) | |
| 36 | +| --- | --- | |
| 37 | +| **title** | `citation_title`, `dc.title`, `dcterms.title` | |
| 38 | +| **author** | `citation_author`, `dc.creator`, `dcterms.creator`, `dc.contributor`, `dcterms.contributor` (first author only) | |
| 39 | +| **date** | `citation_publication_date`, `citation_date`, `citation_online_date`, `dcterms.issued`, `dcterms.created`, `dc.date`, `dcterms.date` | |
| 40 | +| **publisher** | `citation_publisher`, `citation_journal_title`, `dc.publisher`, `dcterms.publisher` | |
| 41 | + |
| 42 | +Names are matched case-insensitively (`DC.Title` and `dc.title` are the same tag). |
| 43 | + |
| 44 | +## API |
| 45 | + |
| 46 | +### test |
| 47 | + |
| 48 | +```js |
| 49 | +const { test } = require('metascraper-citation') |
| 50 | +``` |
| 51 | + |
| 52 | +Returns `true` when the Cheerio document has at least one `meta[name]` starting with `citation_`, `dc.`, or `dcterms.` (case-insensitive). Used as `rules.test` so the bundle skips pages with no scholarly markup. |
| 53 | + |
| 54 | +## License |
| 55 | + |
| 56 | +**metascraper-citation** © [Microlink](https://microlink.io), released under the [MIT](https://github.com/microlinkhq/metascraper/blob/master/LICENSE.md) License.<br> |
| 57 | +Authored and maintained by [Microlink](https://microlink.io) with help from [contributors](https://github.com/microlinkhq/metascraper/contributors). |
| 58 | + |
| 59 | +> [microlink.io](https://microlink.io) · GitHub [microlinkhq](https://github.com/microlinkhq) · X [@microlinkhq](https://x.com/microlinkhq) |
0 commit comments