Add support for benchmark urls

This commit is contained in:
Sam Carlton 2022-04-27 12:46:08 -05:00
parent 9b28ae14fb
commit 8dd2c5ea4a

View file

@ -0,0 +1,94 @@
---
// Full Astro Component Syntax:
// https://docs.astro.build/core-concepts/astro-components/
import axios from 'axios'
import Layout from '../../layouts/default.astro'
import { makeLastUpdatedFriendly } from '~/helpers/parse-date'
import { getAppEndpoint } from '~/helpers/app-derived.js'
import LinkButton from '~/components/link-button.vue'
import AllUpdatesSubscribe from '~/components/all-updates-subscribe.vue'
import VideoRow from '~/components/video/row.vue'
// import appList from '~/static/app-list.json'
// export async function getStaticPaths () {
// return appList.map(app => {
// // console.log('app.slug', app.slug )
// return {
// params: {
// slug: app.slug
// }
// }
// })
// }
const {
slug
} = Astro.params
// Parse the request url
const requestUrl = new URL( Astro.request.url )
// Get type and slug from the request path
// 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
// https://docs.astro.build/en/reference/api-reference/#astrorequests
console.log('Astro.params', Astro.params )
console.log('apiUrl', apiUrl )
console.log('Astro.request.url', Astro.request.url )
console.log('Astro.site.pathname', Astro.site.pathname )
// console.log('Astro.request', Astro.request )
const appEntry = await axios.get( apiUrl.toString() )
.then( response => {
// console.log( 'response', response )
return response.data
})
// const {
// head,
// entry
// } = Astro.props
const app = {}
const hasMultipleAliases = false
const appDeviceSupport = []
const hasRelatedVideos = false
const relatedVideosRowHtml = []
const hasBundleIdentifiers = false
const lastUpdatedFriendly = null
---
<Layout
headTitle={ `${ appEntry.name } | Does It ARM` }
headDescription={ 'Test' }
>
{ slug }
<br>
<br>
{ JSON.stringify( appEntry ) }
<AllUpdatesSubscribe
client:visible
/>
</Layout>