- 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
42 lines
1.7 KiB
JavaScript
42 lines
1.7 KiB
JavaScript
/**
|
|
* 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}`;
|
|
}
|