2013-07-01 20:24:48 +01:00
|
|
|
var fancyFirstChar;
|
2013-05-11 17:44:25 +01:00
|
|
|
|
2013-07-01 20:24:48 +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)) {
|
2013-07-01 20:24:48 +01:00
|
|
|
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);
|
|
|
|
|
2013-07-01 20:24:48 +01:00
|
|
|
posts[post].content_html = newContent;
|
2013-05-11 17:44:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return posts;
|
|
|
|
});
|
2013-07-01 20:24:48 +01:00
|
|
|
},
|
|
|
|
activate: function () {},
|
|
|
|
deactivate: function () {}
|
|
|
|
};
|
2013-05-29 01:10:39 +01:00
|
|
|
|
2013-07-01 20:24:48 +01:00
|
|
|
module.exports = fancyFirstChar;
|