mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
Add formula template
This commit is contained in:
parent
5504b2c537
commit
146d012ffc
1 changed files with 49 additions and 0 deletions
49
src/pages/formula/[...formulaPath].astro
Normal file
49
src/pages/formula/[...formulaPath].astro
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
---
|
||||||
|
// Full Astro Component Syntax:
|
||||||
|
// https://docs.astro.build/core-concepts/astro-components/
|
||||||
|
|
||||||
|
import { DoesItAPI } from '~/helpers/api/client.js'
|
||||||
|
import { catchRedirectResponse } from '~/helpers/astro/request.js'
|
||||||
|
import {
|
||||||
|
ListingDetails
|
||||||
|
} from '~/helpers/listing-page.js'
|
||||||
|
import { getPathPartsFromAstroRequest } from '~/helpers/url.js'
|
||||||
|
|
||||||
|
import Layout from '~/src/layouts/default.astro'
|
||||||
|
import Listing from '~/src/components/default-listing.astro'
|
||||||
|
|
||||||
|
|
||||||
|
const redirectResponse = await catchRedirectResponse( Astro )
|
||||||
|
|
||||||
|
if ( redirectResponse !== null ) {
|
||||||
|
return redirectResponse
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Get type and slug from the request path
|
||||||
|
// so that we don't have extra parts for
|
||||||
|
// urls like /:type/:slug/benchmarks
|
||||||
|
const {
|
||||||
|
pathSlug,
|
||||||
|
subSlug = null
|
||||||
|
} = getPathPartsFromAstroRequest( Astro.request )
|
||||||
|
|
||||||
|
|
||||||
|
// Astro Request reference
|
||||||
|
// https://docs.astro.build/en/reference/api-reference/#astrorequests
|
||||||
|
|
||||||
|
// Request App data from API
|
||||||
|
const appListing = await DoesItAPI.formula( pathSlug ).get()
|
||||||
|
|
||||||
|
const listingDetails = new ListingDetails( appListing )
|
||||||
|
|
||||||
|
const headOptions = listingDetails.headOptions
|
||||||
|
|
||||||
|
---
|
||||||
|
<Layout
|
||||||
|
headOptions={ headOptions }
|
||||||
|
>
|
||||||
|
<Listing
|
||||||
|
listing={ appListing }
|
||||||
|
/>
|
||||||
|
</Layout>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue