24 lines
473 B
TypeScript
24 lines
473 B
TypeScript
|
|
import { apiFetch } from './client';
|
||
|
|
|
||
|
|
export type PageType =
|
||
|
|
| 'category'
|
||
|
|
| 'product-search'
|
||
|
|
| 'product-detail'
|
||
|
|
| 'product-hot'
|
||
|
|
| 'article-home'
|
||
|
|
| 'article-category'
|
||
|
|
| 'article-detail'
|
||
|
|
| '404';
|
||
|
|
|
||
|
|
interface ResolvePageTypeResponse {
|
||
|
|
pageType: PageType;
|
||
|
|
}
|
||
|
|
|
||
|
|
export async function getResolvedPageType(slug: string) {
|
||
|
|
const result = await apiFetch<ResolvePageTypeResponse>(
|
||
|
|
`/page-type?slug=${encodeURIComponent(slug)}`,
|
||
|
|
);
|
||
|
|
|
||
|
|
return result.pageType;
|
||
|
|
}
|