Support compiling static assets, add compile task
This commit is contained in:
parent
cea96e170d
commit
2ac3180c0f
@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
"tasks": {
|
"tasks": {
|
||||||
"dev": "deno run --allow-all --watch server.ts",
|
"dev": "deno run --allow-all --watch server.ts",
|
||||||
"server": "deno run --allow-all server.ts"
|
"server": "deno run --allow-all server.ts",
|
||||||
|
"compile": "deno compile --allow-all --include ./assets/ --output substr server.ts"
|
||||||
},
|
},
|
||||||
"imports": {
|
"imports": {
|
||||||
"@deno/gfm": "jsr:@deno/gfm@^0.9.0",
|
"@deno/gfm": "jsr:@deno/gfm@^0.9.0",
|
||||||
|
@ -85,6 +85,7 @@ router.get("/:username/:identifier", async (ctx) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
router.get("/assets/:path*", async (ctx) => {
|
router.get("/assets/:path*", async (ctx) => {
|
||||||
|
console.log(import.meta.dirname);
|
||||||
try {
|
try {
|
||||||
let filePath = ctx.params.path || "";
|
let filePath = ctx.params.path || "";
|
||||||
let root: string;
|
let root: string;
|
||||||
@ -93,7 +94,7 @@ router.get("/assets/:path*", async (ctx) => {
|
|||||||
filePath = filePath.replace(/^g\//, "");
|
filePath = filePath.replace(/^g\//, "");
|
||||||
root = "/tmp/substr";
|
root = "/tmp/substr";
|
||||||
} else {
|
} else {
|
||||||
root = `${Deno.cwd()}/assets`;
|
root = `${import.meta.dirname}/assets`;
|
||||||
}
|
}
|
||||||
|
|
||||||
await send(ctx, filePath, { root });
|
await send(ctx, filePath, { root });
|
||||||
|
Loading…
x
Reference in New Issue
Block a user