@@ -20,14 +20,21 @@ class BuildsInfo extends HTMLElement {
2020 get fake ( ) {
2121 return this . hasAttribute ( "fake" ) ;
2222 }
23+ get url ( ) {
24+ return this . getAttribute ( "url" ) ?? location . origin ;
25+ }
2326
2427 async getMetadata ( ) {
2528 if ( this . fake ) return BuildsInfo . fakeInfo ;
2629
27- const res = await fetch ( this . endpoint ) ;
30+ const res = await fetch ( this . getUrl ( this . endpoint ) ) ;
2831 return res . ok ? res . json ( ) : null ;
2932 }
3033
34+ getUrl ( input ) {
35+ return new URL ( input , this . url ) . toString ( ) ;
36+ }
37+
3138 async render ( ) {
3239 const data = await this . getMetadata ( ) ;
3340 if ( ! data ) {
@@ -36,12 +43,12 @@ class BuildsInfo extends HTMLElement {
3643 }
3744
3845 const tileAnchor = ( name ) => {
39- return `<a href="/tiles/ ${ name } " download="${ name } .json ">${ name } </a>` ;
46+ return `<a href="${ this . getUrl ( name ) } " download="${ name } ">${ name } </a>` ;
4047 } ;
4148
4249 const metaAnchor = ( pmtiles ) => {
4350 const name = pmtiles . replace ( / \. p m t i l e s $ / , "" ) ;
44- return `<a href="/tiles/ ${ name } .json" download="${ name } .json">metadata</a>` ;
51+ return `<a href="${ this . getUrl ( name ) } .json" download="${ name } .json">metadata</a>` ;
4552 } ;
4653
4754 const builds = data . targets . map (
@@ -55,20 +62,38 @@ class BuildsInfo extends HTMLElement {
5562 </li>` ,
5663 ) ;
5764
58- const debug = [
59- `endpoint: ${ this . endpoint } ` ,
60- `version: ${ data . meta . name } /${ data . meta . version } ` ,
61- ] ;
65+ // const debug = [
66+ // `endpoint: ${this.endpoint}`,
67+ // `version: ${data.meta.name}/${data.meta.version}`,
68+ // ];
69+
70+ const debug = {
71+ element : {
72+ endpoint : this . endpoint ,
73+ url : this . url ,
74+ fake : this . fake ,
75+ } ,
76+ data,
77+ } ;
78+
79+ const format = new Intl . DateTimeFormat ( undefined , {
80+ dateStyle : "medium" ,
81+ timeStyle : "medium" ,
82+ } ) ;
83+ const updated = format . format ( new Date ( data . date ) ) ;
6284
6385 this . classList . add ( "flow" ) ;
6486
6587 this . innerHTML = `
6688 <ul>
6789 ${ builds . join ( "\n" ) }
6890 </ul>
91+ <p>
92+ Last updated: ${ updated }
93+ </p>
6994 <details>
7095 <summary>debug</summary>
71- <pre>${ debug . join ( "\n" ) } </pre>
96+ <pre>${ JSON . stringify ( debug , null , 2 ) } </pre>
7297 </details>
7398 ` ;
7499 }
0 commit comments