feat: design system, layout e componenti di base
- token, font self-hosted (Fraunces e Inter, sottoinsieme latin) con preload - BaseLayout con head completo (SEO, Open Graph, favicon) e JSON-LD dello studio - intestazione con barra superiore, navigazione e sottomenu servizi accessibili - menu mobile con dialog modale e alternativa senza JavaScript - footer con P.IVA, recapiti, servizi, orari e link legali - componenti: Logo, Icon (Lucide inline), Hero, card servizio, scheda professionista, badge abilitazione, card sede, mappa click-to-load, modulo di contatto, banda CTA, breadcrumb, intestazioni di sezione - generate-icons.mjs: marchio, favicon, apple-touch-icon e immagine OG - collection dei servizi e dei link utili con schemi Zod Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016zJ9ZWGKvoKoxYwbmnRKdJ
This commit is contained in:
58 files changed
+5077
-16
No files matched your search
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Elenco delle pagine del sito letto dalla sitemap generata in dist/ (nessuna lista da tenere
|
||||
* allineata a mano), più le pagine escluse dalla sitemap (404 e conferma del modulo).
|
||||
*/
|
||||
import { existsSync, readFileSync, readdirSync } from 'node:fs';
|
||||
import { resolve } from 'node:path';
|
||||
|
||||
export function readSitemapPaths(distDir) {
|
||||
const index = resolve(distDir, 'sitemap-index.xml');
|
||||
if (!existsSync(index)) {
|
||||
throw new Error(`Sitemap non trovata in ${index}: esegui prima \`npm run build\`.`);
|
||||
}
|
||||
const locs = (xml) => [...xml.matchAll(/<loc>([^<]+)<\/loc>/g)].map((m) => m[1].trim());
|
||||
const paths = [];
|
||||
for (const sitemapUrl of locs(readFileSync(index, 'utf8'))) {
|
||||
const file = resolve(distDir, new URL(sitemapUrl).pathname.replace(/^\//, ''));
|
||||
for (const url of locs(readFileSync(file, 'utf8'))) paths.push(new URL(url).pathname);
|
||||
}
|
||||
return [...new Set(paths)].sort();
|
||||
}
|
||||
|
||||
/** Pagine generate ma escluse dalla sitemap per scelta (noindex). */
|
||||
export const EXTRA_PAGES = ['/404.html', '/contatti/grazie/'];
|
||||
|
||||
/** Tutti i file HTML presenti in dist/ (percorsi relativi). */
|
||||
export function listHtmlFiles(distDir, dir = '') {
|
||||
const out = [];
|
||||
for (const entry of readdirSync(resolve(distDir, dir), { withFileTypes: true })) {
|
||||
const rel = dir ? `${dir}/${entry.name}` : entry.name;
|
||||
if (entry.isDirectory()) out.push(...listHtmlFiles(distDir, rel));
|
||||
else if (entry.name.endsWith('.html')) out.push(rel);
|
||||
}
|
||||
return out.sort();
|
||||
}
|
||||
|
||||
/** Da file HTML a percorso URL: «studio/index.html» → «/studio/». */
|
||||
export function fileToPath(rel) {
|
||||
if (rel === 'index.html') return '/';
|
||||
if (rel.endsWith('/index.html')) return `/${rel.slice(0, -'index.html'.length)}`;
|
||||
return `/${rel}`;
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* Avvia `astro preview` su una porta libera e restituisce l'URL base e una funzione di stop.
|
||||
* Usato dagli script che devono navigare il sito compilato (link, screenshot).
|
||||
*/
|
||||
import { spawn } from 'node:child_process';
|
||||
import { existsSync } from 'node:fs';
|
||||
import { createServer } from 'node:net';
|
||||
import { resolve } from 'node:path';
|
||||
|
||||
export const root = resolve(import.meta.dirname, '..', '..');
|
||||
|
||||
async function freePort(preferred) {
|
||||
const tryPort = (port) =>
|
||||
new Promise((ok) => {
|
||||
const srv = createServer();
|
||||
srv.once('error', () => ok(null));
|
||||
srv.listen(port, '127.0.0.1', () => srv.close(() => ok(port)));
|
||||
});
|
||||
return (await tryPort(preferred)) ?? (await tryPort(0));
|
||||
}
|
||||
|
||||
export async function startPreview({ port = 4322 } = {}) {
|
||||
if (!existsSync(resolve(root, 'dist', 'index.html'))) {
|
||||
throw new Error('Cartella dist/ assente: esegui prima `npm run build`.');
|
||||
}
|
||||
const p = await freePort(port);
|
||||
const astroBin = resolve(root, 'node_modules', 'astro', 'bin', 'astro.mjs');
|
||||
const child = spawn(
|
||||
process.execPath,
|
||||
[astroBin, 'preview', '--host', '127.0.0.1', '--port', String(p)],
|
||||
{
|
||||
cwd: root,
|
||||
stdio: ['ignore', 'pipe', 'pipe'],
|
||||
env: { ...process.env, ASTRO_TELEMETRY_DISABLED: '1' },
|
||||
},
|
||||
);
|
||||
let output = '';
|
||||
child.stdout.on('data', (d) => (output += d));
|
||||
child.stderr.on('data', (d) => (output += d));
|
||||
|
||||
const base = `http://127.0.0.1:${p}`;
|
||||
const deadline = Date.now() + 30_000;
|
||||
for (;;) {
|
||||
try {
|
||||
const res = await fetch(`${base}/`);
|
||||
if (res.ok) break;
|
||||
} catch {
|
||||
// server non ancora pronto
|
||||
}
|
||||
if (child.exitCode !== null || Date.now() > deadline) {
|
||||
child.kill();
|
||||
throw new Error(`Impossibile avviare astro preview:\n${output}`);
|
||||
}
|
||||
await new Promise((r) => setTimeout(r, 250));
|
||||
}
|
||||
|
||||
return {
|
||||
base,
|
||||
stop: () =>
|
||||
new Promise((ok) => {
|
||||
if (child.exitCode !== null) return ok();
|
||||
child.once('exit', () => ok());
|
||||
child.kill('SIGTERM');
|
||||
}),
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user