<?php

declare(strict_types=1);



class LastUpdatedWidget extends Widget
{
    public function code(): string
    {
        return 'last_updated';
    }

    public function name(): string
    {
        return 'Last updated';
    }

    public function description(): string
    {
        return "Shows this page's real last-revised date — it updates automatically whenever you edit the page.";
    }

    public function icon(): string
    {
        return 'fa-solid fa-clock-rotate-left';
    }

    public function render(array $ctx): string
    {
        $page = $ctx['page'] ?? null;
        $date = is_array($page) ? ($page['updated_at'] ?? $page['created_at'] ?? null) : null;

        return $this->partial('last-updated', ['date' => $date]);
    }
}
