mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 14:03:48 +03:00
6b3f835cfb
- rename "content" to "content_raw" - rename "content_raw" to "content" - change all references
41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
var _ = require('underscore');
|
|
|
|
var fancyFirstChar;
|
|
|
|
function fancify(originalContent) {
|
|
var newContent,
|
|
firstCharIndex = 0;
|
|
|
|
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);
|
|
|
|
return newContent;
|
|
}
|
|
|
|
|
|
fancyFirstChar = {
|
|
init: function (ghost) {
|
|
ghost.registerFilter('prePostsRender', function (posts) {
|
|
if (_.isArray(posts)) {
|
|
_.each(posts, function (post) {
|
|
post.content = fancify(post.content);
|
|
});
|
|
} else if (posts.hasOwnProperty('content')) {
|
|
posts.content = fancify(posts.content);
|
|
}
|
|
|
|
return posts;
|
|
});
|
|
},
|
|
activate: function () {},
|
|
deactivate: function () {}
|
|
};
|
|
|
|
module.exports = fancyFirstChar; |