Files
Montech_Landing/apps/landing/composables/useMontechApi.ts
T
MahdiandCursor 7e8e1b1f1b Initial Montech monorepo: Nuxt landing, Vue admin, Nest API.
Scaffold SSR site with CMS/blog/gallery/SEO admin and deploy configs for montech.ir.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-30 18:42:28 +03:30

54 lines
1.3 KiB
TypeScript

export function useApiBase() {
const config = useRuntimeConfig();
if (import.meta.server) return config.apiBase as string;
return (config.public.apiBase as string) || "";
}
export async function fetchPublicSite() {
const base = useApiBase();
return await $fetch(`${base}/api/public/site`);
}
export async function fetchPublicBlog() {
const base = useApiBase();
return await $fetch(`${base}/api/public/blog`);
}
export async function fetchPublicPost(slug: string) {
const base = useApiBase();
return await $fetch(`${base}/api/public/blog/${slug}`);
}
export async function fetchPublicGallery() {
const base = useApiBase();
return await $fetch(`${base}/api/public/gallery`);
}
export async function fetchPage(key: string) {
const base = useApiBase();
return await $fetch(`${base}/api/public/pages/${key}`);
}
export function applyPageSeo(seo?: {
title?: string;
description?: string;
ogImage?: string | null;
canonical?: string | null;
noIndex?: boolean;
} | null) {
if (!seo) return;
useSeoMeta({
title: seo.title,
description: seo.description,
ogTitle: seo.title,
ogDescription: seo.description,
ogImage: seo.ogImage || undefined,
robots: seo.noIndex ? "noindex,nofollow" : "index,follow",
});
if (seo.canonical) {
useHead({
link: [{ rel: "canonical", href: seo.canonical }],
});
}
}