mirror of
https://github.com/vercel/commerce.git
synced 2025-05-22 09:26:59 +00:00
Fix missing block and functions
This commit is contained in:
parent
8fc54664da
commit
cd828e95c5
@ -5,7 +5,7 @@ const baseUrl = process.env.NEXT_PUBLIC_VERCEL_URL
|
||||
? `https://${process.env.NEXT_PUBLIC_VERCEL_URL}`
|
||||
: 'http://localhost:3000';
|
||||
|
||||
export default async function sitemap(): Promise<Promise<Promise<MetadataRoute.Sitemap>>> {
|
||||
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
||||
const routesMap = ['', '/search'].map((route) => ({
|
||||
url: `${baseUrl}${route}`,
|
||||
lastModified: new Date().toISOString()
|
||||
|
@ -9,9 +9,17 @@ type EditorJsListBlock = {
|
||||
type: 'list';
|
||||
data: { style: 'unordered' | 'ordered'; items: string[] };
|
||||
};
|
||||
type EditorJsQuoteBlock = {
|
||||
data: { text: string; caption: string; alignment: string };
|
||||
type: 'quote';
|
||||
};
|
||||
|
||||
type EditorJsBlockCommon = { id: string };
|
||||
type EditorJsBlocks = EditorJsHeaderBlock | EditorJsParagraphBlock | EditorJsListBlock;
|
||||
type EditorJsBlocks =
|
||||
| EditorJsHeaderBlock
|
||||
| EditorJsParagraphBlock
|
||||
| EditorJsListBlock
|
||||
| EditorJsQuoteBlock;
|
||||
|
||||
type EditorJsBlock = EditorJsBlocks & EditorJsBlockCommon;
|
||||
|
||||
@ -53,6 +61,8 @@ export const parseEditorJsToHtml = (content: string) => {
|
||||
return list(block.data);
|
||||
case 'paragraph':
|
||||
return paragraph(block.data);
|
||||
case 'quote':
|
||||
return quote(block.data);
|
||||
default:
|
||||
console.warn(`Unknown block type: ${JSON.stringify(block)}`);
|
||||
return '';
|
||||
@ -76,3 +86,7 @@ function paragraph({ text }: EditorJsParagraphBlock['data']): string {
|
||||
function header({ level, text }: EditorJsHeaderBlock['data']): string {
|
||||
return `<h${level}>${text}</h${level}>`;
|
||||
}
|
||||
|
||||
function quote({ text, caption, alignment }: EditorJsQuoteBlock['data']): string {
|
||||
return `<blockquote><p>${text}</p> - <cite>${caption}</cite></blockquote>`;
|
||||
}
|
||||
|
@ -385,7 +385,7 @@ export async function getProducts({
|
||||
query: SearchProductsDocument,
|
||||
variables: {
|
||||
search: query || '',
|
||||
sortBy: sortKey || ProductOrderField.Rank,
|
||||
sortBy: sortKey || (query ? ProductOrderField.Rank : ProductOrderField.Rating),
|
||||
sortDirection: reverse ? OrderDirection.Desc : OrderDirection.Asc
|
||||
}
|
||||
});
|
||||
@ -487,3 +487,21 @@ export async function getProductRecommendations(productId: string): Promise<Prod
|
||||
// @todo
|
||||
return [];
|
||||
}
|
||||
export async function addToCart(
|
||||
cartId: string,
|
||||
lines: { merchandiseId: string; quantity: number }[]
|
||||
): Promise<Cart> {
|
||||
// @todo
|
||||
throw new Error(`Not implemented`);
|
||||
}
|
||||
export async function updateCart(
|
||||
cartId: string,
|
||||
lines: { id: string; merchandiseId: string; quantity: number }[]
|
||||
): Promise<Cart> {
|
||||
// @todo
|
||||
throw new Error(`Not implemented`);
|
||||
}
|
||||
export async function removeFromCart(cartId: string, lineIds: string[]): Promise<Cart> {
|
||||
// @todo
|
||||
throw new Error(`Not implemented`);
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
"*": "prettier --write --ignore-unknown"
|
||||
},
|
||||
"dependencies": {
|
||||
"@graphql-typed-document-node/core": "3.2.0",
|
||||
"@headlessui/react": "^1.7.10",
|
||||
"@vercel/og": "^0.1.0",
|
||||
"clsx": "^1.2.1",
|
||||
|
5
pnpm-lock.yaml
generated
5
pnpm-lock.yaml
generated
@ -1,6 +1,9 @@
|
||||
lockfileVersion: '6.0'
|
||||
|
||||
dependencies:
|
||||
'@graphql-typed-document-node/core':
|
||||
specifier: 3.2.0
|
||||
version: registry.npmjs.org/@graphql-typed-document-node/core@3.2.0(graphql@16.6.0)
|
||||
'@headlessui/react':
|
||||
specifier: ^1.7.10
|
||||
version: 1.7.14(react-dom@18.2.0)(react@18.2.0)
|
||||
@ -4917,7 +4920,6 @@ packages:
|
||||
graphql: ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0
|
||||
dependencies:
|
||||
graphql: registry.npmjs.org/graphql@16.6.0
|
||||
dev: true
|
||||
|
||||
registry.npmjs.org/@jridgewell/gen-mapping@0.3.3:
|
||||
resolution: {integrity: sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz}
|
||||
@ -6075,7 +6077,6 @@ packages:
|
||||
name: graphql
|
||||
version: 16.6.0
|
||||
engines: {node: ^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0}
|
||||
dev: true
|
||||
|
||||
registry.npmjs.org/has-flag@3.0.0:
|
||||
resolution: {integrity: sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz}
|
||||
|
Loading…
x
Reference in New Issue
Block a user