Skip to content

Commit dc6f91c

Browse files
authored
Merge pull request #1317 from helsingborg-stad/feat/adding-post-date-to-archive
feat: addign post date to archive
2 parents dbf992f + 0ba7549 commit dc6f91c

File tree

5 files changed

+16
-11
lines changed

5 files changed

+16
-11
lines changed

library/Controller/Archive.php

+5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
*/
1313
class Archive extends \Municipio\Controller\BaseController
1414
{
15+
16+
// TODO: Remove these?
1517
private static $gridSize;
1618

1719
private static $randomGridBase = array();
@@ -609,6 +611,7 @@ protected function getArchiveItems(array $posts): array
609611
* @param array $posts The posts
610612
* @return array The posts - with archive date
611613
*/
614+
// TODO: Check if needed or if some functionality is needed
612615
public function getDate($posts, $archiveProps)
613616
{
614617
$preparedPosts = [];
@@ -694,6 +697,7 @@ public function tryFormatDateToUnixTimestamp(mixed $date): ?int
694697
* Get the literal date string replace map
695698
* @return array
696699
*/
700+
// TODO: Check if needed
697701
private function getLiteralDateStringReplaceMap(): array
698702
{
699703
$wpService = \Municipio\Helper\WpService::get();
@@ -714,6 +718,7 @@ private function getLiteralDateStringReplaceMap(): array
714718
* @param string $key
715719
* @return string $dateFormat
716720
*/
721+
// TODO: Check if needed
717722
private function getDateFormatString(string $key): string
718723
{
719724
switch ($key) {

views/v3/partials/post/post-cards.blade.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
'tags' => $post->termsUnlinked,
1212
'meta' => $displayReadingTime ? $post->readingTime : '',
1313
'date' => [
14-
'timestamp' => $post->archiveDate,
15-
'format' => $post->archiveDateFormat
14+
'timestamp' => $post->getArchiveDateTimestamp(),
15+
'format' => $post->getArchiveDateFormat(),
1616
],
17-
'dateBadge' => $post->archiveDateFormat == 'date-badge',
17+
'dateBadge' => $post->getArchiveDateFormat() == 'date-badge',
1818
'context' => ['archive', 'archive.list', 'archive.list.card'],
1919
'containerAware' => true,
2020
'hasPlaceholder' => $anyPostHasImage && empty($post->images['thumbnail16:9']['src'])

views/v3/partials/post/post-compressed.blade.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
</article>
2323

2424
<!-- Dates -->
25-
@if(!empty($post->archiveDate))
25+
@if(!empty($post->getArchiveDateTimestamp()))
2626
@typography(['variant' => 'meta', 'element' => 'p', 'classList' => ['archive-compressed__date', 'u-margin__top--4']])
2727
{{$lang->publish}}:
2828
@date([
2929
'action' => 'formatDate',
30-
'timestamp' => $post->archiveDate,
31-
'format' => $post->archiveDateFormat
30+
'timestamp' => $post->getArchiveDateTimestamp(),
31+
'format' => $post->getArchiveDateFormat()
3232
])
3333
@enddate
3434
@endtypography

views/v3/partials/post/post-grid.blade.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
'backgroundColor' => 'secondary'
1818
],
1919
'date' => [
20-
'timestamp' => $post->archiveDate,
21-
'format' => $post->archiveDateFormat
20+
'timestamp' => $post->getArchiveDateTimestamp(),
21+
'format' => $post->getArchiveDateFormat(),
2222
],
23-
'dateBadge' => $post->archiveDateFormat == 'date-badge',
23+
'dateBadge' => $post->getArchiveDateFormat() == 'date-badge',
2424
'classList' => ['t-archive-block'],
2525
'context' => ['archive', 'archive.list', 'archive.list.block'],
2626
])

views/v3/partials/post/post-newsitem.blade.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
'content' => $post->excerpt,
77
'image' => $post->imageContract ?? $post->images['thumbnail16:9'],
88
'date' => [
9-
'timestamp' => $post->archiveDate,
10-
'format' => $post->archiveDateFormat,
9+
'timestamp' => $post->getArchiveDateTimestamp(),
10+
'format' => $post->getArchiveDateFormat(),
1111
],
1212
'readTime' => $post->readingTime,
1313
'link' => $post->permalink,

0 commit comments

Comments
 (0)