Add a reusable website link generator and polish static image cards.

Editors can pick product, store, blog, portfolio, or video category links, and image cards expose compact info/link actions without dumping URLs in the footer.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Alireza Hassani
2026-08-17 00:30:01 +03:30
co-authored by Cursor
parent b9024ad77a
commit e0e68de30f
15 changed files with 1164 additions and 77 deletions
+13
View File
@@ -36,3 +36,16 @@ export function getChildren(categories: Category[], parentId: string | null): Ca
export function hasChildren(categories: Category[], id: string): boolean {
return categories.some((c) => c.parentId === id)
}
export function getAncestorIds(categories: Category[], id: string): string[] {
const byId = new Map(categories.map((category) => [category.id, category]))
const ids: string[] = []
let current = byId.get(id)
while (current?.parentId) {
ids.push(current.parentId)
current = byId.get(current.parentId)
}
return ids
}
+37
View File
@@ -0,0 +1,37 @@
import { getBusinessDomain } from '../lib/config'
export type WebsiteLinkKind = 'product' | 'storeItem' | 'blog' | 'portfolio' | 'video'
export const WEBSITE_LINK_KINDS: WebsiteLinkKind[] = [
'product',
'storeItem',
'blog',
'portfolio',
'video',
]
export const WEBSITE_LINK_KIND_PATH: Record<WebsiteLinkKind, string> = {
product: '/products',
storeItem: '/store-items',
blog: '/blogs',
portfolio: '/portfolios',
video: '/videos',
}
export function getWebsiteOrigin(domain = getBusinessDomain()): string {
const host = domain.trim().replace(/^https?:\/\//i, '').replace(/\/$/, '')
const protocol = window.location.protocol === 'http:' ? 'http:' : 'https:'
return `${protocol}//${host}`
}
export function buildWebsiteCategoryUrl(
kind: WebsiteLinkKind,
category: { id: string; slug?: string | null },
domain = getBusinessDomain(),
): string {
const path = WEBSITE_LINK_KIND_PATH[kind]
const query = category.slug
? `category=${encodeURIComponent(category.slug)}`
: `categoryId=${encodeURIComponent(category.id)}`
return `${getWebsiteOrigin(domain)}${path}?${query}`
}