lukeonline - commit 7b6c56b
feat: basic repository library for pulling in commit details7b6c56b71d34a6e7a34ee981b61e8be72c1c50daLukeJ<luke.jones.2567@gmail.com>2026-09-29T21:00:26+01:00diff --git a/src/lib/repos.ts b/src/lib/repos.ts
new file mode 100644
index 0000000..092dd94
--- /dev/null
+++ b/src/lib/repos.ts
@@ -0,0 +1,56 @@
+import fs from 'node:fs'
+import path from 'node:path'
+
+const reposRoot = path.join(process.cwd(), 'src/content/repos')
+
+export interface Repo {
+ name: string
+ head: string
+ defaultBranch: string
+ branches: string[]
+ tags: string[]
+ commitCount: number
+}
+
+export interface Commit {
+ sha: string
+ shortSha: string
+ parents: string[]
+ author: {
+ name: string
+ email: string
+ }
+ date: string
+ message: string
+}
+
+export interface RepoFile {
+ path: string
+ mode: string
+ type: string
+ sha: string
+}
+
+export function getCommits(name: string): Commit[] {
+ const file = path.join(reposRoot, name, 'commits.json')
+
+ return JSON.parse(fs.readFileSync(file, 'utf-8'))
+}
+
+export function getTree(name: string): RepoFile[] {
+ const file = path.join(reposRoot, name, 'tree.json')
+
+ return JSON.parse(fs.readFileSync(file, 'utf-8'))
+}
+
+export function getCommit(name: string, sha: string) {
+ const file = path.join(reposRoot, name, 'commits', `${sha}.json`)
+
+ return JSON.parse(fs.readFileSync(file, 'utf-8'))
+}
+
+export function getFile(name: string, encodedPath: string) {
+ const file = path.join(reposRoot, name, 'files', `${encodedPath}.json`)
+
+ return JSON.parse(fs.readFileSync(file, 'utf-8'))
+}