Skip to content

Commit

Permalink
Merge pull request #542 from helsingborg-stad/fix/post-dates-format
Browse files Browse the repository at this point in the history
fix: correct post date formates
  • Loading branch information
Anna authored Nov 23, 2023
2 parents 2e398ea + 0a51114 commit 68b198c
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion source/php/Module/Posts/Posts.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ public static function getManualInputPosts($data, bool $stripLinksFromContent =
'src' => $imageSquare['src'],
'alt' => $imageSquare['alt']
] : false,
'postDate' => null,
'postDateFormatted' => null,
'termsUnlinked' => null,
'dateBadge' => false,
'termIcon' => false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ public function setPostFlags(&$post)
$post->showDate = true;
$eventOccasions = get_post_meta($post->id, 'occasions_complete', true);
if (!empty($eventOccasions)) {
$post->postDate = $eventOccasions[0]['start_date'];
$post->postDateFormatted = $eventOccasions[0]['start_date'];
$post->dateBadge = true;
} else {
$post->postDate = false;
$post->postDateFormatted = false;
}
}

if (empty($post->showDate)) {
$post->postDate = false;
$post->postDateFormatted = false;
}
}

Expand Down
4 changes: 2 additions & 2 deletions source/php/Module/Posts/views/grid.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
'content' => isset($post->showExcerpt) ? $post->excerptShort : '',
'meta' => $display_reading_time ? $post->readingTime : false,
'tags' => !empty($post->termsUnlinked) ? $post->termsUnlinked : false,
'date' => $post->postDate,
'date' => $post->postDateFormatted,
'dateBadge' => !empty($post->dateBadge) ? $post->dateBadge : false,
'containerAware' => true,
'hasAction' => true,
Expand Down Expand Up @@ -47,7 +47,7 @@
'ratio' => $ratio,
'meta' => !empty($post->termsUnlinked) ? $post->termsUnlinked : false,
'secondaryMeta' => !empty($display_reading_time) ? $post->readingTime : false,
'date' => !empty($post->postDate) ? $post->postDate : false,
'date' => !empty($post->postDateFormatted) ? $post->postDateFormatted : false,
'dateBadge' => !empty($post->dateBadge) ? $post->dateBadge : false,
'filled' => true,
'image' => !empty($post->showImage)
Expand Down
4 changes: 2 additions & 2 deletions source/php/Module/Posts/views/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
'ratio' => '16:9',
'meta' => !empty($post->termsUnlinked) ? $post->termsUnlinked : false,
'secondary_meta' => $display_reading_time ? $post->readingTime : false,
'date' => !empty($post->postDate) ? $post->postDate : false,
'date' => !empty($post->postDateFormatted) ? $post->postDateFormatted : false,
'dateBadge' => !empty($post->dateBadge) ? $post->dateBadge : false,
'filled' => true,
'image' =>
Expand Down Expand Up @@ -51,7 +51,7 @@
'content' => !empty($post->showExcerpt) ? $post->excerptShort : false,
'tags' => !empty($post->termsUnlinked) ? $post->termsUnlinked : false,
'meta' => !empty($display_reading_time) ? $post->readingTime : false,
'date' => !empty($post->postDate) ? $post->postDate : false,
'date' => !empty($post->postDateFormatted) ? $post->postDateFormatted : false,
'dateBadge' => !empty($post->dateBadge) ? $post->dateBadge : false,
'classList' => $display_reading_time ? ['c-card--with-reading-time', 'u-height--100'] : ['u-height--100'],
'containerAware' => true,
Expand Down
4 changes: 2 additions & 2 deletions source/php/Module/Posts/views/partials/date.blade.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
@if($post->postDate)
@if($post->postDateFormatted)
@typography(['variant' => 'meta', 'element' => 'span', 'classList' => [$baseClass . '__date']])
@group
@icon(['icon' => 'date_range', 'size' => 'sm'])
@endicon
@date([
'action' => 'formatDate',
'timestamp' => $post->postDate
'timestamp' => $post->postDateFormatted
])
@enddate
@endgroup
Expand Down
2 changes: 1 addition & 1 deletion source/php/Module/Posts/views/partials/post/box.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
'link' => $post->permalink,
'meta' => $post->termsUnlinked,
'secondaryMeta' => $display_reading_time ? $post->readingTime : false,
'date' => $post->postDate,
'date' => $post->postDateFormatted,
'ratio' => $ratio,
'image' => $post->showImage
? [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'content' => ($post->showExcerpt ? $post->excerptShort : false),
'ratio' => $ratio,
'meta' => $post->termsUnlinked,
'date' => $post->postDate,
'date' => $post->postDateFormatted,
'dateBadge' => $post->dateBadge,
'filled' => true,
'image' => ($post->showImage ? [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
'heading' => !empty($post->showTitle) ? $post->postTitle : false,
'content' => !empty($post->showExcerpt) ? $post->excerptShort : false,
'classList' => [$classes, 'u-color__text--info', 'c-card--focus-inset'],
'date' => $post->postDate,
'date' => $post->postDateFormatted,
'dateBadge' => $post->dateBadge,
'containerAware' => false,
'hasAction' => true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
'tags' => !empty($post->termsUnlinked) ? $post->termsUnlinked : false,
'image' => !empty($post->thumbnail['src']) ? $post->thumbnail['src'] : false,
'content' => !empty($post->showExcerpt) ? $post->excerptShort : false,
'date' => !empty($post->postDate) ? $post->postDate : false,
'date' => !empty($post->postDateFormatted) ? $post->postDateFormatted : false,
'dateBadge' => !empty($post->dateBadge) ? $post->dateBadge : false,
'buttons' => [['text' => $labels['readMore'], 'href' => $post->permalink, 'color' => 'primary']],
'containerAware' => true,
Expand Down
2 changes: 1 addition & 1 deletion source/php/Module/Posts/views/segment.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
'meta' => !empty($display_reading_time) ? $post->readingTime : false,
'tags' => !empty($post->termsUnlinked) ? $post->termsUnlinked : false,
'image' => !empty($post->thumbnail['src']) ? $post->thumbnail['src'] : false,
'date' => $post->postDate,
'date' => $post->postDateFormatted,
'dateBadge' => !empty($post->dateBadge) ? $post->dateBadge : false,
'content' => !empty($post->showExcerpt) ? $post->excerptShort : false,
'buttons' => [['text' => $labels['readMore'], 'href' => $post->permalink, 'color' => 'primary']],
Expand Down

0 comments on commit 68b198c

Please sign in to comment.