Skip to content

Commit

Permalink
fix: handle date as array (#517)
Browse files Browse the repository at this point in the history
* fix: handle date as array

* fix: move to controller.

---------

Co-authored-by: Sebastian Thulin <[email protected]>
  • Loading branch information
sebastianthulin and Sebastian Thulin authored Feb 10, 2025
1 parent 45d8685 commit c5cb803
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
14 changes: 14 additions & 0 deletions source/php/Component/Segment/Segment.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,20 @@ public function init()
if(!$hasImage && !$hasPlaceholder) {
$this->data['classList'][] = $this->getBaseClass('no-image', true);
}

//Handle date data
if ($date && !is_array($date)) {
$this->data['date'] = [
'timestamp' => $date,
'action' => 'formatDate'
];
}

if ($date) {
$this->data['date']['classList'] ??= [];
$this->data['date']['classList'][] = $this->getBaseClass('date');
}

}

/**
Expand Down
6 changes: 1 addition & 5 deletions source/php/Component/Segment/components/content.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,7 @@
@endif

@if ($date)
@date([
'action' => false,
'timestamp' => $date,
'classList' => [$baseClass . '__date']
])
@date($date)
@enddate
@endif

Expand Down

0 comments on commit c5cb803

Please sign in to comment.