-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
42 additions
and
89 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
var recommend = require('./recommend'); | ||
var extractConfig = require('./recommend_config'); | ||
|
||
module.exports = function (post) { | ||
var rp_config = extractConfig(this.config); | ||
if (!rp_config.autoDisplay) return post; | ||
|
||
var rp_data = this.locals.get('data').recommended_posts; | ||
var internal = rp_config.internalLinks; | ||
var external = rp_config.externalLinks; | ||
var totalLinks = internal + external; | ||
var rps = recommend(rp_data, totalLinks, post); | ||
if (rps.length > 0) { | ||
var rps_list = rps.map(post => '<li><a href="' + post.permalink + '">' + post.title + '</a></li>').join(''); | ||
var rps_html = '<div>' + rp_config.titleHtml + '<ul>' + rps_list + '</ul></div>' | ||
post.content += rps_html; | ||
} | ||
return post; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters