@@ -51,14 +51,18 @@ export function notFound(userOptions?: Partial<Options>): Middleware {
51
51
async function getDirectoryIndex ( root : string , file : string ) : Promise < string > {
52
52
const folders : [ string , string ] [ ] = [ ] ;
53
53
const files : [ string , string ] [ ] = [ ] ;
54
+ const folderIcon =
55
+ `<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="currentColor" viewBox="0 0 256 256"><use xlink:href="#icon-folder"></use></svg>` ;
56
+ const fileIcon =
57
+ `<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="currentColor" viewBox="0 0 256 256"><use xlink:href="#icon-file"></use></svg>` ;
54
58
55
59
try {
56
60
for await ( const info of Deno . readDir ( join ( root , file ) ) ) {
57
61
info . isDirectory
58
- ? folders . push ( [ `${ info . name } /` , `📁 ${ info . name } /` ] )
62
+ ? folders . push ( [ `${ info . name } /` , `${ folderIcon } ${ info . name } /` ] )
59
63
: files . push ( [
60
64
info . name === "index.html" ? "./" : info . name ,
61
- `📄 ${ info . name } ` ,
65
+ `${ fileIcon } ${ info . name } ` ,
62
66
] ) ;
63
67
}
64
68
} catch {
@@ -69,11 +73,11 @@ async function getDirectoryIndex(root: string, file: string): Promise<string> {
69
73
info . isDirectory
70
74
? folders . push ( [
71
75
posix . join ( base , `${ info . name } /` ) ,
72
- `📁 ${ info . name } /` ,
76
+ `${ folderIcon } ${ info . name } /` ,
73
77
] )
74
78
: files . push ( [
75
79
posix . join ( base , info . name === "index.html" ? "./" : info . name ) ,
76
- `📄 ${ info . name } ` ,
80
+ `${ fileIcon } ${ info . name } ` ,
77
81
] ) ;
78
82
}
79
83
} catch {
@@ -94,9 +98,47 @@ async function getDirectoryIndex(root: string, file: string): Promise<string> {
94
98
<meta charset="UTF-8">
95
99
<meta name="viewport" content="width=device-width, initial-scale=1.0">
96
100
<title>404 - Not found</title>
97
- <style> body { font-family: sans-serif; max-width: 40em; margin: auto; padding: 2em; line-height: 1.5; }</style>
101
+ <style>
102
+ html {
103
+ color-scheme: light dark;
104
+ }
105
+ body {
106
+ font-family: sans-serif;
107
+ max-width: 40em;
108
+ margin: auto;
109
+ padding: 2em;
110
+ line-height: 1.5;
111
+ }
112
+ h1 {
113
+ margin-bottom: 0;
114
+ }
115
+ ul {
116
+ margin: 2em 0;
117
+ padding: 0;
118
+ list-style-type: "";
119
+ }
120
+ li a {
121
+ display: flex;
122
+ align-items: center;
123
+ column-gap: 0.5em;
124
+ text-decoration: none;
125
+ &:hover {
126
+ text-decoration: underline;
127
+ }
128
+ }
129
+ </style>
98
130
</head>
99
131
<body>
132
+ <svg display="none">
133
+ <defs>
134
+ <g id="icon-file">
135
+ <path d="M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34ZM160,51.31,188.69,80H160ZM200,216H56V40h88V88a8,8,0,0,0,8,8h48V216Z"/>
136
+ </g>
137
+ <g id="icon-folder">
138
+ <path d="M232,88V200.89A15.13,15.13,0,0,1,216.89,216H40a16,16,0,0,1-16-16V64A16,16,0,0,1,40,48H93.33a16.12,16.12,0,0,1,9.6,3.2L130.67,72H216A16,16,0,0,1,232,88Z"></path>
139
+ </g>
140
+ </defs>
141
+ </svg>
100
142
<h1>404 - Not found</h1>
101
143
<p>The URL <code>${ file } </code> does not exist</p>
102
144
<ul>
0 commit comments