Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: addign post date to archive #1317

Merged
merged 1 commit into from
Feb 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat: addign post date to archive
  • Loading branch information
NiclasNorin committed Feb 5, 2025
commit 0ba7549c1a09a309311e58b2ec64f80f1351f4d0
5 changes: 5 additions & 0 deletions library/Controller/Archive.php
Original file line number Diff line number Diff line change
@@ -12,6 +12,8 @@
*/
class Archive extends \Municipio\Controller\BaseController
{

// TODO: Remove these?
private static $gridSize;

private static $randomGridBase = array();
@@ -609,6 +611,7 @@ protected function getArchiveItems(array $posts): array
* @param array $posts The posts
* @return array The posts - with archive date
*/
// TODO: Check if needed or if some functionality is needed
public function getDate($posts, $archiveProps)
{
$preparedPosts = [];
@@ -694,6 +697,7 @@ public function tryFormatDateToUnixTimestamp(mixed $date): ?int
* Get the literal date string replace map
* @return array
*/
// TODO: Check if needed
private function getLiteralDateStringReplaceMap(): array
{
$wpService = \Municipio\Helper\WpService::get();
@@ -714,6 +718,7 @@ private function getLiteralDateStringReplaceMap(): array
* @param string $key
* @return string $dateFormat
*/
// TODO: Check if needed
private function getDateFormatString(string $key): string
{
switch ($key) {
6 changes: 3 additions & 3 deletions views/v3/partials/post/post-cards.blade.php
Original file line number Diff line number Diff line change
@@ -11,10 +11,10 @@
'tags' => $post->termsUnlinked,
'meta' => $displayReadingTime ? $post->readingTime : '',
'date' => [
'timestamp' => $post->archiveDate,
'format' => $post->archiveDateFormat
'timestamp' => $post->getArchiveDateTimestamp(),
'format' => $post->getArchiveDateFormat(),
],
'dateBadge' => $post->archiveDateFormat == 'date-badge',
'dateBadge' => $post->getArchiveDateFormat() == 'date-badge',
'context' => ['archive', 'archive.list', 'archive.list.card'],
'containerAware' => true,
'hasPlaceholder' => $anyPostHasImage && empty($post->images['thumbnail16:9']['src'])
6 changes: 3 additions & 3 deletions views/v3/partials/post/post-compressed.blade.php
Original file line number Diff line number Diff line change
@@ -22,13 +22,13 @@
</article>

<!-- Dates -->
@if(!empty($post->archiveDate))
@if(!empty($post->getArchiveDateTimestamp()))
@typography(['variant' => 'meta', 'element' => 'p', 'classList' => ['archive-compressed__date', 'u-margin__top--4']])
{{$lang->publish}}:
@date([
'action' => 'formatDate',
'timestamp' => $post->archiveDate,
'format' => $post->archiveDateFormat
'timestamp' => $post->getArchiveDateTimestamp(),
'format' => $post->getArchiveDateFormat()
])
@enddate
@endtypography
6 changes: 3 additions & 3 deletions views/v3/partials/post/post-grid.blade.php
Original file line number Diff line number Diff line change
@@ -17,10 +17,10 @@
'backgroundColor' => 'secondary'
],
'date' => [
'timestamp' => $post->archiveDate,
'format' => $post->archiveDateFormat
'timestamp' => $post->getArchiveDateTimestamp(),
'format' => $post->getArchiveDateFormat(),
],
'dateBadge' => $post->archiveDateFormat == 'date-badge',
'dateBadge' => $post->getArchiveDateFormat() == 'date-badge',
'classList' => ['t-archive-block'],
'context' => ['archive', 'archive.list', 'archive.list.block'],
])
4 changes: 2 additions & 2 deletions views/v3/partials/post/post-newsitem.blade.php
Original file line number Diff line number Diff line change
@@ -6,8 +6,8 @@
'content' => $post->excerpt,
'image' => $post->imageContract ?? $post->images['thumbnail16:9'],
'date' => [
'timestamp' => $post->archiveDate,
'format' => $post->archiveDateFormat,
'timestamp' => $post->getArchiveDateTimestamp(),
'format' => $post->getArchiveDateFormat(),
],
'readTime' => $post->readingTime,
'link' => $post->permalink,
Loading