File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,12 +3,7 @@ const Fuse = window.Fuse;
33const searchInput = document . querySelector ( "#searchbar" ) ;
44const contentDiv = document . querySelector ( "#content" ) ;
55const searchResultsDiv = document . querySelector ( "#searchResults" ) ;
6- const currentFile =
7- document . querySelector ( "meta[name='doc-current-file']" ) . attributes
8- . getNamedItem ( "content" ) . value ;
9- const pathToRoot = "../" . repeat (
10- currentFile ? ( currentFile . split ( "/" ) . length + 1 ) : 0 ,
11- ) ;
6+ const rootUrl = new URL ( "." , document . currentScript . src ) ;
127searchInput . removeAttribute ( "style" ) ;
138
149const SEARCH_INDEX = window . DENO_DOC_SEARCH_INDEX ;
@@ -121,7 +116,7 @@ function renderResults(results) {
121116 } ) . join ( "" ) ;
122117
123118 html += `<li class="block">
124- <a href="${ pathToRoot } ${ result . file } / ~/${ result . name } .html" class="flex rounded-lg gap-4 items-center justify-between py-2 px-3 hover:bg-stone-100 dark:hover:bg-stone-800">
119+ <a href="${ rootUrl . href } ${ result . file === "." ? "" : ` ${ result . file } /` } ~/${ result . name } .html" class="flex rounded-lg gap-4 items-center justify-between py-2 px-3 hover:bg-stone-100 dark:hover:bg-stone-800">
125120 <div class="flex items-center gap-2.5">
126121 <div class="docNodeKindIcon">
127122 ${ kind }
Original file line number Diff line number Diff line change @@ -7,12 +7,7 @@ const Fuse = window.Fuse;
77const searchInput = document .querySelector (" #searchbar" );
88const contentDiv = document .querySelector (" #content" );
99const searchResultsDiv = document .querySelector (" #searchResults" );
10- const currentFile =
11- document .querySelector (" meta[name='doc-current-file']" ).attributes
12- .getNamedItem (" content" ).value ;
13- const pathToRoot = " ../" .repeat (
14- currentFile ? (currentFile .split (" /" ).length + 1 ) : 0 ,
15- );
10+ const rootUrl = new URL (" ." , document .currentScript .src );
1611searchInput .removeAttribute (" style" );
1712
1813const SEARCH_INDEX = window .DENO_DOC_SEARCH_INDEX ;
@@ -125,7 +120,7 @@ function renderResults(results) {
125120 }).join (" " );
126121
127122 html += ` <li class = " block" >
128- <a href = " ${pathToRoot }${result.file}/ ~/${result.name}.html" class = " flex rounded-lg gap-4 items-center justify-between py-2 px-3 hover:bg-stone-100 dark:hover:bg-stone-800" >
123+ <a href = " ${rootUrl.href }${result.file === " ." ? " " : `${result.file}/`} ~/${result.name}.html" class = " flex rounded-lg gap-4 items-center justify-between py-2 px-3 hover:bg-stone-100 dark:hover:bg-stone-800" >
129124 <div class = " flex items-center gap-2.5" >
130125 <div class = " docNodeKindIcon" >
131126 ${ kind }
Original file line number Diff line number Diff line change @@ -7,12 +7,7 @@ const Fuse = window.Fuse;
77const searchInput = document .querySelector (" #searchbar" );
88const contentDiv = document .querySelector (" #content" );
99const searchResultsDiv = document .querySelector (" #searchResults" );
10- const currentFile =
11- document .querySelector (" meta[name='doc-current-file']" ).attributes
12- .getNamedItem (" content" ).value ;
13- const pathToRoot = " ../" .repeat (
14- currentFile ? (currentFile .split (" /" ).length + 1 ) : 0 ,
15- );
10+ const rootUrl = new URL (" ." , document .currentScript .src );
1611searchInput .removeAttribute (" style" );
1712
1813const SEARCH_INDEX = window .DENO_DOC_SEARCH_INDEX ;
@@ -125,7 +120,7 @@ function renderResults(results) {
125120 }).join (" " );
126121
127122 html += ` <li class = " block" >
128- <a href = " ${pathToRoot }${result.file}/ ~/${result.name}.html" class = " flex rounded-lg gap-4 items-center justify-between py-2 px-3 hover:bg-stone-100 dark:hover:bg-stone-800" >
123+ <a href = " ${rootUrl.href }${result.file === " ." ? " " : `${result.file}/`} ~/${result.name}.html" class = " flex rounded-lg gap-4 items-center justify-between py-2 px-3 hover:bg-stone-100 dark:hover:bg-stone-800" >
129124 <div class = " flex items-center gap-2.5" >
130125 <div class = " docNodeKindIcon" >
131126 ${ kind }
Original file line number Diff line number Diff line change @@ -7,12 +7,7 @@ const Fuse = window.Fuse;
77const searchInput = document .querySelector (" #searchbar" );
88const contentDiv = document .querySelector (" #content" );
99const searchResultsDiv = document .querySelector (" #searchResults" );
10- const currentFile =
11- document .querySelector (" meta[name='doc-current-file']" ).attributes
12- .getNamedItem (" content" ).value ;
13- const pathToRoot = " ../" .repeat (
14- currentFile ? (currentFile .split (" /" ).length + 1 ) : 0 ,
15- );
10+ const rootUrl = new URL (" ." , document .currentScript .src );
1611searchInput .removeAttribute (" style" );
1712
1813const SEARCH_INDEX = window .DENO_DOC_SEARCH_INDEX ;
@@ -125,7 +120,7 @@ function renderResults(results) {
125120 }).join (" " );
126121
127122 html += ` <li class = " block" >
128- <a href = " ${pathToRoot }${result.file}/ ~/${result.name}.html" class = " flex rounded-lg gap-4 items-center justify-between py-2 px-3 hover:bg-stone-100 dark:hover:bg-stone-800" >
123+ <a href = " ${rootUrl.href }${result.file === " ." ? " " : `${result.file}/`} ~/${result.name}.html" class = " flex rounded-lg gap-4 items-center justify-between py-2 px-3 hover:bg-stone-100 dark:hover:bg-stone-800" >
129124 <div class = " flex items-center gap-2.5" >
130125 <div class = " docNodeKindIcon" >
131126 ${ kind }
You can’t perform that action at this time.
0 commit comments