157 lines
4.7 KiB
Plaintext
157 lines
4.7 KiB
Plaintext
---
|
|
import Layout from '../layouts/Layout.astro';
|
|
import { allCategories } from '../data/categories';
|
|
import { allProducts } from '../data/products';
|
|
import StarRating from '../components/StarRating.astro';
|
|
import markdownIt from 'markdown-it';
|
|
import markdownItAttrs from 'markdown-it-attrs';
|
|
const md = markdownIt({
|
|
html: true,
|
|
linkify: true,
|
|
typographer: true,
|
|
}).use(
|
|
markdownItAttrs, {
|
|
// optional, these are default options
|
|
leftDelimiter: '{',
|
|
rightDelimiter: '}',
|
|
allowedAttributes: [] // empty array = all attributes are allowed
|
|
}
|
|
);
|
|
|
|
type ProductStaticPath = { params: { productLookup: string }};
|
|
|
|
export function getStaticPaths() {
|
|
return allProducts.map<ProductStaticPath>((product) => { return {
|
|
params: {
|
|
productLookup: product.slug
|
|
}
|
|
}});
|
|
}
|
|
console.log(getStaticPaths());
|
|
|
|
const formatAsCurrency = (amount: number) => amount.toLocaleString('en-US', { style: 'currency', currency: 'USD' });
|
|
|
|
const { productLookup } = Astro.params;
|
|
const product = allProducts.find(p => p.slug === productLookup)!;
|
|
const category = allCategories.find(c => c.id == product.categoryId)!;
|
|
---
|
|
|
|
<Layout title=`${product?.name} - Dasher Supply`>
|
|
<main>
|
|
<h1 class="center"><a href="/"><span class="text-gradient">Dasher Supply</span></a> > <a href={`/category/${category.seoLink}`}>{category.category}</a> > {product.name}</h1>
|
|
<p class="instructions">
|
|
{product?.callout || 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} style="max-width: 100%;" />}
|
|
</div>
|
|
<div class="col-8">
|
|
<h5 class="card-title">
|
|
<a href={product?.amazonLink}>{product?.productDetails?.title}</a>
|
|
</h5>
|
|
<p>
|
|
<StarRating value={product?.productDetails?.reviewRating||0} max={5} overlayColor="#13151a" /> {product?.productDetails?.reviewCount} Reviews
|
|
</p>
|
|
{ product?.description &&
|
|
<div set:html={md.render(product?.description||'')}></div>
|
|
}
|
|
{ !product?.description &&
|
|
<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">{formatAsCurrency(product?.productDetails?.price||0)} On Amazon <span>→</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>
|
|
<div>
|
|
<a href="/about">About this site.</a>
|
|
</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: 0.5rem;
|
|
border-radius: 8px;
|
|
font-family: "Caveat", cursive;
|
|
font-weight: 400;
|
|
font-style: normal;
|
|
font-size: 2.5rem;
|
|
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; color: #fff }
|
|
a:hover, a:active { text-decoration: underline; color: #fff }
|
|
</style>
|