chore: added better date formatting to post lists
85a9a123
3 file(s) · +10 −24
| 39 | 39 | <footer class="footer"> |
|
| 40 | 40 | {{ footer_html|safe }} |
|
| 41 | 41 | </footer> |
|
| 42 | + | <script> |
|
| 43 | + | document.querySelectorAll('.post-date').forEach(el => { |
|
| 44 | + | const d = new Date(el.textContent.trim()); |
|
| 45 | + | if (!isNaN(d)) { |
|
| 46 | + | const day = String(d.getDate()).padStart(2, '0'); |
|
| 47 | + | const mon = d.toLocaleString('en-US', { month: 'short' }); |
|
| 48 | + | el.textContent = `${day} ${mon}, ${d.getFullYear()}`; |
|
| 49 | + | } |
|
| 50 | + | }); |
|
| 51 | + | </script> |
|
| 42 | 52 | </body> |
|
| 43 | 53 | </html> |
| 26 | 26 | <a href="/posts/{{ post.slug }}" class="post-item"> |
|
| 27 | 27 | <div class="post-item-info"> |
|
| 28 | 28 | <span class="post-title">{{ post.title }}</span> |
|
| 29 | - | {% if post.tags.is_some() %} |
|
| 30 | - | <span class="post-tags"> |
|
| 31 | - | {% for tag in post.tags.as_deref().unwrap_or_default().split(',') %} |
|
| 32 | - | {% if !tag.trim().is_empty() %} |
|
| 33 | - | <span class="tag">{{ tag.trim() }}</span> |
|
| 34 | - | {% endif %} |
|
| 35 | - | {% endfor %} |
|
| 36 | - | </span> |
|
| 37 | - | {% endif %} |
|
| 38 | 29 | </div> |
|
| 39 | 30 | {% if post.published_date.is_some() %} |
|
| 40 | 31 | <time class="post-date">{{ post.published_date.as_deref().unwrap_or_default() }}</time> |
| 18 | 18 | <a href="/posts/{{ post.slug }}" class="post-item post-item-enhanced"> |
|
| 19 | 19 | <div class="post-item-info"> |
|
| 20 | 20 | <span class="post-title">{{ post.title }}</span> |
|
| 21 | - | {% if post.meta_description.is_some() %} |
|
| 22 | - | {% let desc = post.meta_description.as_deref().unwrap_or_default() %} |
|
| 23 | - | {% if !desc.is_empty() %} |
|
| 24 | - | <span class="post-excerpt">{{ desc }}</span> |
|
| 25 | - | {% endif %} |
|
| 26 | - | {% endif %} |
|
| 27 | - | {% if post.tags.is_some() %} |
|
| 28 | - | <span class="post-tags"> |
|
| 29 | - | {% for tag in post.tags.as_deref().unwrap_or_default().split(',') %} |
|
| 30 | - | {% if !tag.trim().is_empty() %} |
|
| 31 | - | <span class="tag">{{ tag.trim() }}</span> |
|
| 32 | - | {% endif %} |
|
| 33 | - | {% endfor %} |
|
| 34 | - | </span> |
|
| 35 | - | {% endif %} |
|
| 36 | 21 | </div> |
|
| 37 | 22 | {% if post.published_date.is_some() %} |
|
| 38 | 23 | <time class="post-date">{{ post.published_date.as_deref().unwrap_or_default() }}</time> |