mirror of
https://git.rdcenter.ru/RDCenter/skb-kit.git
synced 2026-12-05 02:29:45 +00:00
добавлено в о нас блок трудолюбие и креативность, возможность менять фон хедера через worpress, название фона должно быть art
This commit is contained in:
1 parent
7c7f98b448
commit
d3a23dc716
7 files changed
+135
-3
No files matched your search
@@ -0,0 +1,34 @@
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
interface AcfField {
|
||||
mainpage_header_bg?: {
|
||||
url: string;
|
||||
};
|
||||
}
|
||||
|
||||
interface WpPage {
|
||||
acf?: AcfField;
|
||||
}
|
||||
|
||||
export function useWpMainPageData() {
|
||||
const [bgImage, setBgImage] = useState<string>("");
|
||||
|
||||
useEffect(() => {
|
||||
// Заменяй slug на нужный слаг твоей главной страницы в WP
|
||||
fetch("https://test.skbkit.ru/wp-json/wp/v2/pages?slug=mainpage&_fields=acf")
|
||||
.then((res) => res.json())
|
||||
.then((data: WpPage[]) => {
|
||||
if (data && data.length > 0) {
|
||||
const page = data[0];
|
||||
if (page.acf && page.acf.mainpage_header_bg) {
|
||||
setBgImage(page.acf.mainpage_header_bg.url);
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error("Ошибка при загрузке данных WP:", err);
|
||||
});
|
||||
}, []);
|
||||
|
||||
return { bgImage };
|
||||
}
|
||||
Reference in new issue
Block a user