1

I'm building a CMS and the content of a post is saved in HTML in the database.

On the page that lists posts, I would like to show the first n words / n characters, for the short version of the post with a "read more" button.

What would be the best way to strip the text from the HTML the right way, without making it look al weird?

2

1 Answer 1

3

you can try use the library html-to-text (npm install html-to-text). Split all text and show the n array elements.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.