mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
Add support for benchmark urls
This commit is contained in:
parent
9b28ae14fb
commit
8dd2c5ea4a
1 changed files with 11 additions and 7 deletions
|
|
@ -34,13 +34,19 @@ const {
|
||||||
} = Astro.params
|
} = Astro.params
|
||||||
|
|
||||||
|
|
||||||
const apiUrl = new URL( import.meta.env.PUBLIC_API_DOMAIN )
|
|
||||||
|
|
||||||
// Parse the request url
|
// Parse the request url
|
||||||
const requestUrl = new URL( Astro.request.url )
|
const requestUrl = new URL( Astro.request.url )
|
||||||
|
|
||||||
// Use request path to get api url path
|
// Get type and slug from the request path
|
||||||
apiUrl.pathname = `/api${ requestUrl.pathname }.json`
|
// so that we don't have extra parts for
|
||||||
|
// urls like /:type/:slug/benchmarks
|
||||||
|
const [ , pathType, pathSlug ] = requestUrl.pathname.split('/')
|
||||||
|
|
||||||
|
// Create an empty API URL
|
||||||
|
const apiUrl = new URL( import.meta.env.PUBLIC_API_DOMAIN )
|
||||||
|
|
||||||
|
// Use request path parts to set api url path
|
||||||
|
apiUrl.pathname = `/api/${ pathType }/${ pathSlug }.json`
|
||||||
|
|
||||||
|
|
||||||
// Astro Request reference
|
// Astro Request reference
|
||||||
|
|
@ -50,7 +56,7 @@ console.log('Astro.params', Astro.params )
|
||||||
console.log('apiUrl', apiUrl )
|
console.log('apiUrl', apiUrl )
|
||||||
console.log('Astro.request.url', Astro.request.url )
|
console.log('Astro.request.url', Astro.request.url )
|
||||||
console.log('Astro.site.pathname', Astro.site.pathname )
|
console.log('Astro.site.pathname', Astro.site.pathname )
|
||||||
console.log('Astro.request', Astro.request )
|
// console.log('Astro.request', Astro.request )
|
||||||
|
|
||||||
const appEntry = await axios.get( apiUrl.toString() )
|
const appEntry = await axios.get( apiUrl.toString() )
|
||||||
.then( response => {
|
.then( response => {
|
||||||
|
|
@ -82,8 +88,6 @@ const lastUpdatedFriendly = null
|
||||||
<br>
|
<br>
|
||||||
{ JSON.stringify( appEntry ) }
|
{ JSON.stringify( appEntry ) }
|
||||||
|
|
||||||
<AllUpdatesSubscribe />
|
|
||||||
|
|
||||||
<AllUpdatesSubscribe
|
<AllUpdatesSubscribe
|
||||||
client:visible
|
client:visible
|
||||||
/>
|
/>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue