Crystallize 是一个面向电子商务的 headless 内容管理系统,提供 GraphQL API 接口。
---// 从 Crystallize 的 GraphQL API 获取目录路径 import BaseLayout from '../../layouts/BaseLayout.astro';import { createClient } from '@crystallize/js-api-client'; const apiClient = createClient({ tenantIdentifier: 'furniture'}); const query = ` query getCataloguePaths{ catalogue(language: "en", path: "/shop") { name children { name path } } }`const { data: { catalogue } } = await apiClient.catalogueApi(query)---<BaseLayout> <h1>{catalogue.name}</h1> <nav> <ul> {catalogue.children.map(child => ( <li><a href={child.path}>{child.name}</a></li> ))} </ul> </nav></BaseLayout>