Files
site-portfolio/public/js/modules/ui/content-edit/content-edit-storage.js
T
root daa623fe73 feat(mesh-bg): fade-in шейдера фона + modulepreload графа
- canvas стартует с opacity:0 и плавно проявляется (0.9s) при .is-ready
- initPageMeshShader ставит is-ready после первого кадра
- modulepreload page-mesh-shader.js для параллельной загрузки с main.js
- пересборка страниц (build:pages)
2026-09-24 21:37:40 +02:00

30 lines
966 B
JavaScript

const API = "/api/content-edits";
export function getPagePath() {
const path = window.location.pathname.replace(/^\//, "");
if (!path || path.endsWith("/")) return "index.html";
return path;
}
export async function loadEdits(page = getPagePath()) {
const res = await fetch(`${API}?page=${encodeURIComponent(page)}`);
if (!res.ok) throw new Error("load failed");
return res.json();
}
export async function saveEdits(payload) {
const res = await fetch(`${API}?page=${encodeURIComponent(payload.page)}`, {
method: "PUT",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload),
});
if (!res.ok) throw new Error("save failed");
return res.json();
}
export function isContentEditHost() {
const host = window.location.hostname;
const ALLOWED_HOSTS = ["localhost", "127.0.0.1", "10.200.201.3", "dev.mamadaevv.site", "f2ogw6fzi6trnp7cp43x8wsd.31.129.103.242.sslip.io"];
return ALLOWED_HOSTS.includes(host);
}