summaryrefslogtreecommitdiffstats
path: root/packages/gitbook-core/src/models/SummaryArticle.js
diff options
context:
space:
mode:
Diffstat (limited to 'packages/gitbook-core/src/models/SummaryArticle.js')
-rw-r--r--packages/gitbook-core/src/models/SummaryArticle.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/packages/gitbook-core/src/models/SummaryArticle.js b/packages/gitbook-core/src/models/SummaryArticle.js
new file mode 100644
index 0000000..3651c8a
--- /dev/null
+++ b/packages/gitbook-core/src/models/SummaryArticle.js
@@ -0,0 +1,32 @@
+const { Record, List } = require('immutable');
+
+const DEFAULTS = {
+ title: '',
+ depth: 0,
+ path: '',
+ url: '',
+ ref: '',
+ level: '',
+ articles: List()
+};
+
+class SummaryArticle extends Record(DEFAULTS) {
+ constructor(article) {
+ super({
+ ...article,
+ articles: (new List(article.articles))
+ .map(art => new SummaryArticle(art))
+ });
+ }
+
+ /**
+ * Return true if article is an instance of SummaryArticle
+ * @param {Mixed} article
+ * @return {Boolean}
+ */
+ static is(article) {
+ return (article instanceof SummaryArticle);
+ }
+}
+
+module.exports = SummaryArticle;