2016-06-30 13:21:47 +03:00
|
|
|
import {helper} from 'ember-helper';
|
2016-05-24 15:06:59 +03:00
|
|
|
import counter from 'ghost-admin/utils/word-count';
|
2014-03-02 18:30:35 +04:00
|
|
|
|
2016-06-30 13:21:47 +03:00
|
|
|
export default helper(function (params) {
|
2015-09-03 14:06:50 +03:00
|
|
|
if (!params || !params.length) {
|
2015-02-09 18:57:50 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
let markdown = params[0] || '';
|
2015-02-09 18:57:50 +03:00
|
|
|
|
2014-06-06 05:18:03 +04:00
|
|
|
if (/^\s*$/.test(markdown)) {
|
|
|
|
return '0 words';
|
|
|
|
}
|
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
let count = counter(markdown);
|
2014-10-25 01:09:50 +04:00
|
|
|
|
2014-06-06 05:18:03 +04:00
|
|
|
return count + (count === 1 ? ' word' : ' words');
|
2014-03-04 00:18:10 +04:00
|
|
|
});
|