Fixes dc:date element
This commit is contained in:
parent
884cdb42eb
commit
c654c33f91
|
@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
|
|||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [1.2.2]
|
||||
### Fixed
|
||||
- Fixed `dc:date` element (publication date) in the generated EPUB
|
||||
|
||||
## [1.2.1]
|
||||
|
||||
### Added
|
||||
|
|
17
generate.js
17
generate.js
|
@ -22,8 +22,23 @@ module.exports = (url, epubPath, title, coverURL, language="en-US") => {
|
|||
|
||||
epubPath = epubPath ? epubPath : slugify(path.basename(url)) + '.epub';
|
||||
|
||||
let date = new Date(Date.parse(res.published));
|
||||
|
||||
|
||||
function pad(number) {
|
||||
if (number < 10) {
|
||||
return '0' + number;
|
||||
}
|
||||
return number;
|
||||
}
|
||||
|
||||
// Using toISOString() trips Pandoc, which leaves an empty dc:date element instead.
|
||||
let epubDate = date.getUTCFullYear() +
|
||||
'-' + pad(date.getUTCMonth() + 1) +
|
||||
'-' + pad(date.getUTCDate());
|
||||
|
||||
let xml = `<dc:title id="epub-title-1">${title}</dc:title>
|
||||
<dc:date>${res.published}</dc:date>
|
||||
<dc:date>${epubDate}</dc:date>
|
||||
<dc:language>${language}</dc:language>
|
||||
<dc:identifier>${url}</dc:identifier>
|
||||
<dc:source>${url}</dc:source>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "url-to-epub",
|
||||
"version": "1.2.0",
|
||||
"version": "1.2.2",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "url-to-epub",
|
||||
"version": "1.2.1",
|
||||
"version": "1.2.2",
|
||||
"description": "A single tool to generate a standards-compliant EPUB from a webpage. Zero config. Requires pandoc",
|
||||
"main": "index.js",
|
||||
"bin": {
|
||||
|
|
Loading…
Reference in New Issue