diff options
Diffstat (limited to 'packages/gitbook-core')
-rw-r--r-- | packages/gitbook-core/src/models/File.js | 9 | ||||
-rw-r--r-- | packages/gitbook-core/src/shapes/Summary.js | 5 | ||||
-rw-r--r-- | packages/gitbook-core/src/shapes/SummaryArticle.js | 7 | ||||
-rw-r--r-- | packages/gitbook-core/src/shapes/SummaryPart.js | 5 |
4 files changed, 16 insertions, 10 deletions
diff --git a/packages/gitbook-core/src/models/File.js b/packages/gitbook-core/src/models/File.js index 09dfc1b..6f44700 100644 --- a/packages/gitbook-core/src/models/File.js +++ b/packages/gitbook-core/src/models/File.js @@ -3,17 +3,20 @@ const { Record } = require('immutable'); const DEFAULTS = { type: '', - mtime: '', + mtime: new Date(), path: '' }; class File extends Record(DEFAULTS) { - constructor(file) { + constructor(file = {}) { if (typeof file === 'string') { file = { path: file }; } - super(file); + super({ + ...file, + mtime: new Date(file.mtime) + }); } /** diff --git a/packages/gitbook-core/src/shapes/Summary.js b/packages/gitbook-core/src/shapes/Summary.js index 7efe4e0..f97e66c 100644 --- a/packages/gitbook-core/src/shapes/Summary.js +++ b/packages/gitbook-core/src/shapes/Summary.js @@ -1,6 +1,7 @@ const React = require('react'); +const { listOf } = require('react-immutable-proptypes'); + const { - arrayOf, shape } = React.PropTypes; @@ -9,5 +10,5 @@ const Part = require('./SummaryPart'); module.exports = shape({ file: File.isRequired, - parts: arrayOf(Part).isRequired + parts: listOf(Part).isRequired }); diff --git a/packages/gitbook-core/src/shapes/SummaryArticle.js b/packages/gitbook-core/src/shapes/SummaryArticle.js index d13bb31..c5aa717 100644 --- a/packages/gitbook-core/src/shapes/SummaryArticle.js +++ b/packages/gitbook-core/src/shapes/SummaryArticle.js @@ -1,8 +1,9 @@ /* eslint-disable no-use-before-define */ -const React = require('react'); +const React = require('react'); +const { list } = require('react-immutable-proptypes'); + const { - arrayOf, string, number, shape @@ -14,7 +15,7 @@ const Article = shape({ path: string, ref: string, level: string, - articles: arrayOf(Article) + articles: list }); module.exports = Article; diff --git a/packages/gitbook-core/src/shapes/SummaryPart.js b/packages/gitbook-core/src/shapes/SummaryPart.js index 75d5602..769ddd1 100644 --- a/packages/gitbook-core/src/shapes/SummaryPart.js +++ b/packages/gitbook-core/src/shapes/SummaryPart.js @@ -1,6 +1,7 @@ const React = require('react'); +const { listOf } = require('react-immutable-proptypes'); + const { - arrayOf, string, shape } = React.PropTypes; @@ -9,5 +10,5 @@ const Article = require('./SummaryArticle'); module.exports = shape({ title: string.isRequired, - articles: arrayOf(Article) + articles: listOf(Article) }); |