Luke Jones

lukeonline - commit 48e84cd

fix: file traversal navigation48e84cdc86fb8570c6fd231f51edd2bdb1dadeeaLukeJ<luke.jones.2567@gmail.com>2026-09-29T22:15:01+01:00
diff --git a/src/pages/projects/[name].astro b/src/pages/projects/[name].astro index 6c466c2..f6f9c13 100644 --- a/src/pages/projects/[name].astro +++ b/src/pages/projects/[name].astro @@ -43,7 +43,7 @@ function getReadMeContent() { <Base title={repo.data.name}> <div class="flex flex-row items-baseline gap-2"> - <code class="text-sm">{repo.data.defaultBranch}</code> + <code class="text-sm"><a href={`/projects/${repo.data.name}`}>{repo.data.defaultBranch}</a></code> <a class={BUTTON_STYLING_SHARED + ' h-8 p-1 pl-2 items-center gap-3'} href={`/projects/${repo.data.name}/commits`} diff --git a/src/pages/projects/[name]/commits/index.astro b/src/pages/projects/[name]/commits/index.astro index 10edaa1..932589c 100644 --- a/src/pages/projects/[name]/commits/index.astro +++ b/src/pages/projects/[name]/commits/index.astro @@ -2,7 +2,8 @@ import Base from '../../../../layouts/Base.astro' import { getCollection } from 'astro:content' -import { getCommits } from '../../../../lib/repos' +import { getCommits, getTree } from '../../../../lib/repos' +import { BUTTON_STYLING_SHARED, DISABLED_BUTTON_STYLING_SHARED } from '../../../../consts.ts' export async function getStaticPaths() { const repos = await getCollection('repos') @@ -11,36 +12,79 @@ export async function getStaticPaths() { params: { name: repo.data.name, }, + props: { + repo, + }, })) } +const { repo } = Astro.props const { name } = Astro.params + const commits = getCommits(name!) +const tree = getTree(name!) --- <Base title={`${name}`}> + <div class="flex flex-row items-baseline gap-2"> + <code class="text-sm"><a href={`/projects/${name}`}>{repo.data.defaultBranch}</a></code> + + <a + class={DISABLED_BUTTON_STYLING_SHARED + ' h-8 p-1 pl-2 items-center gap-3'} + aria-disabled="true" + > + {repo.data.commitCount} commits + </a> + + <a + class={BUTTON_STYLING_SHARED + ' h-8 p-1 pl-2 items-center gap-3'} + href={`/projects/${name}/files`} + > + {tree.length} files + </a> + + <a + class={BUTTON_STYLING_SHARED + ' h-8 p-1 pl-2 items-center gap-3'} + href={`/projects/${name}/file/README.md`} + > + README + </a> + + <a + class={BUTTON_STYLING_SHARED + ' h-8 p-1 pl-2 items-center gap-3'} + href={`/projects/${name}/file/LICENSE`} + > + LICENSE + </a> + </div> + <table class="w-full"> - <tr> - <th class="text-left">sha</th> - <th class="text-left">Message</th> - <th class="text-left">Date</th> - </tr> - { - commits.reverse().map((commit) => ( - <tr> - <td class="max-w-12 min-w-12"> - <a href={`/projects/${name}/commit/${commit.sha}`}> - <code class="text-sm">{commit.shortSha}</code> - </a> - </td> - <td class="whitespace-nowrap overflow-hidden max-w-72 text-ellipsis"> - <code class="text-sm">{commit.message}</code> - </td> - <td> - {new Date(commit.date).toLocaleDateString()} - </td> - </tr> - )) - } + <thead> + <tr> + <th class="text-left">sha</th> + <th class="text-left">Message</th> + <th class="text-left">Date</th> + </tr> + </thead> + + <tbody> + { + [...commits].reverse().map((commit) => ( + <tr> + <td class="max-w-12 min-w-12"> + <a href={`/projects/${name}/commit/${commit.sha}`}> + <code class="text-sm">{commit.shortSha}</code> + </a> + </td> + + <td class="max-w-72 overflow-hidden text-ellipsis whitespace-nowrap"> + <code class="text-sm">{commit.message}</code> + </td> + + <td>{new Date(commit.date).toLocaleDateString()}</td> + </tr> + )) + } + </tbody> </table> </Base> diff --git a/src/pages/projects/[name]/files/[...path].astro b/src/pages/projects/[name]/files/[...path].astro index b4cf90f..c8db89a 100644 --- a/src/pages/projects/[name]/files/[...path].astro +++ b/src/pages/projects/[name]/files/[...path].astro @@ -2,6 +2,7 @@ import { getCollection } from 'astro:content' import { getTree } from '../../../../lib/repos' import Base from '../../../../layouts/Base.astro' +import { BUTTON_STYLING_SHARED, DISABLED_BUTTON_STYLING_SHARED } from '../../../../consts.ts' export async function getStaticPaths() { const repos = await getCollection('repos') @@ -65,6 +66,29 @@ const directories = [ --- <Base title={`${repo.data.name} - ${directory}`}> + <div class="flex flex-row items-baseline gap-2"> + <code class="text-sm"><a href={`/projects/${repo.data.name}`}>{repo.data.defaultBranch}</a></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 + > + <a + class={BUTTON_STYLING_SHARED + ' h-8 p-1 pl-2 items-center gap-3'} + href={`/projects/${repo.data.name}/files`} + >{tree.length} files</a + > + <a + class={BUTTON_STYLING_SHARED + ' h-8 p-1 pl-2 items-center gap-3'} + href={`/projects/${repo.data.name}/file/README.md`} + >README</a + > + <a + class={BUTTON_STYLING_SHARED + ' h-8 p-1 pl-2 items-center gap-3'} + href={`/projects/${repo.data.name}/file/LICENSE`} + >LICENSE</a + > + </div> <div class="flex flex-col rounded-sm p-2 font-mono text-sm whitespace-pre-line ring inset-shadow-sm ring-gray-600 inset-shadow-gray-400" > diff --git a/src/pages/projects/[name]/files/index.astro b/src/pages/projects/[name]/files/index.astro index 580d7a2..bd6d6c6 100644 --- a/src/pages/projects/[name]/files/index.astro +++ b/src/pages/projects/[name]/files/index.astro @@ -2,6 +2,7 @@ import { getCollection } from 'astro:content' import { getTree } from '../../../../lib/repos' import Base from '../../../../layouts/Base.astro' +import { BUTTON_STYLING_SHARED, DISABLED_BUTTON_STYLING_SHARED } from '../../../../consts.ts' export async function getStaticPaths() { const repos = await getCollection('repos') @@ -34,6 +35,29 @@ const directories = [ --- <Base title={repo.data.name}> + <div class="flex flex-row items-baseline gap-2"> + <code class="text-sm"><a href={`/projects/${repo.data.name}`}>{repo.data.defaultBranch}</a></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 + > + <a + class={BUTTON_STYLING_SHARED + ' h-8 p-1 pl-2 items-center gap-3'} + href={`/projects/${repo.data.name}/files`} + >{tree.length} files</a + > + <a + class={BUTTON_STYLING_SHARED + ' h-8 p-1 pl-2 items-center gap-3'} + href={`/projects/${repo.data.name}/file/README.md`} + >README</a + > + <a + class={BUTTON_STYLING_SHARED + ' h-8 p-1 pl-2 items-center gap-3'} + href={`/projects/${repo.data.name}/file/LICENSE`} + >LICENSE</a + > + </div> <div class="flex flex-col rounded-sm p-2 font-mono text-sm whitespace-pre-line ring inset-shadow-sm ring-gray-600 inset-shadow-gray-400" >