Add filter "getArticleByPath" for theme templates

This commit is contained in:
Samy Pessé
2016-04-13 11:48:29 +02:00
parent fb430ac1ed
commit 038cd0155b
+8
View File
@@ -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);