mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-25 11:52:10 +00:00
getArticleByPath is now a global function for template instead of a filter
This commit is contained in:
@@ -56,6 +56,21 @@ function createTemplateEngine(output, currentFile) {
|
||||
|
||||
context: context,
|
||||
|
||||
globals: {
|
||||
/**
|
||||
Return an article by its path
|
||||
|
||||
@param {String} articlePath
|
||||
@return {Object|undefined}
|
||||
*/
|
||||
getArticleByPath: function(articlePath) {
|
||||
var article = summary.getByPath(articlePath);
|
||||
if (!article) return undefined;
|
||||
|
||||
return JSONUtils.encodeSummaryArticle(article);
|
||||
}
|
||||
},
|
||||
|
||||
filters: defaultFilters.merge({
|
||||
/**
|
||||
Translate a sentence
|
||||
@@ -97,15 +112,6 @@ function createTemplateEngine(output, currentFile) {
|
||||
|
||||
contentURL: function(filePath) {
|
||||
return fileToURL(output, filePath);
|
||||
},
|
||||
|
||||
/**
|
||||
Return an article by its path
|
||||
*/
|
||||
getArticleByPath: function(s) {
|
||||
var article = summary.getByPath(s);
|
||||
if (!article) return undefined;
|
||||
return JSONUtils.encodeSummaryArticle(article);
|
||||
}
|
||||
}),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user