0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00
ghost/content/plugins/fancyFirstChar.js
Hannah Wolfe 5c15c2d4b0 issue #186 - load plugins
- Adding activePlugins array to config.js
- Adding a loadPlugins function to ghost.js
- Tweaking fancyFirstChar.js so that it works again, getting rid of the function wrapper and constructor
2013-07-01 20:24:48 +01:00

34 lines
No EOL
1.2 KiB
JavaScript

var fancyFirstChar;
fancyFirstChar = {
init: function (ghost) {
ghost.registerFilter('prePostsRender', function (posts) {
var post,
originalContent,
newContent,
firstCharIndex = 0;
for (post in posts) {
if (posts.hasOwnProperty(post)) {
originalContent = posts[post].content_html;
if (originalContent.substr(0, 1) === '<') {
firstCharIndex = originalContent.indexOf('>') + 1;
}
newContent = originalContent.substr(0, firstCharIndex);
newContent += '<span class="fancyChar">';
newContent += originalContent.substr(firstCharIndex, 1);
newContent += '</span>';
newContent += originalContent.substr(firstCharIndex + 1, originalContent.length - firstCharIndex - 1);
posts[post].content_html = newContent;
}
}
return posts;
});
},
activate: function () {},
deactivate: function () {}
};
module.exports = fancyFirstChar;