mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-29 07:09:48 +03:00
19 lines
391 B
JavaScript
19 lines
391 B
JavaScript
import {helper} from 'ember-helper';
|
|
import counter from 'ghost-admin/utils/word-count';
|
|
|
|
export default 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');
|
|
});
|