GHHG10's picture
download
raw
916 Bytes
import type { APIRoute } from "astro"
import { getCollection } from "astro:content"
function notFoundText(locals: unknown) {
if (typeof locals !== "object" || locals === null || !("t" in locals)) {
return "share.not_found"
}
const t = (locals as { t?: unknown }).t
if (typeof t !== "function") {
return "share.not_found"
}
const text = t("share.not_found")
if (typeof text === "string" && text.length > 0) {
return text
}
return "share.not_found"
}
export const GET: APIRoute = async ({ params, locals }) => {
const slug = params.slug || "index"
const docs = await getCollection("docs")
const doc = docs.find((d) => d.id === slug)
const notFound = notFoundText(locals)
if (!doc) {
return new Response(notFound, { status: 404, statusText: notFound })
}
return new Response(doc.body, {
headers: {
"Content-Type": "text/plain; charset=utf-8",
},
})
}

Xet Storage Details

Size:
916 Bytes
·
Xet hash:
43dba31e9bc1fa4e876c8f22db26bc1675fab5e6cc6d59c86e592b1d579df7f1

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.