Luke Jones

lukeonline - commit 3d4a30b

refactor: move commit listing into unqiue page3d4a30bb16864a31bc3779a9b016a9350aa72363LukeJ<luke.jones.2567@gmail.com>2026-09-29T21:13:37+01:00
diff --git a/src/pages/projects/[name].astro b/src/pages/projects/[name].astro index bcc4ebe..c74f801 100644 --- a/src/pages/projects/[name].astro +++ b/src/pages/projects/[name].astro @@ -3,6 +3,7 @@ import Base from '../../layouts/Base.astro' import { getCollection } from 'astro:content' import { getCommits, getTree } from '../../lib/repos' +import { BUTTON_STYLING_SHARED } from '../../consts.ts' export async function getStaticPaths() { const repos = await getCollection('repos') @@ -19,13 +20,13 @@ export async function getStaticPaths() { const { repo } = Astro.props -const commits = getCommits(repo.data.name) const tree = getTree(repo.data.name) --- <Base title={repo.data.name}> - <div> - default: <strong>{repo.data.defaultBranch}</strong> | <a href={`/projects/${repo.data.name}/commits`}>{repo.data.commitCount} commits</a> + <div class="flex flex-row items-baseline gap-2"> + <code class="text-sm">{repo.data.defaultBranch}</code> + <a class={BUTTON_STYLING_SHARED + ' h-8 p-1 pl-2 items-center gap-3'} href={`/projects/${repo.data.name}/commits`}>{repo.data.commitCount} commits</a> </div> <div class="flex flex-col ring ring-gray-600 rounded-sm p-2 inset-shadow-sm inset-shadow-gray-400"> { @@ -38,16 +39,4 @@ const tree = getTree(repo.data.name) )) } </div> - <div class="flex flex-col"> - { - commits - .slice(-10) - .reverse() - .map((commit) => ( - <a href={`/projects/${repo.data.name}/commit/${commit.sha}`}> - <code class="text-sm">{commit.shortSha} {commit.message}</code> - </a> - )) - } - </div> </Base> diff --git a/src/pages/projects/[name]/commits/index.astro b/src/pages/projects/[name]/commits/index.astro new file mode 100644 index 0000000..048b2ae --- /dev/null +++ b/src/pages/projects/[name]/commits/index.astro @@ -0,0 +1,44 @@ +--- +import Base from '../../../../layouts/Base.astro' + +import { getCollection } from 'astro:content' +import { getCommits } from '../../../../lib/repos' + +export async function getStaticPaths() { + const repos = await getCollection('repos') + + return repos.map((repo) => ({ + params: { + name: repo.data.name, + }, + })) +} + +const { name } = Astro.params +const commits = getCommits(name!) +--- + +<Base title={`${name}`}> + <table> + { + commits.reverse().map((commit) => ( + <tr> + <td> + <a href={`/projects/${name}/commit/${commit.sha}`}> + <code class="text-sm">{commit.shortSha}</code> + </a> + </td> + <td class="overflow-hidden text-ellipsis"> + <code class="text-sm">{commit.message}</code> + </td> + <td> + <code class="text-sm">{commit.author.name}</code> + </td> + <td> + <code class="text-sm">{commit.date}</code> + </td> + </tr> + )) + } + </table> +</Base> diff --git a/src/pages/projects/index.astro b/src/pages/projects/index.astro index af6b15a..dae7113 100644 --- a/src/pages/projects/index.astro +++ b/src/pages/projects/index.astro @@ -13,7 +13,6 @@ const contentData = repos.map((repo) => ({ title: `${repo.data.name}`, link: `${repoUrl}${repo.data.name}`, })) -console.log(repos) --- <ContentList title={title} content={contentData} />