<script lang="ts">
	import { goto } from "$app/navigation";
	import { resolve } from "$app/paths";
	import CommitLogView from "$lib/components/repo/CommitLogView.svelte";

	let { data } = $props();

	const pageHref = (page: number) =>
		resolve(
			`/${data.repo.ownerHandle}/${data.repo.name}/commits/${encodeURIComponent(data.ref)}${page > 1 ? `?page=${page}` : ""}` as "/"
		);
	const changePage = (page: number) => void goto(pageHref(page));
</script>

<CommitLogView
	ownerHandle={data.repo.ownerHandle}
	repoName={data.repo.name}
	ref={data.ref}
	commits={data.commits}
	tagsByCommit={data.tagsByCommit}
	page={data.page}
	pageCount={data.pageCount}
	onPageChange={changePage}
/>
