mirror of
https://github.com/john-okeefe/foliate-js.git
synced 2026-09-09 11:29:14 -04:00
EPUB: fix subjects
Also update README
This commit is contained in:
@@ -95,7 +95,7 @@ Processors for each book format return an object that implements the following i
|
|||||||
- `.href`: a string representing the destination of the item. Does not have to be a valid URL.
|
- `.href`: a string representing the destination of the item. Does not have to be a valid URL.
|
||||||
- `.subitems`: a array that contains TOC items
|
- `.subitems`: a array that contains TOC items
|
||||||
- `.pageList`: same as the TOC, but for the [page list](https://www.w3.org/publishing/epub32/epub-packages.html#sec-nav-pagelist).
|
- `.pageList`: same as the TOC, but for the [page list](https://www.w3.org/publishing/epub32/epub-packages.html#sec-nav-pagelist).
|
||||||
- `.metadata`: an object representing the metadata of the book.
|
- `.metadata`: an object representing the metadata of the book. Currently, it follows more or less the metadata schema of [Readium's webpub manifest](https://github.com/readium/webpub-manifest).
|
||||||
- `.rendition`: an object that contains properties that correspond to the [rendition properties](https://www.w3.org/publishing/epub32/epub-packages.html#sec-package-metadata-rendering) in EPUB. If `.layout` is `"pre-paginated"`, the book is rendered with the fixed layout renderer.
|
- `.rendition`: an object that contains properties that correspond to the [rendition properties](https://www.w3.org/publishing/epub32/epub-packages.html#sec-package-metadata-rendering) in EPUB. If `.layout` is `"pre-paginated"`, the book is rendered with the fixed layout renderer.
|
||||||
- `.resolveHref(href)`: given an href string, returns an object representing the destination referenced by the href, which has the following properties:
|
- `.resolveHref(href)`: given an href string, returns an object representing the destination referenced by the href, which has the following properties:
|
||||||
- `.index`: the index of the referenced section in the `.section` array
|
- `.index`: the index of the referenced section in the `.section` array
|
||||||
|
|||||||
@@ -134,7 +134,13 @@ const METADATA = [
|
|||||||
{ name: 'rights', ...LANGS, props: [ALTS] },
|
{ name: 'rights', ...LANGS, props: [ALTS] },
|
||||||
{ name: 'date' },
|
{ name: 'date' },
|
||||||
{ name: 'dcterms:modified', type: 'meta' },
|
{ name: 'dcterms:modified', type: 'meta' },
|
||||||
{ name: 'subject', many: true, ...LANGS, props: ['term', 'authority', ALTS] },
|
{
|
||||||
|
name: 'subject', many: true, ...LANGS, props: ['term', 'authority', ALTS],
|
||||||
|
setLegacyAttrs: (obj, el) => {
|
||||||
|
obj.term ??= el.getAttributeNS(NS.OPF, 'term')
|
||||||
|
obj.authority ??= el.getAttributeNS(NS.OPF, 'authority')
|
||||||
|
},
|
||||||
|
},
|
||||||
{ name: 'source', many: true },
|
{ name: 'source', many: true },
|
||||||
{
|
{
|
||||||
name: 'belongs-to-collection', type: 'meta', many: true, ...LANGS,
|
name: 'belongs-to-collection', type: 'meta', many: true, ...LANGS,
|
||||||
@@ -888,8 +894,9 @@ ${doc.querySelector('parsererror').innerText}`)
|
|||||||
published: metadata?.date,
|
published: metadata?.date,
|
||||||
modified: metadata?.dctermsModified,
|
modified: metadata?.dctermsModified,
|
||||||
subject: metadata?.subject
|
subject: metadata?.subject
|
||||||
?.filter(({ value, code }) => value || code)
|
?.filter(({ value, term }) => value || term)
|
||||||
?.map(({ value, code, scheme }) => ({ name: value, code, scheme })),
|
?.map(({ value, term, authority }) =>
|
||||||
|
({ name: value, code: term, scheme: authority })),
|
||||||
rights: metadata?.rights?.value,
|
rights: metadata?.rights?.value,
|
||||||
}
|
}
|
||||||
const relators = {
|
const relators = {
|
||||||
|
|||||||
Reference in New Issue
Block a user