generated from satnaing/astro-paper
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
slides in the product description page
- Loading branch information
Daveed
committed
Dec 9, 2024
1 parent
e9e58c6
commit 73b8b50
Showing
7 changed files
with
171 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--- | ||
import { Fragment } from "react"; | ||
interface Slide { | ||
id: number; | ||
name: string; | ||
alternativeText: string | null; | ||
caption: string | null; | ||
width: number; | ||
height: number; | ||
url: string; | ||
} | ||
const { slides } = Astro.props; | ||
--- | ||
|
||
<div class="relative mx-auto w-full max-w-4xl"> | ||
<div class="flex space-x-4 overflow-x-scroll"> | ||
{ | ||
slides.map((slide: Slide) => ( | ||
<Fragment> | ||
<div class="md:w-1/2 lg:w-1/3 w-full flex-shrink-0"> | ||
<img | ||
src={slide.url} | ||
alt={slide.alternativeText || slide.name} | ||
width={slide.width} | ||
height={slide.height} | ||
class="rounded-lg object-cover shadow-lg" | ||
/> | ||
{slide.caption && ( | ||
<p class="mt-2 text-sm text-gray-600 dark:text-gray-300"> | ||
{slide.caption} | ||
</p> | ||
)} | ||
</div> | ||
</Fragment> | ||
)) | ||
} | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
--- | ||
import type { CollectionEntry } from "astro:content"; | ||
import Layout from "@layouts/Layout.astro"; | ||
import Main from "@layouts/Main.astro"; | ||
import Header from "@components/Header.astro"; | ||
import Footer from "@components/Footer.astro"; | ||
import Pagination from "@components/Pagination.astro"; | ||
// import Card from "@components/Card"; | ||
import { markketplace, SITE } from "@config"; | ||
import HeroImage from "@components/HeroImage.astro"; | ||
import Hr from "@components/Hr.astro"; | ||
import Slides from "@components/Slides.astro"; | ||
import { marked } from "marked"; | ||
import { getCollection } from "astro:content"; | ||
import type Store from "@interfaces/Store"; | ||
import { slugifyStr } from "@utils/slugify"; | ||
import type Product from "@interfaces/Product"; | ||
export interface Props { | ||
currentPage: number; | ||
totalPages: number; | ||
stores: CollectionEntry<"stores">[]; | ||
product?: Product; | ||
} | ||
export async function getStaticPaths() { | ||
const products = await getCollection("products"); | ||
const productsResult = products.map((product: { data: Product }) => ({ | ||
params: { | ||
slug: `${product.data.slug || slugifyStr(product.data.Name)}`, | ||
}, | ||
props: { product: product }, | ||
})); | ||
return [...productsResult]; | ||
} | ||
const { currentPage, totalPages, product } = Astro.props; | ||
const stores = await getCollection("stores"); | ||
const store = stores.find( | ||
(store: { data: Store }) => store.data.slug == markketplace.STORE_SLUG | ||
); | ||
const htmlDescription = marked.parse(product?.data?.Description); | ||
console.log({ product, slide: product.data.Slides, t: product.data.Thumbnail }); | ||
--- | ||
|
||
<Layout | ||
title={`Product | ${product?.data?.title}`} | ||
meta={{ | ||
title: `Markkët Product | ${product?.data?.title}`, | ||
description: | ||
product?.data?.SEO?.metaDescription || store?.data?.Description, | ||
}} | ||
> | ||
<Header activeNav="pages" store={store} /> | ||
<main id="main-content"> | ||
<section id="about" class="mb-10 max-w-3xl prose-img:border-0"> | ||
{ | ||
store?.data?.SEO?.socialImage && ( | ||
<HeroImage | ||
image={product?.data?.Thumbnail} | ||
title={product?.data?.Name} | ||
/> | ||
) | ||
} | ||
<h1 class="text-2xl tracking-wider sm:text-3xl"> | ||
{product?.data?.Name} | ||
</h1> | ||
<div set:html={htmlDescription} /> | ||
<Hr /> | ||
{ | ||
product?.data?.Slides?.length > 0 && ( | ||
<section class="my-10"> | ||
<h2 class="mb-4 text-xl font-bold">Product Images</h2> | ||
<Slides slides={product?.data?.Slides} /> | ||
</section> | ||
) | ||
} | ||
<button | ||
class="brand-yellow bg-accent-600 mt-6 rounded-lg px-4 py-2 text-white hover:bg-accent-700 focus:outline-none focus:ring-2 focus:ring-accent-500 focus:ring-offset-2" | ||
disabled | ||
> | ||
Coming Soon | ||
</button> | ||
</section> | ||
</main> | ||
|
||
<Pagination | ||
{currentPage} | ||
{totalPages} | ||
prevUrl={`/blog${currentPage - 1 !== 1 ? "/" + (currentPage - 1) : ""}/`} | ||
nextUrl={`/blog/${currentPage + 1}/`} | ||
/> | ||
|
||
<Footer noMarginTop={totalPages > 1} activeNav="x" /> | ||
</Layout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters