---
import '../css/prevnext.css';
import { metadata } from '../include/SiteConfig.js';
import PrevNextLink from './PrevNextLink.astro';

const { seq, pages } = Astro.props;

const prevPage = seq
  ? pages.filter((p) => p.data.sequence === seq - 1)[0]
  : null;
const nextPage = seq
  ? pages.filter((p) => p.data.sequence === seq + 1)[0]
  : null;
---

{
  seq && (
    <nav class="prevnext" aria-label="Next and previous">
      <span class="prev">
        <PrevNextLink page={prevPage} rel="prev">
          Back
        </PrevNextLink>
      </span>
      <span class="contents">
        <a href={`/${metadata.version}/contents/`}>Contents</a>
      </span>
      <span class="next">
        <PrevNextLink page={nextPage} rel="next">
          Next
        </PrevNextLink>
      </span>
    </nav>
  )
}
