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,9 @@
|
||||
/**
|
||||
* Data di build: usa SOURCE_DATE_EPOCH se impostata (build riproducibili), altrimenti l'ora
|
||||
* corrente. Serve per l'anno del copyright nel footer.
|
||||
*/
|
||||
const epoch = Number(process.env.SOURCE_DATE_EPOCH);
|
||||
|
||||
export const buildDate = Number.isFinite(epoch) && epoch > 0 ? new Date(epoch * 1000) : new Date();
|
||||
|
||||
export const buildYear = buildDate.getFullYear();
|
||||
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* Funzioni di formattazione condivise (indirizzi, orari, link telefonici e mappe).
|
||||
*/
|
||||
import type { Phone, PostalAddress } from '../data/studio';
|
||||
import { studio } from '../data/studio';
|
||||
|
||||
/** «Via XX Settembre, 163 — 14048 Montegrosso d’Asti (AT)» */
|
||||
export function addressLine(a: PostalAddress): string {
|
||||
return `${a.streetAddress} — ${a.postalCode} ${a.locality} (${a.province})`;
|
||||
}
|
||||
|
||||
/** «14048 Montegrosso d’Asti (AT)» */
|
||||
export function cityLine(a: PostalAddress): string {
|
||||
return `${a.postalCode} ${a.locality} (${a.province})`;
|
||||
}
|
||||
|
||||
export function telHref(phone: Phone): string {
|
||||
return `tel:${phone.e164}`;
|
||||
}
|
||||
|
||||
export function mailtoHref(email: string, subject?: string): string {
|
||||
return subject ? `mailto:${email}?subject=${encodeURIComponent(subject)}` : `mailto:${email}`;
|
||||
}
|
||||
|
||||
/** Fasce orarie leggibili: «9:00 – 12:30 | 15:00 – 18:30». */
|
||||
export function hoursLine(): string {
|
||||
const short = (t: string) => t.replace(/^0/, '');
|
||||
return studio.orari.fasce.map((f) => `${short(f.apertura)} – ${short(f.chiusura)}`).join(' | ');
|
||||
}
|
||||
|
||||
/** Ricerca per indirizzo (le coordinate non sono verificate, brief §4.6). */
|
||||
export function googleMapsUrl(query: string): string {
|
||||
return `https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(query)}`;
|
||||
}
|
||||
|
||||
export function googleDirectionsUrl(query: string): string {
|
||||
return `https://www.google.com/maps/dir/?api=1&destination=${encodeURIComponent(query)}`;
|
||||
}
|
||||
|
||||
export function openStreetMapUrl(query: string): string {
|
||||
return `https://www.openstreetmap.org/search?query=${encodeURIComponent(query)}`;
|
||||
}
|
||||
|
||||
/** Dominio leggibile di un URL esterno (es. «agenziaentrate.gov.it»). */
|
||||
export function displayDomain(url: string): string {
|
||||
return new URL(url).hostname.replace(/^www\./, '');
|
||||
}
|
||||
|
||||
/** Data in italiano: «15 ottobre 2026». */
|
||||
export function formatDateIt(date: Date): string {
|
||||
return new Intl.DateTimeFormat('it-IT', {
|
||||
day: 'numeric',
|
||||
month: 'long',
|
||||
year: 'numeric',
|
||||
timeZone: 'Europe/Rome',
|
||||
}).format(date);
|
||||
}
|
||||
|
||||
/** Iniziali per l'avatar: «Dott.ssa Giulia Grasso» → «GG». */
|
||||
export function initials(name: string): string {
|
||||
return name
|
||||
.replace(/^(Dott\.ssa|Dott\.|Avv\.|Rag\.)\s+/i, '')
|
||||
.split(/\s+/)
|
||||
.map((p) => p.charAt(0).toUpperCase())
|
||||
.join('')
|
||||
.slice(0, 2);
|
||||
}
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
/**
|
||||
* Titoli di pagina e dati strutturati (JSON-LD) condivisi.
|
||||
*/
|
||||
import { professionisti, sedePrincipale, studio } from '../data/studio';
|
||||
import type { PostalAddress } from '../data/studio';
|
||||
|
||||
const SUFFIX_FULL = 'Studio Grasso | Studio Tributario e Societario, Asti';
|
||||
const SUFFIX_MEDIUM = 'Studio Grasso, Asti';
|
||||
const SUFFIX_SHORT = 'Studio Grasso';
|
||||
/** Lunghezza massima del titolo (brief §4.8: «max ~60 caratteri»). */
|
||||
export const TITLE_MAX = 65;
|
||||
|
||||
/**
|
||||
* Formato del brief: «Titolo pagina — Studio Grasso | Studio Tributario e Societario, Asti».
|
||||
* Se il titolo supera ~60 caratteri si usa un suffisso più breve (vedi DECISIONS.md).
|
||||
*/
|
||||
export function pageTitle(title: string): string {
|
||||
for (const suffix of [SUFFIX_FULL, SUFFIX_MEDIUM, SUFFIX_SHORT]) {
|
||||
const full = `${title} — ${suffix}`;
|
||||
if (full.length <= TITLE_MAX) return full;
|
||||
}
|
||||
return `${title} — ${SUFFIX_SHORT}`;
|
||||
}
|
||||
|
||||
export interface Crumb {
|
||||
name: string;
|
||||
href: string;
|
||||
}
|
||||
|
||||
const absolute = (site: URL, path: string) => new URL(path, site).href;
|
||||
|
||||
export const orgId = (site: URL) => absolute(site, '/#studio');
|
||||
|
||||
function postalAddress(a: PostalAddress) {
|
||||
return {
|
||||
'@type': 'PostalAddress',
|
||||
streetAddress: a.streetAddress,
|
||||
postalCode: a.postalCode,
|
||||
addressLocality: a.locality.replace('’', "'"),
|
||||
addressRegion: a.province,
|
||||
addressCountry: a.country,
|
||||
};
|
||||
}
|
||||
|
||||
/** Organizzazione (AccountingService) presente in tutte le pagine (brief §9.2). */
|
||||
export function organizationLd(site: URL) {
|
||||
const altreSedi = studio.sedi.filter((s) => !s.principale);
|
||||
return {
|
||||
'@type': 'AccountingService',
|
||||
'@id': orgId(site),
|
||||
name: `${studio.nome} — ${studio.sottotitolo}`,
|
||||
alternateName: studio.nomeEsteso,
|
||||
description: studio.descrizioneBreve,
|
||||
url: absolute(site, '/'),
|
||||
logo: absolute(site, '/apple-touch-icon.png'),
|
||||
image: absolute(site, '/og-default.png'),
|
||||
telephone: studio.telefoni[0].display,
|
||||
faxNumber: studio.fax.display,
|
||||
email: studio.email,
|
||||
vatID: `IT${studio.partitaIva}`,
|
||||
...(studio.titolare.denominazione ? { legalName: studio.titolare.denominazione } : {}),
|
||||
...(studio.titolare.codiceFiscale ? { taxID: studio.titolare.codiceFiscale } : {}),
|
||||
address: postalAddress(sedePrincipale.indirizzo),
|
||||
location: altreSedi.map((s) => ({
|
||||
'@type': 'Place',
|
||||
name: s.nome,
|
||||
address: postalAddress(s.indirizzo),
|
||||
})),
|
||||
openingHoursSpecification: studio.orari.fasce.map((f) => ({
|
||||
'@type': 'OpeningHoursSpecification',
|
||||
dayOfWeek: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'],
|
||||
opens: f.apertura,
|
||||
closes: f.chiusura,
|
||||
})),
|
||||
areaServed: studio.areaServita,
|
||||
employee: professionisti.map((p) => ({
|
||||
'@type': 'Person',
|
||||
name: p.nomeSenzaTitolo,
|
||||
honorificPrefix: p.titolo,
|
||||
jobTitle: p.qualificaPrincipale,
|
||||
})),
|
||||
sameAs: [],
|
||||
};
|
||||
}
|
||||
|
||||
export function breadcrumbLd(site: URL, crumbs: Crumb[]) {
|
||||
return {
|
||||
'@type': 'BreadcrumbList',
|
||||
itemListElement: crumbs.map((c, i) => ({
|
||||
'@type': 'ListItem',
|
||||
position: i + 1,
|
||||
name: c.name,
|
||||
item: absolute(site, c.href),
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
export function serviceLd(site: URL, service: { name: string; description: string; path: string }) {
|
||||
return {
|
||||
'@type': 'Service',
|
||||
'@id': absolute(site, `${service.path}#servizio`),
|
||||
name: service.name,
|
||||
description: service.description,
|
||||
url: absolute(site, service.path),
|
||||
provider: { '@id': orgId(site) },
|
||||
areaServed: studio.areaServita,
|
||||
};
|
||||
}
|
||||
|
||||
/** Serializza il JSON-LD in modo sicuro dentro un tag <script>. */
|
||||
export function jsonLdScript(graph: unknown[]): string {
|
||||
return JSON.stringify({ '@context': 'https://schema.org', '@graph': graph }).replace(
|
||||
/</g,
|
||||
'\\u003c',
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* Accesso alla collection dei servizi, ordinata per `ordine`.
|
||||
*/
|
||||
import { getCollection, type CollectionEntry } from 'astro:content';
|
||||
|
||||
export type Servizio = CollectionEntry<'servizi'>;
|
||||
|
||||
export async function getServizi(): Promise<Servizio[]> {
|
||||
const items = await getCollection('servizi');
|
||||
return items.sort((a, b) => a.data.ordine - b.data.ordine);
|
||||
}
|
||||
|
||||
export const servizioHref = (s: Servizio) => `/servizi/${s.data.slug}/`;
|
||||
Reference in new issue
Block a user