23 lines
583 B
TypeScript
23 lines
583 B
TypeScript
import { resolveArticlePage } from "./resolveArticlePage";
|
|
import { resolveProductPage } from "./resolveProductPage";
|
|
|
|
export type SlugResult =
|
|
| ReturnType<typeof resolveArticlePage>
|
|
| ReturnType<typeof resolveProductPage>;
|
|
|
|
export function findBySlug(slug?: string): SlugResult | null {
|
|
if (!slug || slug.trim() === '') {
|
|
return null;
|
|
}
|
|
|
|
// PRODUCT
|
|
const product = resolveProductPage(slug);
|
|
if (product) return product;
|
|
|
|
// ARTICLE
|
|
const article = resolveArticlePage(slug);
|
|
if (article) return article;
|
|
|
|
// 404
|
|
return null;
|
|
} |