blogpost.postSummary and filters

I’m getting a summary of blog posts to related blog posts.

However, when I use:

${blogpost.postSummary|striptags|safe|truncate(200)}

I get nothing. Actually, I don’t even get titles and images anymore.

If I remove filters, it breaks my layout. Funnily this same code works very nicely with

{ content.post_summary|striptags|safe|truncate(200) }

Which is not course content I want to related blog posts.

Whole code looks like this:

 {% related_blog_posts limit=3, callback="blog_post_formatter" %}

<script>
 var blog_post_formatter = function(blogposts) {

 var formatted = '<div class="blog-listing">';
 for (var i = 0; i < blogposts.length; i++) {
 var blogpost = blogposts[i];
 formatted += `<a href="${blogpost.url}" class="article display-flex flex-direction-column">`;
 formatted += '<div class="article-image">';
 if (blogpost.featuredImage) {
 formatted += `<img src="${blogpost.featuredImage}" alt="${blogpost.featuredImageAltText}">`;
 }
 formatted += '</div>';
 formatted += '<div class="article-content display-flex flex-direction-column flex-grow-1">';
 formatted += `<h2>${blogpost.name}</h2>`;
 formatted += `<p class="article-summary flex-grow-1">${blogpost.postSummary|striptags|safe|truncate(200)}</p>`; 
 formatted += `<h5>${blogpost.blogAuthor.fullName}</h5>`;
 formatted += '</div></a>';
 }
 formatted += '</div>';
 return formatted;
 }
</script> 

Do you have any suggestions on how to get summaries working?

Hi, @KTakki :waving_hand: Thanks for your question. I’d like to invite some of our community to the conversation — hey @albertsg @alyssamwilie @BarryGrennan how would you handle this?

Thank you for taking a look! — Jaycee

I know this is an older post, but this is the solution I came up with:

formatted += '<div class="blog-listing__post-summary">' var truncatedSummary = blogpost.postSummary.replace(/<[^>]*>/g, '').substring(0, 200);formatted += '<p class="related-blog-post-summary">' + truncatedSummary + '</p>';formatted += '</div>';

Some Hubl code comes through, if there is a video set as the first thing on the page, but other than that, everything works.

Hope it helps anyone else looking for this solution.