PDF резюме: Puppeteer-скрипт, кнопка скачивания, имя файла Mamadaev_Nik__CV__Product_Designer_UX-UI

This commit is contained in:
Local Build committed 2026-08-14 10:05:17 +02:00
1 parent 322938b5ec
commit 97e56b48bf
45 files changed
+5132 -4197

No files matched your search

+53 -14
View File
@@ -1,7 +1,8 @@
/**
* Локальный сервер: public/ + BrowserSync + API правок контента (только localhost).
* Локальный сервер: public/ + API правок контента (только localhost).
* Фолбэк: нативный http без browser-sync (portscanner глючит на Node 23+).
*/
import browserSync from "browser-sync";
import http from "node:http";
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
@@ -199,17 +200,55 @@ if (!fs.existsSync(PENDING_FILE)) {
}
migrateLegacyFiles();
browserSync.create().init({
server: {
baseDir: publicDir,
middleware: [contentEditsApi],
},
files: [path.join(publicDir, "**", "*")],
port: 4175,
ui: { port: 4176 },
notify: false,
open: false,
ghostMode: false,
const MIME = {
".html": "text/html; charset=utf-8",
".css": "text/css; charset=utf-8",
".js": "application/javascript; charset=utf-8",
".mjs": "application/javascript; charset=utf-8",
".json": "application/json; charset=utf-8",
".svg": "image/svg+xml",
".png": "image/png",
".jpg": "image/jpeg",
".jpeg": "image/jpeg",
".webp": "image/webp",
".gif": "image/gif",
".ico": "image/x-icon",
".woff": "font/woff",
".woff2": "font/woff2",
".ttf": "font/ttf",
".mp4": "video/mp4",
".webm": "video/webm",
};
function serveStatic(req, res) {
const url = new URL(req.url || "/", "http://localhost");
let filePath = path.join(publicDir, decodeURIComponent(url.pathname));
if (filePath.endsWith(path.sep)) filePath = path.join(filePath, "index.html");
fs.stat(filePath, (err, stat) => {
if (err || !stat.isFile()) {
const fallback = path.join(publicDir, "index.html");
fs.readFile(fallback, (e2, data) => {
if (e2) { res.writeHead(404); res.end("Not found"); return; }
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
res.end(data);
});
return;
}
const ext = path.extname(filePath).toLowerCase();
const mime = MIME[ext] || "application/octet-stream";
fs.readFile(filePath, (e2, data) => {
if (e2) { res.writeHead(500); res.end("Error"); return; }
res.writeHead(200, { "Content-Type": mime });
res.end(data);
});
});
}
const server = http.createServer((req, res) => {
contentEditsApi(req, res, () => serveStatic(req, res));
});
console.log("serve-dev: http://localhost:4175 (public/, reload only public/**)");
server.listen(4175, () => {
console.log("serve-dev: http://localhost:4175 (public/)");
});