Jump to content

StoriedCorey

Member
  • Posts

    50
  • Joined

  • Last visited

Reputation Activity

  1. Like
    StoriedCorey got a reaction from RyanDejaegher in Custom CSS To Limit Blog Excerpt   
    Thanks, @RyanDejaegher! Might be reaching out again. Appreciate the help! 
  2. Like
    StoriedCorey reacted to RyanDejaegher in Custom CSS To Limit Blog Excerpt   
    @StoriedCorey and @emilykrause  Add this code to Settings -> Advanced -> Code Injection -> Footer

    You can adjust the var characterCount to a different number to adjust how much it cuts off. You can also adjust the "trail".

    This code will also only cut full words, that way it doesn't cut it at weird points. i.e. "Learn more about Squaresp...."
     
    <script> (function(){ window.addEventListener('load', function() { var characterCount = 140 var blogParagraph = document.querySelectorAll('.BlogList-item-excerpt p') var trail = "..." // Shorten a string to less than maxLen characters without truncating words. function shorten(str, maxLen, separator = ' ') { if (str.length <= maxLen) return str; return str.substr(0, str.lastIndexOf(separator, maxLen)); } blogParagraph.forEach(item => { item.textContent = shorten(item.textContent, characterCount) + trail; }) }) })() </script> Result/Demo:

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.