File tree Expand file tree Collapse file tree 3 files changed +0
-59
lines changed
Expand file tree Collapse file tree 3 files changed +0
-59
lines changed Original file line number Diff line number Diff line change @@ -4,24 +4,6 @@ import {
44import { contentType } from "https://deno.land/std@0.206.0/media_types/content_type.ts"
55import { transpile } from "./src/transpile.ts"
66
7- import {
8- relative ,
9- join ,
10- normalize ,
11- fromFileUrl ,
12- } from "https://deno.land/std@0.224.0/path/mod.ts"
13-
14- const cwd = Deno . cwd ( )
15- const scriptDir = join ( fromFileUrl ( import . meta. url ) , ".." )
16- console . log ( { cwd, scriptDir} )
17- const relPath = normalize ( relative ( scriptDir , cwd ) )
18-
19- const relImport = async ( path : string ) => {
20- const adjustedPath = join ( relPath , path ) . replaceAll ( "\\" , "/" )
21-
22- return await import ( "./" + adjustedPath )
23- }
24-
257const getFile = async ( filepath : string ) =>
268 await Deno . open (
279 filepath ,
@@ -84,38 +66,8 @@ async (filepath: string, url: URL) => {
8466 }
8567}
8668
87- const htmlPreset =
88- ( body : string ) => `<!doctype html><html>
89- <head>
90- <meta charset="UTF-8">
91- </head>
92- <body>
93- ${ body }
94- </body>
95- </html>`
96-
97- let cacheBuster = 0
98-
9969Deno . serve ( handler ( {
10070 ts : handleTs ,
101- async tsx ( filepath , url , req ) {
102- const accept = req . headers . get ( "accept" ) || ""
103-
104- if ( accept . includes ( "text/html" ) ) {
105- return new Response (
106- htmlPreset (
107- ( await relImport (
108- filepath + "#" + cacheBuster ++
109- ) ) . default
110- ) ,
111- { headers : {
112- "content-type" : "text/html" ,
113- } }
114- )
115- } else {
116- return await handleTs ( filepath , url )
117- }
118- }
11971} ) )
12072
12173const appendParam =
Load Diff This file was deleted.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments