summaryrefslogtreecommitdiffstats
path: root/lib/backbone/summary.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/backbone/summary.js')
-rw-r--r--lib/backbone/summary.js18
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/backbone/summary.js b/lib/backbone/summary.js
index 5d4d53c..a1caae7 100644
--- a/lib/backbone/summary.js
+++ b/lib/backbone/summary.js
@@ -24,8 +24,12 @@ function TOCArticle(summary, title, ref, articles, parent) {
}
var parts = url.parse(ref);
- this.path = parts.pathname;
- this.anchor = parts.hash;
+ this.ref = ref;
+
+ if (!this.isExternal()) {
+ this.path = parts.pathname;
+ this.anchor = parts.hash;
+ }
this.articles = _.map(articles || [], function(article) {
if (article instanceof TOCArticle) return article;
@@ -45,8 +49,9 @@ TOCArticle.prototype.walk = function(iter) {
TOCArticle.prototype.getContext = function() {
return {
title: this.title,
- path: this.path,
- anchor: this.anchor
+ path: this.isExternal()? undefined : this.path,
+ anchor: this.isExternal()? undefined : this.anchor,
+ url: this.isExternal()? this.ref : undefined
};
};
@@ -55,6 +60,11 @@ TOCArticle.prototype.hasLocation = function() {
return Boolean(this.path);
};
+// Return true if is pointing to an external location
+TOCArticle.prototype.isExternal = function() {
+ return location.isExternal(this.ref);
+};
+
// Return true if has children
TOCArticle.prototype.hasChildren = function() {
return this.articles.length > 0;