mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
feat: new filter filter:teasers.configureStripTags
This commit is contained in:
@@ -12,8 +12,6 @@ var plugins = require('../plugins');
|
|||||||
var utils = require('../utils');
|
var utils = require('../utils');
|
||||||
|
|
||||||
module.exports = function (Topics) {
|
module.exports = function (Topics) {
|
||||||
var stripTeaserTags = utils.stripTags.concat(['img']);
|
|
||||||
|
|
||||||
Topics.getTeasers = async function (topics, options) {
|
Topics.getTeasers = async function (topics, options) {
|
||||||
if (!Array.isArray(topics) || !topics.length) {
|
if (!Array.isArray(topics) || !topics.length) {
|
||||||
return [];
|
return [];
|
||||||
@@ -69,6 +67,8 @@ module.exports = function (Topics) {
|
|||||||
});
|
});
|
||||||
await Promise.all(postData.map(p => posts.parsePost(p)));
|
await Promise.all(postData.map(p => posts.parsePost(p)));
|
||||||
|
|
||||||
|
const { tags } = await plugins.fireHook('filter:teasers.configureStripTags', { tags: utils.stripTags.concat(['img']) });
|
||||||
|
|
||||||
var teasers = topics.map(function (topic, index) {
|
var teasers = topics.map(function (topic, index) {
|
||||||
if (!topic) {
|
if (!topic) {
|
||||||
return null;
|
return null;
|
||||||
@@ -76,7 +76,7 @@ module.exports = function (Topics) {
|
|||||||
if (tidToPost[topic.tid]) {
|
if (tidToPost[topic.tid]) {
|
||||||
tidToPost[topic.tid].index = meta.config.teaserPost === 'first' ? 1 : counts[index];
|
tidToPost[topic.tid].index = meta.config.teaserPost === 'first' ? 1 : counts[index];
|
||||||
if (tidToPost[topic.tid].content) {
|
if (tidToPost[topic.tid].content) {
|
||||||
tidToPost[topic.tid].content = utils.stripHTMLTags(tidToPost[topic.tid].content, stripTeaserTags);
|
tidToPost[topic.tid].content = utils.stripHTMLTags(tidToPost[topic.tid].content, tags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return tidToPost[topic.tid];
|
return tidToPost[topic.tid];
|
||||||
|
|||||||
Reference in New Issue
Block a user