diff --git a/packages/imagetools_3/package.json b/packages/imagetools_3/package.json index 7b3dd45..7ecbf61 100644 --- a/packages/imagetools_3/package.json +++ b/packages/imagetools_3/package.json @@ -53,8 +53,7 @@ "keyv-file": "^5.1.3", "object-hash": "3.0.0", "p-map": "^7.0.3", - "p-timeout": "^6.1.4", - "sharp": "^0.34.1" + "p-timeout": "^6.1.4" }, "devDependencies": { "vitest": "^3.2.4" diff --git a/packages/imagetools_3/plugin/utils/imagetools.js b/packages/imagetools_3/plugin/utils/imagetools.js index 2d46a8f..bee1848 100644 --- a/packages/imagetools_3/plugin/utils/imagetools.js +++ b/packages/imagetools_3/plugin/utils/imagetools.js @@ -4,6 +4,7 @@ import { applyTransforms, generateTransforms, } from "imagetools-core"; + import sharp from "sharp"; export const getLoadedImage = async (src) => { diff --git a/packages/polymech/package.json b/packages/polymech/package.json index 2423df6..623a0a5 100644 --- a/packages/polymech/package.json +++ b/packages/polymech/package.json @@ -35,15 +35,19 @@ "@polymech/i18n": "file:../../../polymech-mono/packages/i18n", "@polymech/kbot-d": "file:../../../polymech-mono/packages/kbot", "@polymech/log": "file:../../../polymech-mono/packages/log", + "@types/html-escaper": "^3.0.0", "@types/yargs": "^17.0.35", "astro": "^5.13.2", "exifreader": "^4.31.1", "find-up": "^7.0.0", + "flowbite": "^3.1.2", "github-slugger": "^2.0.0", "glob": "^11.0.3", "hast-util-select": "^6.0.4", "hast-util-to-string": "^3.0.1", "html-entities": "^2.5.2", + "html-escaper": "^3.0.3", + "html-validate": "^8.18.2", "imagetools": "file:../imagetools_3", "marked": "^16.1.2", "mdast-util-to-string": "^4.0.0", @@ -58,14 +62,10 @@ "remark-parse": "^11.0.0", "remark-rehype": "^11.1.2", "showdown": "^2.1.0", + "tailwindcss": "^4.0.7", "tslog": "^4.9.3", "unified": "^11.0.5", "unist-util-visit": "^5.0.0", - "tailwindcss": "^4.0.7", - "flowbite": "^3.1.2", - "yargs": "^18.0.0", - "html-escaper": "^3.0.3", - "html-validate": "^8.18.2", - "@types/html-escaper": "^3.0.0" + "yargs": "^18.0.0" } -} \ No newline at end of file +} diff --git a/packages/polymech/src/base/images.ts b/packages/polymech/src/base/images.ts index 0f540bf..465facc 100644 --- a/packages/polymech/src/base/images.ts +++ b/packages/polymech/src/base/images.ts @@ -22,6 +22,7 @@ export interface ImageSEOData { export interface GalleryImage { name?: string url?: string + urlR?: string src: string thumb?: string responsive?: string diff --git a/packages/polymech/src/base/media.ts b/packages/polymech/src/base/media.ts index 88d1d16..8427bb5 100644 --- a/packages/polymech/src/base/media.ts +++ b/packages/polymech/src/base/media.ts @@ -17,7 +17,7 @@ import { sync as read } from '@polymech/fs/read' import { logger } from './index.js' import { removeArrayValues, removeArrays, removeBufferValues, removeEmptyObjects } from './objects.js' -import { ITEM_ASSET_URL, PRODUCT_CONFIG, PRODUCT_ROOT, DEFAULT_IMAGE_URL, FILE_SERVER_DEV } from '../app/config.js' +import { ITEM_ASSET_URL, PRODUCT_CONFIG, PRODUCT_ROOT, DEFAULT_IMAGE_URL, FILE_SERVER_DEV, ITEM_ASSET_URL_R } from '../app/config.js' import { GalleryImage, MetaJSON } from './images.js' import { env } from './index.js' @@ -320,13 +320,27 @@ export const gallery = async ( )) } + const assetUrlR = (filePath) => { + return sanitizeUri(ITEM_ASSET_URL_R( + { + FILE_SERVER_DEV, + assetPath, + filePath, + ITEM_REL: product, + ...profile.variables + } + )) + } - const fileBuffer = readFileSync(filePath); - const hash = createHash('md5').update(fileBuffer).digest('hex').substring(0, 8); + + const fileBuffer = readFileSync(filePath) + const hash = createHash('md5').update(fileBuffer).digest('hex').substring(0, 8) + const urlR = (await image_url(assetUrlR(file)) || '').replace('/products', '/machines') const ret: GalleryImage = { name: path.parse(file).name, url: await image_url(assetUrl(file)), + urlR, src: await image_url(assetUrl(file)), thumb: assetUrl(`/${parts.name}-thumb.webp`), responsive: assetUrl(`/webp/${parts.name}.webp`), diff --git a/packages/polymech/src/components/ArticleStructuredData.astro b/packages/polymech/src/components/ArticleStructuredData.astro index ee0cfea..6af111d 100644 --- a/packages/polymech/src/components/ArticleStructuredData.astro +++ b/packages/polymech/src/components/ArticleStructuredData.astro @@ -16,6 +16,8 @@ const itemData = frontmatter ? await get("json-ld", {} as any, frontmatter, const meta = config.metadata || { } + + let data = itemData || { "@context": "https://schema.org", "@type": "Article", diff --git a/packages/polymech/src/model/component.ts b/packages/polymech/src/model/component.ts index b53d731..f7a8ae2 100644 --- a/packages/polymech/src/model/component.ts +++ b/packages/polymech/src/model/component.ts @@ -197,13 +197,13 @@ const onItem = async (item: IStoreItem, ctx: ILoaderContextEx) => { src: data.assets.renderings[0].thumb }) data.assets.gallery = await gallery('media/gallery', data.rel) as [] + data.assets.main_image = (data.assets.gallery as any[]).find((item: any) => item.src.endsWith('latest.jpg')) data.image = data.assets.main_image || data.assets.gallery[0] || data.assets.renderings[0] data.assets.showcase = await gallery('media/showcase', data.rel) as [] data.assets.samples = await gallery('media/samples', data.rel) as [] data.assets.screenshots = await gallery('media/screenshots', data.rel) as [] - } export function loader(branch: string): Loader { const load = async ({ diff --git a/packages/polymech/src/model/json-ld.ts b/packages/polymech/src/model/json-ld.ts index ec3ca70..3e6f79c 100644 --- a/packages/polymech/src/model/json-ld.ts +++ b/packages/polymech/src/model/json-ld.ts @@ -1,5 +1,6 @@ import type { IComponentNode, IComponentConfig } from '@polymech/commons' import { PolymechInstance } from '../registry.js'; +import { ITEM_ASSET_URL_R } from '@/app/config.js'; const config = () => PolymechInstance.getConfig(); interface ProductJsonLD { @@ -36,15 +37,15 @@ export const get = async (node: IComponentNode, component: IComponentConfig, opt name: config().ecommerce?.brand || config().site.title } } - if (component.image?.url) { - jsonLD.image = [component.image.url] + if (component.image?.urlR) { + jsonLD.image = component.image?.urlR } if (component.price) { jsonLD.offers = { '@type': 'Offer', price: component.price, - priceCurrency: config().ecommerce?.currencyCode || 'EU', + priceCurrency: config().ecommerce?.currencyCode || 'EUR', availability: 'https://schema.org/InStock', url: opts.url || config().site.base_url } diff --git a/packages/polymech/src/model/merchant.ts b/packages/polymech/src/model/merchant.ts index 847df12..ca0a4b6 100644 --- a/packages/polymech/src/model/merchant.ts +++ b/packages/polymech/src/model/merchant.ts @@ -22,7 +22,7 @@ export const get = async (node: IComponentNode, config: IComponentConfig, opts: description: config.keywords, link: node.path, image_link: config.image?.url, - price: config.price?.toString() + ' USD', + price: config.price?.toString() + ' EUR', availability: 'in_stock', brand: 'Polymech', condition: 'new' diff --git a/packages/polymech/src/model/registry.ts b/packages/polymech/src/model/registry.ts index 015e250..fe5a55b 100644 --- a/packages/polymech/src/model/registry.ts +++ b/packages/polymech/src/model/registry.ts @@ -2,7 +2,7 @@ import { get as handleMerchant } from './merchant.js' import { get as handleJsonLd } from './json-ld.js' -import type { IComponentNode, IComponentConfig } from '@polymech/commons/' +import type { IComponentNode, IComponentConfig } from '@polymech/commons' export type Handler = (node: IComponentNode, config: IComponentConfig, opts: { url?: string }) => Promise