Jump to content

Blog collection page - move metadata to bottom + reformat date (7.1)

Go to solution Solved by Beyondspace,

Recommended Posts

  • 2 weeks later...

Hey everyone,

I've repurposed a blog into a job board and want to know if instead of just the date appearing, it can be prefaced with 'Applications Close'. When I publish the blog post/job opportunity, the publish date would be in the future, so together it would read 'Applications Close [DATE]. 

 

Thanks!

Link to comment
On 4/17/2023 at 10:03 PM, sharine said:

Hey everyone,

I've repurposed a blog into a job board and want to know if instead of just the date appearing, it can be prefaced with 'Applications Close'. When I publish the blog post/job opportunity, the publish date would be in the future, so together it would read 'Applications Close [DATE]. 

 

Thanks!

Can you share link to a blog? I guess we can use CSS pseudo to add a text before the date

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment
  • 2 weeks later...
  • 3 weeks later...

In case anyone is looking for the solution to this, I was able to fix the 'one day off' issue by changing the variable from (removing the split on the 'T') :
 

d = new Date(document.querySelector('[itemprop="datePublished"]').getAttribute("content").split("T")[0]);

to:

 

d = new Date(document.querySelector('[itemprop="datePublished"]').getAttribute("content"));

Official Squarespace Expert  |  Founder @ Winn-Brown & Co. 

👉  Get in Touch

📍 London, UK

Link to comment

Nit: The script you are using has been upgraded, check

The script will get the exact date value from timestamp and convert it into your website's timezone so it seems to be working now

Edited by Beyondspace

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox, video lightbox and much more)
🗓️ Delivery Date Picker (Squarespace Date picker form field)
💫 Gallery block 7.1 workaround
🥳 No-code customisations for Squarespace (+100 Spark plugin customisations)
🥳 Freemium Squarespace Widget Templates (+1000 Elfsight Templates)

If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you!

Link to comment
  • 1 month later...
On 3/25/2021 at 10:01 AM, Beyondspace said:

🌍 [16-May-2023] Update

The scirpt has been updated to fix some known issues, the details can be found in the post below

Live editor also available on Beyondspace.studio

〰️ 〰️ 〰️ 〰️ 〰️ 〰️ 〰️ 〰️ 〰️ 〰️ 〰️ 〰️

Update the placement using css

.blog-basic-grid--text {
    display: flex;
    flex-wrap: wrap;
}
.blog-basic-grid--text .blog-more-link {
  width: 100%;
}
.blog-basic-grid--text .blog-meta-section {
  order: 9;
}

Update the dateformat using custom code

Please add this snippet into Settings->Advanced->Code Injection to format the date the way you like it

<!-- Fix inconsistent blog date format on Squarespace 7.1 template -->
<!-- Squarespace Forum 03-08-2021 -->
<script src="https://stevenlevithan.com/assets/misc/date.format.js"></script>
<script>
	document.addEventListener('DOMContentLoaded', function() {
      var dateformat = "mm-dd-yyyy";
      var pubdate = document.querySelectorAll("time[datetime], time[pubdate], time.blog-meta-item--date");
      for (var i = 0; i < pubdate.length; i++) {
          var d = new Date(pubdate[i].getAttribute("datetime") || pubdate[i].innerText);
          if ( pubdate[i].classList.contains('blog-meta-item--date') ) {
              d = new Date(document.querySelector('[itemprop="datePublished"]').getAttribute("content").split("T")[0]);
          }
          pubdate[i].innerHTML = d.format(dateformat); 
      }
  });


</script>

 

The variable dateformat currently set with "mm-dd-yyyy", but you can change to different format (reference here)

These are some more format that supported:

"mm-dd-yyyy" --> 02-25-2021

"dd-mm-yyyy" --> 25-02-2021

"mm/dd/yyyy" --> 02/25/2021

"mmm dd yyyy" --> Feb/25/2021

image.png.b4c48c3129f85d74e8a7b01013d54c47.png

Hello..

I tried using this code but it didn't work. Maybe because I have a code injection of:

<style>

.blog-meta-item--tags {
  display: none;
}

  </style>

I tried putting it on the top and inside of <style> and</style> but it didn't work so I just deleted it. 

Is there any workaround for that?

Website Post Sample: https://perhapsmybe.com/post/drowning

 

UPDATE: Solution found here:
 

 

Edited by perhapsmybe
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • 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.