feat: simplify navigation and add RU/EN home and contacts
- simplify main navigation and hide extra menu items - make home page more sales-focused with updated hero, benefits and fleet teaser - add RU/EN handling for home and contacts, including SEO defaults - integrate basic Strapi homepage API client (no breaking changes) - update contacts page with messenger buttons and dynamic footer year Made-with: Cursor
This commit is contained in:
48
src/api/strapiClient.ts
Normal file
48
src/api/strapiClient.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
const STRAPI_URL = import.meta.env.VITE_STRAPI_URL || 'http://localhost:1337';
|
||||
|
||||
type Locale = 'ru' | 'en';
|
||||
|
||||
async function fetchJson(path: string, init?: RequestInit) {
|
||||
const res = await fetch(`${STRAPI_URL}${path}`, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
...init,
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
throw new Error(`Strapi request failed: ${res.status} ${res.statusText}`);
|
||||
}
|
||||
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export interface HomepageData {
|
||||
heroTitle?: string;
|
||||
heroSubtitle?: string;
|
||||
seoTitle?: string;
|
||||
seoDescription?: string;
|
||||
}
|
||||
|
||||
export async function getHomepage(locale: Locale): Promise<HomepageData | null> {
|
||||
const query = new URLSearchParams({
|
||||
locale,
|
||||
populate: '*',
|
||||
}).toString();
|
||||
|
||||
const json = await fetchJson(`/api/homepage?${query}`);
|
||||
|
||||
if (!json || !json.data || !json.data.attributes) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const attrs = json.data.attributes;
|
||||
|
||||
return {
|
||||
heroTitle: attrs.heroTitle,
|
||||
heroSubtitle: attrs.heroSubtitle,
|
||||
seoTitle: attrs.seoTitle,
|
||||
seoDescription: attrs.seoDescription,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user