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

34 lines
1.2 KiB
JavaScript
Raw Normal View History

var fancyFirstChar;
2013-05-11 17:44:25 +01:00
fancyFirstChar = {
init: function (ghost) {
ghost.registerFilter('prePostsRender', function (posts) {
2013-05-11 17:44:25 +01:00
var post,
originalContent,
newContent,
firstCharIndex = 0;
for (post in posts) {
if (posts.hasOwnProperty(post)) {
originalContent = posts[post].content_html;
2013-05-11 17:44:25 +01:00
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;
2013-05-11 17:44:25 +01:00
}
}
return posts;
});
},
activate: function () {},
deactivate: function () {}
};
2013-05-29 01:10:39 +01:00
module.exports = fancyFirstChar;