From 038cd0155bcf1920d5bac65970698c2ce6e1593b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samy=20Pess=C3=A9?= Date: Wed, 13 Apr 2016 11:48:29 +0200 Subject: [PATCH] Add filter "getArticleByPath" for theme templates --- lib/output/website.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/output/website.js b/lib/output/website.js index 2533deec6..3cf890e79 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);