mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-24 11:26:31 +00:00
Add filter "getArticleByPath" for theme templates
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user