Kriuchko
4/19/2019 - 1:16 PM

Custom post date parse post date

\!h js
/* Blog posts custom date */
function initCustomDate() {
    $('.post-date').each(function parseDate() {
        const parsedDate = $('.original-post-date').html().split(' ');
        $(this).html(`<span class="post-date-month">${parsedDate[0]}</span><span class="post-date-day">${parsedDate[1].replace(/\D+/g, '')}</span>`);
    });
}

\!h template
<div class="post-date"><div class="original-post-date">{{post.date_published}}</div></div>

\!h css
.original-post-date {
    display: none;
}