Jump to content

Soren_90

Member
  • Posts

    1
  • Joined

  • Last visited

Reputation Activity

  1. Like
    Soren_90 got a reaction from Beyondspace in Changing the date format of blog posts   
    Really helpful, thanks a lot. 
  2. Thanks
    Soren_90 reacted to Beyondspace in [FreeShare] Date display format options on all pages   
    [16-May-2023] Update
    The script has been updated, find the new solution here 
     
    Hi guys,
    Understanding the requirement to set consistently format date on all pages of website , I would like to share my solution to you .
    1. Add the following codes to Home > Settings > Advanced > Code Injection
    <!-- Fix inconsistent blog date format on Squarespace 7.1 template --> <!-- Squarespace Forum Update 06-11-2021 --> <script src="https://stevenlevithan.com/assets/misc/date.format.js"></script> <script> (function(){ document.addEventListener('DOMContentLoaded', function() { const dateformat = "dd-mm-yyyy"; const pubdates = document.querySelectorAll("time[datetime]:not([class*=event-time]), time[pubdate], time.blog-meta-item--date"); pubdates.forEach(pubDate => { let d = new Date(pubDate.getAttribute("datetime") || pubDate.innerText); if (pubDate.classList.contains('blog-meta-item--date') ) { d = new Date(document.querySelector('[itemprop="datePublished"]').getAttribute('content').split("T")[0]); } pubDate.innerHTML = d.format(dateformat); }); }); })(); </script> 2. Change the 'dateformat' in my previous code with the date format you want to apply. Ex: dd-mm-yyy, mmm-dd-yyyy,...

    Hope that it can help your sites properly
    Let me know if you have any issue that needs to be solved.
    Support me by pressing 👍 if this useful for you
  3. Thanks
    Soren_90 reacted to Romulusmap in Changing the date format of blog posts   
    Hey guys,

    I've been looking for a solution to this problem myself and since I haven't found one, I've come up with my own. It's rather crude but should be efficient, when customized to your own template. Might change with time but just hit me and I'll try to help.
    Inject it into the header and change the classes (if needed) for it to work. It's working after the page loaded so you might get a split second flash of old dates.
    First code is for English users. Just switches  order around. Second one is for international users.
     
    "//Changing blog grid view dates order."
    simply switches the display style from MM/DD/YYYY to DD/MM/YYYY. "//Changing blog detailed view  dates."
    changes language to Polish (or any other if you substitute your own 🙂), as well as switches the order around.  
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script> //Changing blog grid view dates order. $(document).ready(function() { $('time.blog-date').each(function(){ let dateArray = this.innerText.split("/"); let dateCompiled = dateArray[1] + "/" + dateArray[0] + "/" + dateArray[2]; console.log(dateCompiled); this.innerText = dateCompiled; }); //Changing blog detailed view dates. $('time.blog-meta-item--date').each(function(){ this.innerText = this.innerText.split(" ")[1] + " " + this.innerText.split(" ")[0]; }); }); </script>  
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script> //Changing blog grid view dates order. $(document).ready(function() { $('time.blog-date').each(function(){ let dateArray = this.innerText.split("/"); let dateCompiled = dateArray[1] + "/" + dateArray[0] + "/" + dateArray[2]; console.log(dateCompiled); this.innerText = dateCompiled; }); //Changing blog detailed view dates. $('time.blog-meta-item--date').each(function(){ if (this.innerText.split(" ")[0] === 'Jan'){ this.innerText = this.innerText.split(" ")[1] + ' Stycznia'; } else if (this.innerText.split(" ")[0] === 'Feb') { this.innerText = this.innerText.split(" ")[1] + ' Lutego'; } else if (this.innerText.split(" ")[0] === 'Mar') { this.innerText = this.innerText.split(" ")[1] + ' Marca'; } else if (this.innerText.split(" ")[0] === 'Apr') { this.innerText = this.innerText.split(" ")[1] + ' Kwietnia'; } else if (this.innerText.split(" ")[0] === 'May') { this.innerText = this.innerText.split(" ")[1] + ' Maja'; } else if (this.innerText.split(" ")[0] === 'June') { this.innerText = this.innerText.split(" ")[1] + ' Czerwca'; } else if (this.innerText.split(" ")[0] === 'July') { this.innerText = this.innerText.split(" ")[1] + ' Lipca'; } else if (this.innerText.split(" ")[0] === 'Aug') { this.innerText = this.innerText.split(" ")[1] + ' Sierpnia'; } else if (this.innerText.split(" ")[0] === 'Sept') { this.innerText = this.innerText.split(" ")[1] + ' Września'; } else if (this.innerText.split(" ")[0] === 'Oct') { this.innerText = this.innerText.split(" ")[1] + ' Października'; } else if (this.innerText.split(" ")[0] === 'Nov') { this.innerText = this.innerText.split(" ")[1] + ' Listopada'; } else if (this.innerText.split(" ")[0] === 'Dec') { this.innerText = this.innerText.split(" ")[1] + ' Grudnia'; } }); }); </script> If anyone needs any help with their template, feel free to ask. I'll try to help. Thanks!
  4. Like
    Soren_90 reacted to tuanphan in Adjusting the mobile breakpoint in 7.1   
    Add to Home > design > custom CSS
    @media screen and (min-width:768px) { /* hide navigation */ .header-nav { display: none; } /* Hide header button */ .header-actions { display: none; } /* show burger */ .header-burger { display: flex; } /* Show overlay mobile menu */ .header--menu-open .header-menu { opacity: 1; visibility: visible; } }  
×
×
  • 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.