File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11{
22 "name" : " @focal/docify" ,
3- "version" : " 1.0.6 " ,
3+ "version" : " 1.0.7 " ,
44 "license" : " MIT" ,
55 "exports" : " ./mod.ts" ,
66 "imports" : {
Original file line number Diff line number Diff line change @@ -8,18 +8,12 @@ import { tmpl } from "./tmpl.ts";
88export default class {
99
1010 constructor ( app : Application ) {
11- const { engine } = app ;
12-
13- app . get ( "/" , async ( ) => {
14- const summary = await getSummary ( ) ;
15- const content = await getReadme ( ) ;
16- return engine . render ( tmpl , { meta, summary, content } ) ;
17- } ) ;
1811
1912 app . get ( "/*" , async ( ctx : HttpContext ) => {
13+ const { pathname } = ctx . request ;
2014 const summary = await getSummary ( ) ;
21- const content = await getDocument ( ctx . request . pathname ) ;
22- return engine . render ( tmpl , { meta, summary, content } ) ;
15+ const content = pathname === "/" ? await getReadme ( ) : await getDocument ( pathname ) ;
16+ return app . engine . render ( tmpl , { meta, summary, content } ) ;
2317 } ) ;
2418
2519 app . run ( ) ;
Original file line number Diff line number Diff line change @@ -3,12 +3,10 @@ import { dirname } from "@std/path/dirname";
33const __dirname = dirname ( import . meta. url . replace ( / ^ f i l e : \/ \/ / , "" ) ) ;
44const tmplFile = __dirname + "/tmpl.html" ;
55
6- async function getTmpl ( ) {
6+ export const tmpl = await ( async function ( ) {
77 if ( tmplFile . match ( / ^ h t t p s ? : \/ \/ / ) ) {
88 const response = await fetch ( tmplFile ) ;
99 return await response . text ( ) ;
1010 }
1111 return await Deno . readTextFile ( tmplFile ) ;
12- }
13-
14- export const tmpl = await getTmpl ( ) ;
12+ } ) ( ) ;
You can’t perform that action at this time.
0 commit comments