dashersupply/src/pages/[productLookup].astro

133 lines
3.8 KiB
Plaintext

---
import Layout from '../layouts/Layout.astro';
import { categories } from '../data/categories';
import { products } from '../data/products';
import StarRating from '../components/StarRating.astro';
type ProductStaticPath = { params: { productLookup: string }};
export function getStaticPaths() {
return products.map<ProductStaticPath>((_, index) => { return {
params: {
productLookup: index
}
}});
}
console.log(getStaticPaths());
const { productLookup } = Astro.params;
const product = products[productLookup];
const category = categories[product.categoryId];
---
<Layout title=`${product?.name} - Dasher Supply`>
<main>
<h1 class="center"><a href="/"><span class="text-gradient">Dasher Supply</span></a> &gt; <a href={`/category/${category.seoLink}`}>{category.category}</a> &gt; {product.name}</h1>
<p class="instructions">
{category.description}
</p>
<h2>
{product?.name}
</h2>
<div class="row">
<div class="col-4">
{product?.productDetails?.imageUrls !== undefined && <img src={product!.productDetails?.imageUrls[0]} alt={product?.productDetails?.title} />}
</div>
<div class="col-8">
<h5 class="card-title">
{product?.productDetails?.title}
</h5>
<p>
<StarRating value={product?.productDetails?.reviewRating} max={5} overlayColor="#13151a" /> {product?.productDetails?.reviewCount} Reviews
</p>
<ul role="list">
{product?.productDetails?.featureBullets?.map(featureBullet => (
<li>{featureBullet}</li>
))}
</ul>
<p>
{product?.productDetails?.description && product?.productDetails?.description}
</p>
<a href={product?.amazonLink} class="btn btn-primary">${product?.productDetails?.price} On Amazon <span>&rarr;</span></a>
</div>
</div>
<br />
<div class="disclaimers">
<p>Dasher Supply is not endorsed by or affiliated with DoorDash. As an Amazon Associate I earn from qualifying purchases.</p>
</div>
</main>
</Layout>
<style>
main {
margin: auto;
padding: 1rem;
min-width: 800px;
max-width: calc(100% - 2rem);
color: white;
font-size: 20px;
line-height: 1.6;
}
.center {
text-align: center;
}
h1 {
font-size: 4rem;
font-weight: 700;
line-height: 1;
margin-bottom: 1em;
font-family: "Holtwood One SC", sans-serif;
font-weight: 600;
font-style: bold;
/* text-shadow: -5px -5px 0 rgba(var(--accent-dark), 17%), 3px -3px 0 rgba(var(--accent-light), 10%), -2px 2px 0 rgba(var(--accent-light), 5%), 5px 5px 0 rgba(var(--accent-light), 10%); */
}
.text-gradient {
background-image: var(--accent-gradient);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-size: 400%;
background-position: 0%;
}
.disclaimers {
margin-bottom: 2rem;
border: 1px solid rgba(var(--accent-light), 25%);
background: linear-gradient(rgba(var(--accent-dark), 66%), rgba(var(--accent-dark), 33%));
padding: 1.5rem;
border-radius: 8px;
font-family: "Urbanist", sans-serif;
font-weight: 400;
font-style: normal;
}
.instructions {
margin-bottom: 2rem;
border: 1px solid rgba(var(--accent-light), 25%);
background: linear-gradient(rgba(var(--accent-dark), 66%), rgba(var(--accent-dark), 33%));
padding: 1.5rem;
border-radius: 8px;
font-family: "Charm", cursive;
font-weight: 400;
font-style: normal;
font-size: 2rem;
text-align: center;
}
.instructions code {
font-size: 0.8em;
font-weight: bold;
background: rgba(var(--accent-light), 12%);
color: rgb(var(--accent-light));
border-radius: 4px;
padding: 0.3em 0.4em;
}
.instructions strong {
color: rgb(var(--accent-light));
}
.link-card-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(24ch, 1fr));
gap: 2rem;
padding: 0;
}
a, a:link, a:visited { text-decoration: none; }
a:hover { text-decoration: underline; color: #fff }
</style>