mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
59 lines
1.5 KiB
Text
59 lines
1.5 KiB
Text
---
|
|
// Full Astro Component Syntax:
|
|
// https://docs.astro.build/core-concepts/astro-components/
|
|
|
|
import axios from 'axios'
|
|
|
|
import { ListingDetails } from '~/helpers/listing-page.js'
|
|
|
|
import Layout from '../../layouts/default.astro'
|
|
import Listing from '../../components/default-listing.astro'
|
|
|
|
// const {
|
|
// appPath
|
|
// } = 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('Astro.request.url', Astro.request.url )
|
|
// console.log('Astro.site.pathname', Astro.site.pathname )
|
|
// console.log('Astro.request', Astro.request )
|
|
|
|
const appListing = await axios.get( apiUrl.toString() )
|
|
.then( response => {
|
|
// console.log( 'response', response )
|
|
return response.data
|
|
})
|
|
|
|
const listingDetails = new ListingDetails( appListing )
|
|
|
|
---
|
|
<Layout
|
|
headTitle={ listingDetails.pageTitle }
|
|
headDescription={ listingDetails.pageDescription }
|
|
headOptions={ listingDetails.headOptions }
|
|
>
|
|
|
|
<Listing
|
|
listing={ appListing }
|
|
/>
|
|
|
|
</Layout>
|