Skip to content

Commit

Permalink
product metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
sesto-dev committed Sep 19, 2023
1 parent 05f72f1 commit f2e3138
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 13 deletions.
2 changes: 1 addition & 1 deletion apps/storefront/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"dependencies": {
"@hookform/resolvers": "^3.3.1",
"@persepolis/database": "^1.0.5",
"@persepolis/database": "^1.0.6",
"@persepolis/mail": "^1.0.7",
"@prisma/client": "^5.2.0",
"@radix-ui/react-accordion": "^1.1.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,32 @@ import prisma from '@/lib/prisma'
import { isVariableValid } from '@/lib/utils'
import { DataSection } from './components/data'
import Carousel from '@/components/native/Carousel'
import type { Metadata, ResolvingMetadata } from 'next'

type Props = {
params: { productId: string }
searchParams: { [key: string]: string | string[] | undefined }
}

export async function generateMetadata(
{ params, searchParams }: Props,
parent: ResolvingMetadata
): Promise<Metadata> {
const product = await prisma.product.findUnique({
where: {
id: params.productId,
},
})

return {
title: product.title,
description: product.description,
keywords: product.keywords,
openGraph: {
images: product.images,
},
}
}

export default async function Product({
params,
Expand Down
2 changes: 1 addition & 1 deletion packages/database/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@persepolis/database",
"version": "1.0.5",
"version": "1.0.6",
"description": "Database schema for the Persepolis e-commerce platform.",
"scripts": {
"db:generate": "npx prisma generate",
Expand Down
4 changes: 2 additions & 2 deletions packages/database/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ model Product {
title String
description String?
images String[]
tags String[]
keywords String[]
metadata Json?
price Float @default(100)
Expand Down Expand Up @@ -350,7 +350,7 @@ model Blog {
content String? @db.Text
categories String[]
tags String[]
keywords String[]
author Author @relation(fields: [authorId], references: [id])
authorId String
Expand Down
18 changes: 9 additions & 9 deletions packages/database/prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ async function main() {
title: 'BKID Pipe',
brand: 'BKID',
categories: ['Accessories'],
tags: ['pipe', 'brushed', 'wood'],
keywords: ['pipe', 'brushed', 'wood'],
price: 69.99,
images: ['https://lemanoosh.com/app/uploads/bkid-pipe-01.jpg'],
},
{
title: 'Bang and Olufsen Speaker',
brand: 'Bang and Olufsen',
categories: ['Electronics'],
tags: ['speaker', 'brushed', 'mechanical'],
keywords: ['speaker', 'brushed', 'mechanical'],
price: 9.99,
images: [
'https://lemanoosh.com/app/uploads/BO_2019_A1_Natural_Brushed_05-768x1156.jpg',
Expand All @@ -76,7 +76,7 @@ async function main() {
brand: 'Audio Technica',

categories: ['Electronics'],
tags: ['music', 'brushed', 'mechanical'],
keywords: ['music', 'brushed', 'mechanical'],
price: 12.99,
images: [
'https://lemanoosh.com/app/uploads/gerhardt-kellermann-zeitmagazin-10.jpg',
Expand All @@ -87,7 +87,7 @@ async function main() {
brand: 'Monocle',

categories: ['Electronics'],
tags: ['shoes', 'brushed', 'mechanical'],
keywords: ['shoes', 'brushed', 'mechanical'],
price: 1.99,
images: [
'https://lemanoosh.com/app/uploads/plp-women-footwear-sneakers-04-07-768x1246.jpg',
Expand All @@ -98,15 +98,15 @@ async function main() {
brand: 'Zone2',

categories: ['Electronics'],
tags: ['shoes', 'brushed', 'mechanical'],
keywords: ['shoes', 'brushed', 'mechanical'],
price: 129.99,
images: ['https://lemanoosh.com/app/uploads/0055-768x1023.jpg'],
},
{
title: 'Carl Hauser L1 Phone',
brand: 'Carl Hauser',
categories: ['Electronics'],
tags: ['shoes', 'brushed', 'mechanical'],
keywords: ['shoes', 'brushed', 'mechanical'],
price: 5.99,
images: [
'https://lemanoosh.com/app/uploads/carl-hauser-0121-768x993.jpg',
Expand All @@ -116,7 +116,7 @@ async function main() {
title: 'Carl Hauser Scanner',
brand: 'Carl Hauser',
categories: ['Electronics'],
tags: ['shoes', 'brushed', 'mechanical'],
keywords: ['shoes', 'brushed', 'mechanical'],
price: 22.99,
images: [
'https://lemanoosh.com/app/uploads/carl-hauser-020-768x973.jpg',
Expand All @@ -126,7 +126,7 @@ async function main() {
title: 'Bright Neon Helmet',
brand: 'Bright',
categories: ['Electronics'],
tags: ['shoes', 'brushed', 'mechanical'],
keywords: ['shoes', 'brushed', 'mechanical'],
price: 17.99,
images: [
'https://lemanoosh.com/app/uploads/Orange_white-_Helmet_01.jpg',
Expand Down Expand Up @@ -252,7 +252,7 @@ async function main() {
},
description: 'Description of this product.',
images: product.images,
tags: product.tags,
keywords: product.keywords,
categories: {
connect: {
title: product.categories[0],
Expand Down

1 comment on commit f2e3138

@vercel
Copy link

@vercel vercel bot commented on f2e3138 Sep 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

store – ./apps/storefront

pasargad.vercel.app
store-accretence.vercel.app
store.accretence.com
store-git-main-accretence.vercel.app

Please sign in to comment.