0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00
ghost/core/client/app/helpers/gh-count-words.js

21 lines
407 B
JavaScript
Raw Normal View History

2015-02-12 21:22:32 -07:00
import Ember from 'ember';
import counter from 'ghost/utils/word-count';
const {Helper} = Ember;
export default Helper.helper(function (params) {
if (!params || !params.length) {
return;
}
let markdown = params[0] || '';
if (/^\s*$/.test(markdown)) {
return '0 words';
}
let count = counter(markdown);
return count + (count === 1 ? ' word' : ' words');
});