Skip to content

Commit

Permalink
upgrade vitepress to rc15
Browse files Browse the repository at this point in the history
  • Loading branch information
Pistonight committed Sep 23, 2023
1 parent b7e1d29 commit 6461639
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ tasks:
- txtpp verify -r
- bunx vitepress build src

serve:
desc: Serve the built app locally
cmds:
- bun serve.ts

nvim:
desc: Copy nvim configs from home to repo
cmds:
Expand Down
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"dependencies": {},
"devDependencies": {
"vitepress": "^1.0.0-rc.12",
"vitepress": "^1.0.0-rc.15",
"vue": "^3.3.4"
}
}
32 changes: 32 additions & 0 deletions serve.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const PORT = 3000;
console.log("Serving on port", PORT);

const fs = require("fs");

Bun.serve({
port: PORT,
fetch: async (req) => {
const host = req.headers.get("host");
const url = req.url;
const path = url.split(host)[1];
console.log(path)
if (path === "/") {
return new Response(Bun.file("src/.vitepress/dist/index.html"))
}
const file0 = `src/.vitepress/dist${path}`
if (path.endsWith("/") || path.endsWith(".html")) {
return new Response(Bun.file(file0))
}
if (fs.existsSync(file0)) {
return new Response(Bun.file(file0))
}

const file1 = `src/.vitepress/dist${path}/index.html`
if (fs.existsSync(file1)) {
return new Response(Bun.file(file1))
}
const file2 = `src/.vitepress/dist${path}.html`

return new Response(Bun.file(file2))
}
})

0 comments on commit 6461639

Please sign in to comment.