@scayle/storefront-product-detail 0.4.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -4,37 +4,37 @@ import type { WithContext, Product, BreadcrumbList } from 'schema-dts';
|
|
|
4
4
|
type CanonicalLink = Record<'rel' | 'key' | 'href', string>;
|
|
5
5
|
type UrlParams = Record<'baseUrl' | 'fullPath', string>;
|
|
6
6
|
interface ProductInfo {
|
|
7
|
+
/** The name of the product. */
|
|
7
8
|
name: string;
|
|
9
|
+
/** The brand of the product. */
|
|
8
10
|
brand: string;
|
|
11
|
+
/** A description of the product. */
|
|
9
12
|
productDescription: string;
|
|
13
|
+
/** Array of product variants. */
|
|
10
14
|
variants: Variant[];
|
|
15
|
+
/** Array of image URLs for the product. */
|
|
11
16
|
images: string[];
|
|
12
17
|
}
|
|
13
18
|
export interface UseProductSeoDataReturn {
|
|
19
|
+
/** The title of the product. */
|
|
14
20
|
title: ComputedRef<string>;
|
|
21
|
+
/** Robots meta tag value, typically "index, follow". */
|
|
15
22
|
robots: string;
|
|
23
|
+
/** Computed ref for canonical link tag metadata. */
|
|
16
24
|
canonicalLink: ComputedRef<CanonicalLink[]>;
|
|
25
|
+
/** Computed ref containing JSON-LD structured data for the product. */
|
|
17
26
|
productJsonLd: ComputedRef<WithContext<Product>>;
|
|
27
|
+
/** Computed ref containing JSON-LD structured data for product breadcrumbs. */
|
|
18
28
|
productBreadcrumbJsonLd: ComputedRef<WithContext<BreadcrumbList>>;
|
|
19
29
|
}
|
|
20
30
|
/**
|
|
21
31
|
* Composable function to generate SEO-related data for a product page.
|
|
22
32
|
*
|
|
23
|
-
* @param
|
|
24
|
-
* @param
|
|
25
|
-
* @param
|
|
26
|
-
* @property {string} name - The name of the product.
|
|
27
|
-
* @property {string} brand - The brand of the product.
|
|
28
|
-
* @property {string} productDescription - A description of the product.
|
|
29
|
-
* @property {Variant[]} variants - Array of product variants.
|
|
30
|
-
* @property {string[]} images - Array of image URLs for the product.
|
|
33
|
+
* @param breadcrumbs Array of breadcrumb items representing the navigation path to the product.
|
|
34
|
+
* @param urlParams Object containing baseUrl and fullPath to build and sanitize canonicalUrl.
|
|
35
|
+
* @param productInfo Object containing product information including name, brand, description, and variants.
|
|
31
36
|
*
|
|
32
|
-
* @returns
|
|
33
|
-
* @property {string} robots - Robots meta tag value, typically "index, follow".
|
|
34
|
-
* @property {ComputedRef<CanonicalLink[]>} canonicalLink - Computed ref for canonical link tag metadata.
|
|
35
|
-
* @property {ComputedRef<string>} title - The title of the product.
|
|
36
|
-
* @property {ComputedRef<WithContext<Product>>} productJsonLd - Computed ref containing JSON-LD structured data for the product.
|
|
37
|
-
* @property {ComputedRef<WithContext<BreadcrumbList>>} productBreadcrumbJsonLd - Computed ref containing JSON-LD structured data for product breadcrumbs.
|
|
37
|
+
* @returns An object containing SEO data for the product page with following properties:
|
|
38
38
|
*/
|
|
39
39
|
export declare function useProductSeoData(breadcrumbs: MaybeRefOrGetter<BreadcrumbItem[]>, urlParams: MaybeRefOrGetter<UrlParams>, productInfo: MaybeRefOrGetter<ProductInfo>): UseProductSeoDataReturn;
|
|
40
40
|
export {};
|
|
@@ -2,21 +2,27 @@ import type { Attributes } from '@scayle/storefront-nuxt';
|
|
|
2
2
|
/**
|
|
3
3
|
* Filters and formats attribute groups based on specified types.
|
|
4
4
|
*
|
|
5
|
-
* @param
|
|
6
|
-
* @param
|
|
7
|
-
* @param
|
|
8
|
-
*
|
|
5
|
+
* @param attributes The object containing attribute groups, where each key maps to an attribute group.
|
|
6
|
+
* @param filterTypes An array of attribute types to include in the filtered results.
|
|
7
|
+
* @param singleValueType An array of attribute types that should have simplified formatting for their values. Default includes 'extras'.
|
|
8
|
+
*
|
|
9
|
+
* @returns A map where the keys are attribute types and the values are arrays of formatted labels.
|
|
9
10
|
*
|
|
10
11
|
* @example
|
|
12
|
+
* ```
|
|
11
13
|
* const attributes = {
|
|
12
14
|
* color: { type: 'color', values: [{ label: 'Red' }, { label: 'Blue' }] },
|
|
13
15
|
* size: { type: 'size', values: [{ label: 'S' }, { label: 'M' }] },
|
|
14
|
-
* }
|
|
15
|
-
*
|
|
16
|
-
* const
|
|
16
|
+
* }
|
|
17
|
+
*
|
|
18
|
+
* const filterTypes = ['color', 'size']
|
|
19
|
+
*
|
|
20
|
+
* const result = getFilteredAttributeGroups(attributes, filterTypes)
|
|
21
|
+
*
|
|
17
22
|
* // Result: Map {
|
|
18
23
|
* // 'color' => ['Red', 'Blue'],
|
|
19
24
|
* // 'size' => ['S', 'M']
|
|
20
25
|
* // }
|
|
26
|
+
* ```
|
|
21
27
|
*/
|
|
22
28
|
export declare const getFilteredAttributeGroups: (attributes: Attributes, filterTypes: string[], singleValueType?: string[]) => Map<string, string[]>;
|
|
@@ -6,10 +6,16 @@ import { type AdvancedAttribute } from '@scayle/storefront-nuxt';
|
|
|
6
6
|
* parses them as integers, and filters out any invalid values. It is
|
|
7
7
|
* commonly used to handle product recommendations.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
* @
|
|
9
|
+
* More information about recommended products and attributes groups please visit our SCAYLE Resource Center:
|
|
10
|
+
* @see https://scayle.dev/en/storefront-guide/developer-guide/features/product-recommendation
|
|
11
|
+
* @see https://scayle.dev/en/user-guide/settings/product-structure/attribute-groups
|
|
12
|
+
*
|
|
13
|
+
* @param attribute The advanced attribute containing values to extract product IDs from. This attribute is sourced from a product's advanced attributes.
|
|
14
|
+
*
|
|
15
|
+
* @returns An array of valid product IDs extracted from the attribute values. Returns an empty array if the input is undefined or invalid.
|
|
11
16
|
*
|
|
12
17
|
* @example
|
|
18
|
+
* ```
|
|
13
19
|
* // Example usage within a Vue.js/Nuxt computed property
|
|
14
20
|
* const recommendedProductIds = computed(() => {
|
|
15
21
|
* return getCombineWithProductIds(
|
|
@@ -58,9 +64,6 @@ import { type AdvancedAttribute } from '@scayle/storefront-nuxt';
|
|
|
58
64
|
* }
|
|
59
65
|
*
|
|
60
66
|
* // Then: recommendedProductIds.value => [ 206131, 206017, 206012 ]
|
|
61
|
-
*
|
|
62
|
-
* More information about recommended products and attributes groups please visit our SCAYLE Resource Center:
|
|
63
|
-
* https://scayle.dev/en/storefront-guide/developer-guide/features/product-recommendation
|
|
64
|
-
* https://scayle.dev/en/user-guide/settings/product-structure/attribute-groups
|
|
67
|
+
* ```
|
|
65
68
|
*/
|
|
66
69
|
export declare const getCombineWithProductIds: (attribute?: AdvancedAttribute) => number[];
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import type { Variant } from '@scayle/storefront-nuxt';
|
|
2
2
|
import type { Product, WithContext } from 'schema-dts';
|
|
3
|
+
/**
|
|
4
|
+
* Generates an object following the schema.org `Product` type with context.
|
|
5
|
+
*
|
|
6
|
+
* @see https://schema.org/Product Used to specify `@type` of the returned schema.
|
|
7
|
+
* @see https://schema.org/Brand Used to define schema of `brand`.
|
|
8
|
+
*
|
|
9
|
+
* @returns An object following the schema.org `Product` type with context.
|
|
10
|
+
*/
|
|
3
11
|
export declare const generateProductSchema: ({ productName, brandName, variants, url, images, description, }: {
|
|
4
12
|
productName: string;
|
|
5
13
|
brandName: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scayle/storefront-product-detail",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Collection of essential composables and utilities to work with product detail",
|
|
5
5
|
"author": "SCAYLE Commerce Engine",
|
|
6
6
|
"license": "MIT",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"@nuxt/kit": "^3.13.0",
|
|
44
|
-
"@scayle/storefront-nuxt": "^
|
|
44
|
+
"@scayle/storefront-nuxt": "^8.0.0",
|
|
45
45
|
"@vue/test-utils": "2.4.6",
|
|
46
46
|
"@vueuse/core": "12.0.0",
|
|
47
47
|
"vue-router": "4.5.0"
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
"@nuxt/schema": "3.13.2",
|
|
53
53
|
"@nuxt/test-utils": "3.15.1",
|
|
54
54
|
"@scayle/eslint-config-storefront": "4.3.2",
|
|
55
|
-
"@scayle/storefront-nuxt": "8.1.
|
|
56
|
-
"@types/node": "22.10.
|
|
55
|
+
"@scayle/storefront-nuxt": "8.1.3",
|
|
56
|
+
"@types/node": "22.10.2",
|
|
57
57
|
"@vue/test-utils": "2.4.6",
|
|
58
58
|
"@vueuse/core": "12.0.0",
|
|
59
59
|
"dprint": "0.47.6",
|