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< html >
2+ < head >
3+ < title > Posters</ title >
4+ </ head >
25 < body >
6+ < h1 > Loading posters...</ h1 >
37 < script >
48 ( async ( ) => {
5- const response = await fetch ( 'https://api.github.com/repos/gofflab/gofflab.github.io/contents/posters/' ) ;
6- const data = await response . json ( ) ;
7- let htmlString = '<ul>' ;
8-
9- for ( let file of data ) {
10- htmlString += `<li><a href="https://gofflab.github.io/${ file . path } ">${ file . name } </a></li>` ; Retry
11- }
9+ try {
10+ const response = await fetch ( 'https://api.github.com/repos/gofflab/gofflab.github.io/contents/posters' ) ;
11+
12+ if ( ! response . ok ) {
13+ throw new Error ( `API Error: ${ response . status } ${ response . statusText } ` ) ;
14+ }
15+
16+ const data = await response . json ( ) ;
17+ let htmlString = '<ul>' ;
18+
19+ for ( let file of data ) {
20+ // Filter out the index.html file itself
21+ if ( file . name !== 'index.html' ) {
22+ htmlString += `<li><a href="https://gofflab.github.io/${ file . path } ">${ file . name } </a></li>` ;
23+ }
24+ }
1225
13- htmlString += '</ul>' ;
14- document . getElementsByTagName ( 'body' ) [ 0 ] . innerHTML = htmlString ;
26+ htmlString += '</ul>' ;
27+ document . getElementsByTagName ( 'body' ) [ 0 ] . innerHTML = htmlString ;
28+ } catch ( error ) {
29+ document . getElementsByTagName ( 'body' ) [ 0 ] . innerHTML = `<p>Error: ${ error . message } </p>` ;
30+ console . error ( 'Error fetching directory:' , error ) ;
31+ }
1532 } ) ( )
1633 </ script >
17- < body >
34+ </ body >
1835</ html >
You can’t perform that action at this time.
0 commit comments