don't break on lowercase readmes
This commit is contained in:
parent
e4b0ebc3e1
commit
e5904927eb
|
|
@ -2,8 +2,9 @@ import { Hono } from "hono"
|
|||
import { serveStatic } from "hono/bun"
|
||||
import { render } from "preact-render-to-string"
|
||||
import { readdirSync } from "fs"
|
||||
import { Glob } from "bun"
|
||||
import { mkdir, readdir } from 'node:fs/promises'
|
||||
import { basename, join } from 'path'
|
||||
import { basename, resolve, join } from 'path'
|
||||
import { Layout } from "./components/Layout"
|
||||
import { Project } from "./components/Project"
|
||||
import { Projects } from "./components/Projects"
|
||||
|
|
@ -63,7 +64,17 @@ app.get("/p/:name", async (c) => {
|
|||
const project = await projectsWithMetadata().then(projects => projects.find(p => p.name === name))
|
||||
if (!project) return c.json({ error: 'Project not found' }, 404)
|
||||
|
||||
const readme = await Bun.file(`${PROJECTS_DIR}/${name}/README.md`).text()
|
||||
let readme = ""
|
||||
const glob = new Glob("*.md")
|
||||
const projectDir = join(PROJECTS_DIR, name)
|
||||
|
||||
for (const file of glob.scanSync(projectDir)) {
|
||||
if (/readme\.md/i.test(file)) {
|
||||
readme = await Bun.file(join(projectDir, file)).text()
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
const cubbyPath = join(CUBBY_DIR, `project_${name}`)
|
||||
let files: string[] = []
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user