diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-04-13 11:48:29 +0200 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-04-13 11:48:29 +0200 |
commit | 038cd0155bcf1920d5bac65970698c2ce6e1593b (patch) | |
tree | e91db8c034190dbeabec21bc150ad0976f5c828d | |
parent | fb430ac1edc7cf35a75994b0fd7e114995edaf95 (diff) | |
download | gitbook-038cd0155bcf1920d5bac65970698c2ce6e1593b.zip gitbook-038cd0155bcf1920d5bac65970698c2ce6e1593b.tar.gz gitbook-038cd0155bcf1920d5bac65970698c2ce6e1593b.tar.bz2 |
Add filter "getArticleByPath" for theme templates
-rw-r--r-- | lib/output/website.js | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/output/website.js b/lib/output/website.js index 2533dee..3cf890e 100644 --- a/lib/output/website.js +++ b/lib/output/website.js @@ -96,6 +96,14 @@ WebsiteOutput.prototype.prepare = function() { return that.toURL(s); }); + // Get an article using its path + that.env.addFilter('getArticleByPath', function(s) { + var article = that.book.summary.getArticle(s); + if (!article) return undefined; + + return article.getContext(); + }); + // Relase path to an asset that.env.addFilter('resolveAsset', function(href) { href = path.join('gitbook', href); |