2016-06-15 02:31:51 +08:00
|
|
|
import { censor } from 'pretty-text/censored-words';
|
|
|
|
import { registerOption } from 'pretty-text/pretty-text';
|
|
|
|
|
|
|
|
registerOption((siteSettings, opts) => {
|
|
|
|
opts.features.censored = true;
|
|
|
|
opts.censoredWords = siteSettings.censored_words;
|
2016-11-09 05:36:34 +08:00
|
|
|
opts.censoredPattern = siteSettings.censored_pattern;
|
2016-06-15 02:31:51 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
export function setup(helper) {
|
|
|
|
helper.addPreProcessor(text => {
|
2016-11-09 05:36:34 +08:00
|
|
|
const options = helper.getOptions();
|
|
|
|
return censor(text, options.censoredWords, options.censoredPattern);
|
2016-06-15 02:31:51 +08:00
|
|
|
});
|
|
|
|
}
|