Skip to content

Commit

Permalink
append each topic title with content preview
Browse files Browse the repository at this point in the history
  • Loading branch information
a1inachen committed Sep 18, 2024
1 parent 05afb1a commit eed894e
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/categories/topics.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,22 @@ module.exports = function (Categories) {
let results = await plugins.hooks.fire('filter:category.topics.prepare', data);
const tids = await Categories.getTopicIds(results);
let topicsData = await topics.getTopicsByTids(tids, data.uid);

Check failure on line 18 in src/categories/topics.js

View workflow job for this annotation

GitHub Actions / test

Trailing spaces not allowed
let mainPosts = await topics.getMainPosts(tids, data.uid);

Check failure on line 19 in src/categories/topics.js

View workflow job for this annotation

GitHub Actions / test

'mainPosts' is never reassigned. Use 'const' instead
const strippedContent = mainPosts.map(post => {

Check failure on line 20 in src/categories/topics.js

View workflow job for this annotation

GitHub Actions / test

Expected parentheses around arrow function argument having a body with curly braces
// Strip HTML tags using regex
const plainText = post.content.replace(/<[^>]*>/g, '').trim();

Check failure on line 23 in src/categories/topics.js

View workflow job for this annotation

GitHub Actions / test

Trailing spaces not allowed
// Get first 10 chars
return plainText.substring(0, 10);
});
topicsData = topicsData.map((topic, index) => {
// Set titleRaw and title to stripped content corresp to same index
topic.titleRaw = topic.titleRaw + ": " + strippedContent[index] + "...";

Check failure on line 29 in src/categories/topics.js

View workflow job for this annotation

GitHub Actions / test

Unexpected string concatenation

Check failure on line 29 in src/categories/topics.js

View workflow job for this annotation

GitHub Actions / test

Strings must use singlequote

Check failure on line 29 in src/categories/topics.js

View workflow job for this annotation

GitHub Actions / test

Strings must use singlequote
topic.title = topic.title + ": " + strippedContent[index] + "...";

Check failure on line 30 in src/categories/topics.js

View workflow job for this annotation

GitHub Actions / test

Unexpected string concatenation

Check failure on line 30 in src/categories/topics.js

View workflow job for this annotation

GitHub Actions / test

Strings must use singlequote

Check failure on line 30 in src/categories/topics.js

View workflow job for this annotation

GitHub Actions / test

Strings must use singlequote
return topic;
});

topicsData = await user.blocks.filter(data.uid, topicsData);

if (!topicsData.length) {
Expand Down

0 comments on commit eed894e

Please sign in to comment.