---
import { Icon } from '@prosefly/astro-components';

interface Props {
  currentSlug?: string;
  editUrl?: string | boolean;
  markdownUrl?: string;
  pageUrl: string;
  placement?: 'aside' | 'inline';
  title: string;
}

const {
  currentSlug: _currentSlug,
  editUrl,
  markdownUrl: _markdownUrl,
  pageUrl: _pageUrl,
  placement = 'inline',
  title: _title,
} = Astro.props;
const t = Astro.locals.t;
const href = typeof editUrl === 'string' && editUrl.trim() ? editUrl : undefined;
---

{href && (
  <div class:list={[
    placement === 'aside' ? 'flex' : 'mt-2 flex justify-end',
  ]}>
    <a
      class="lotus-focus-ring inline-flex items-center gap-1.5 rounded-(--lotus-radius-sm) py-1 text-sm font-medium text-(--lotus-text-muted) transition-colors hover:text-(--lotus-text-strong)"
      href={href}
      rel="noreferrer"
      target="_blank"
    >
      <Icon aria-hidden="true" class="h-3.5 w-3.5" name="lucide:pencil" />
      <span>{t('page.editLink')}</span>
    </a>
  </div>
)}
