import React from 'react'
import Link from 'next/link'

import { date } from './functions'

const Line = ({ path, pubdate, title }) => (
    <li>
        <Link href={`/${path}`}><a>{title}</a></Link>
        <span className="date"> {date(pubdate)}</span>
    </li>
)

const Changelog = ({ changes, orderBy }) => (
    <ul>
        {changes.map(ch =>
            <Line key={ch.path} {...ch} pubdate={ch[orderBy]} />)}
    </ul>
)

export default Changelog
