Compare commits

...
12 Commits
Author SHA1 Message Date
davide 754b84e5f6 temp 2026-09-08 23:34:42 +02:00
davide 91b61caa37 Simplify home page and nav to a single latest-article link
Home now shows only the latest article, pointing to the full list on
/blog instead of duplicating recent articles in a grid. Nav trims to
Home, Tutti gli articoli, and the corralito page; the footer drops the
now-redundant Categorie column.
2026-08-27 13:35:29 +02:00
davide b7bb664c95 Add landing page content and a courses page, restyle both
Turn the home page into a single-column feature: a lead image, the
opening statement as the page's sole h1, a second image, and the body
copy, with the existing latest-articles section still below. Add a new
static page for the crypto courses pitch ("come difendersi dal
corralito"), styled like an article with a cover image and a contact
CTA (email + Telegram) instead of the referenced but nonexistent
contact form. Link the new page from the header nav and footer.
2026-08-26 10:46:46 +02:00
davide 809b60d85e Remove i18n, keep only Italian and rely on browser translation
The interface was translated in en/it/es/fr via @nuxtjs/i18n. Drop the
module, the locale files, and the language switcher: the UI is now
static Italian text, with translation for foreign visitors left to the
Google Translate browser extension instead of the app.
2026-08-26 09:39:05 +02:00
davide 448dd881e4 Ignore ops/ (holds VPS credentials, never commit) 2026-08-25 20:07:09 +02:00
davide 8021ea7254 Route every Strapi plugin path to the CMS, not just /admin
Strapi mounts each plugin's admin API at its own top-level path
(/content-manager, /upload, /i18n, ...), not nested under /admin as
previously assumed. That broke the dashboard widgets: recent/count
documents calls landed on the frontend instead of Strapi. List every
prefix actually used by the installed plugins (core-bundled ones plus
users-permissions and cloud from cms/package.json) explicitly in the
Caddyfile.
2026-08-25 20:06:40 +02:00
davide e927396505 Serve the CMS admin panel under /admin on the public domain
Replace the separate CMS subdomain with path-based routing in Caddy:
/admin and /uploads go to Strapi, everything else to the frontend.
Strapi 5 nests its whole admin panel (UI and API) under /admin, so this
one prefix is enough and never collides with the frontend's own /api
routes. Drops CMS_DOMAIN and the unused STRAPI_URL env var on the cms
service; PUBLIC_STRAPI_URL now points at the same origin as the site.

Authentication is unchanged: Strapi's own admin login still gates the
panel, this only changes how it's reached.
2026-08-25 19:49:37 +02:00
davide cb29c68d75 Fix ACME DNS resolution failures in the caddy container
The host's systemd-resolved stub (127.0.0.53) is unreachable from inside
the container network namespace, so Caddy could not resolve Let's Encrypt
endpoints. Point it at public resolvers instead.
2026-08-25 19:23:56 +02:00
davide 071bc1eaa5 Make the site responsive for phones, tablets, and desktop
Mobile-first layout with breakpoints at 48rem (tablet) and 64rem (desktop):
stacked nav on phones, progressive column counts for the article grid and
footer, scrollable markdown tables, larger tap targets on nav links.
2026-08-25 19:04:40 +02:00
davide abeabb3a44 Add the official social marks to the footer links
The marks come from the simple-icons package (CC0) and are inlined at build
time — the earlier hand-drawn glyphs were wrong, the X mark in particular is
not a plain cross. Importing the three SVGs individually rather than the
package index keeps the other icons out of the bundle: 10 kB, not 5 MB.

Rendered monochrome in the surrounding text colour, with the text label kept
next to each one.
2026-08-25 16:11:14 +02:00
davide 0229960a15 Add the social profiles to the footer 2026-08-25 15:35:29 +02:00
davide 31dbf56235 Show the author and publication time on articles
Strapi already records which admin user created an entry, so the byline needs
no extra field to fill in: the Article content type sets populateCreatorFields
and the API layer exposes only that user's firstname and lastname. The name
also feeds the BlogPosting structured data.

Also fixes the gap below the article header, which until now came from the
cover image's margin and therefore vanished on articles without a cover,
leaving the body text against the byline.
2026-08-25 15:30:57 +02:00
41 changed files with 833 additions and 3263 deletions

No files matched your search

+2 -2
View File
@@ -2,7 +2,6 @@
# --- Domains (Caddy) --- # --- Domains (Caddy) ---
PUBLIC_DOMAIN=blog.localhost PUBLIC_DOMAIN=blog.localhost
CMS_DOMAIN=cms.blog.localhost
ACME_EMAIL=admin@example.com ACME_EMAIL=admin@example.com
# --- Database --- # --- Database ---
@@ -25,4 +24,5 @@ STRAPI_URL=http://cms:1337
# Public base URL of the website, used for canonical URLs and Open Graph. # Public base URL of the website, used for canonical URLs and Open Graph.
PUBLIC_SITE_URL=https://blog.localhost PUBLIC_SITE_URL=https://blog.localhost
# Public base URL of Strapi, used to build absolute media URLs in the browser. # Public base URL of Strapi, used to build absolute media URLs in the browser.
PUBLIC_STRAPI_URL=https://cms.blog.localhost # Same origin as PUBLIC_SITE_URL: Caddy proxies /admin and /uploads to Strapi.
PUBLIC_STRAPI_URL=https://blog.localhost
+3
View File
@@ -10,6 +10,9 @@ node_modules/
*.pem *.pem
*.key *.key
# ops (holds VPS credentials, never commit)
ops/
# nuxt # nuxt
frontend/.nuxt/ frontend/.nuxt/
frontend/.output/ frontend/.output/
+22 -11
View File
@@ -16,24 +16,35 @@ sitemap e `robots.txt` dinamici, ricerca, e i test (nessun framework ancora conf
## Architettura ## Architettura
```text ```text
Browser → Caddy ─┬─ dominio pubblico → Nuxt 4 (SSR) → REST Strapi Browser → Caddy ─┬─ /admin e i path dei plugin Strapi → Strapi 5 → PostgreSQL
└─ sottodominio CMS → Strapi 5 → PostgreSQL └─ tutto il resto → Nuxt 4 (SSR) → REST Strapi
``` ```
Caddy instrada per **path**, non per sottodominio: `PUBLIC_DOMAIN` serve sia il sito che il
pannello Strapi. Ogni plugin Strapi monta la propria API admin sul proprio path di primo
livello, non tutto sotto `/admin` (es. `/content-manager`, `/upload`, `/i18n`...): l'elenco
completo dei prefissi da instradare a Strapi vive nel `Caddyfile`. Se aggiungi un plugin
Strapi, aggiungi il suo prefisso lì. Niente di questo tocca `/api`, riservato agli endpoint
Nitro del frontend. Un solo dominio, un solo certificato TLS.
- Strapi è la **sola** fonte di verità editoriale. Niente altro backend (no Express/Nest/Fastify): - Strapi è la **sola** fonte di verità editoriale. Niente altro backend (no Express/Nest/Fastify):
se serve logica server, sta in Nitro (`frontend/server/`) o in un controller Strapi. se serve logica server, sta in Nitro (`frontend/server/`) o in un controller Strapi.
- I visitatori pubblici non si autenticano mai. Solo editor/admin usano l'auth Strapi. - I visitatori pubblici non si autenticano mai. Solo editor/admin usano l'auth Strapi.
- **Il browser non parla mai con Strapi.** Le pagine chiamano gli endpoint Nitro in - **Il browser dei visitatori pubblici non parla mai con Strapi.** Le pagine chiamano gli
`frontend/server/api/`, che sono l'unico posto dove si costruiscono query Strapi. Così endpoint Nitro in `frontend/server/api/`, che sono l'unico posto dove si costruiscono
`NUXT_STRAPI_URL` resta l'indirizzo interno Docker, niente CORS e niente token nel client. query Strapi. Così `NUXT_STRAPI_URL` resta l'indirizzo interno Docker, niente CORS e
Se aggiungi una vista, aggiungi l'endpoint lì e tipizza il ritorno in `shared/types/blog.ts`. niente token nel client. Se aggiungi una vista, aggiungi l'endpoint lì e tipizza il
ritorno in `shared/types/blog.ts`. Fanno eccezione, per costruzione: l'admin panel
(`/admin`, uso editor/admin autenticato) e le immagini cover, che il browser carica
direttamente da `PUBLIC_STRAPI_URL` (`/uploads/...`, sola lettura, nessun'autenticazione
richiesta né concessa).
- Il Markdown dell'articolo è convertito in HTML **nell'endpoint**, non nel componente: il - Il Markdown dell'articolo è convertito in HTML **nell'endpoint**, non nel componente: il
contenuto è già nell'HTML SSR e `marked` resta fuori dal bundle client. contenuto è già nell'HTML SSR e `marked` resta fuori dal bundle client.
- L'**interfaccia** è tradotta in en/it/es/fr con `@nuxtjs/i18n`: stringhe in - L'**interfaccia** è solo in italiano, stringhe statiche nei componenti (niente
`frontend/i18n/locales/*.json`, rotte `prefix_except_default` (inglese senza prefisso), `@nuxtjs/i18n`, niente file di traduzione): `<html lang="it">` è fisso in
`hreflang` e `og:locale` generati da `useLocaleHead()` in `app.vue`. Nessuna stringa `nuxt.config.ts`. La traduzione per i visitatori stranieri è delegata all'estensione
visibile va scritta a mano in un componente: aggiungi la chiave nei quattro file. Google Translate del browser, non è gestita dall'app. I **contenuti** restano
I **contenuti** invece restano monolingua — la localizzazione di Strapi è disattivata. monolingua — la localizzazione di Strapi è disattivata.
- `cms/src/index.ts` (`bootstrap`) dà al ruolo Public solo `find`/`findOne` su Article e Category, - `cms/src/index.ts` (`bootstrap`) dà al ruolo Public solo `find`/`findOne` su Article e Category,
e disattiva la registrazione pubblica: non esistono utenti front-end, solo amministratori. e disattiva la registrazione pubblica: non esistono utenti front-end, solo amministratori.
Qualsiasi permesso in più va motivato. Qualsiasi permesso in più va motivato.
+13 -14
View File
@@ -4,8 +4,8 @@ Blog platform: a public website built with Nuxt, and a private Strapi CMS where
articles are written. Everything runs behind Caddy via Docker Compose. articles are written. Everything runs behind Caddy via Docker Compose.
```text ```text
Browser → Caddy ─┬─ public domain → Nuxt (website) Browser → Caddy ─┬─ /admin and Strapi's plugin paths → Strapi (CMS) → PostgreSQL
└─ cms subdomain → Strapi (CMS) → PostgreSQL └─ everything else → Nuxt (website)
``` ```
There are no front-end accounts: sign-up is disabled and only administrators write There are no front-end accounts: sign-up is disabled and only administrators write
@@ -46,7 +46,8 @@ The first build takes a few minutes. `docker-compose.dev.yml` publishes the port
`127.0.0.1` and leaves Caddy out; it must always be passed explicitly, so it can never be `127.0.0.1` and leaves Caddy out; it must always be passed explicitly, so it can never be
picked up by accident in production. picked up by accident in production.
**4. Create the administrator account** at http://localhost:1337/admin. This is the first **4. Create the administrator account** at http://localhost:1337/admin (dev bypasses Caddy,
so the CMS is reached directly on its port). This is the first
run, so the form creates the account — pick your own credentials. run, so the form creates the account — pick your own credentials.
**5. Write something.** In the admin panel: create a **Category**, then an **Article** **5. Write something.** In the admin panel: create a **Category**, then an **Article**
@@ -72,16 +73,15 @@ override it with `NUXT_STRAPI_URL` if needed. Strapi reads its own `cms/.env`.
## Production ## Production
**1. Point the DNS at the server.** Two `A` records (and `AAAA` if you have IPv6) on the **1. Point the DNS at the server.** One `A` record (and `AAAA` if you have IPv6) on the
public IP of the machine: public IP of the machine:
| Record | Purpose | | Record | Purpose |
|---|---| |---|---|
| `example.com` | the website | | `example.com` | the website and, at `/admin`, the Strapi admin panel |
| `cms.example.com` | the Strapi admin panel |
Wait for the records to resolve before starting the stack — Caddy requests the Wait for the record to resolve before starting the stack — Caddy requests the
certificates on the first boot and a failed challenge means a retry delay. certificate on the first boot and a failed challenge means a retry delay.
**2. Open the firewall** for ports `80` and `443` only. Port `80` is required: Caddy uses **2. Open the firewall** for ports `80` and `443` only. Port `80` is required: Caddy uses
it for the ACME challenge and to redirect to HTTPS. PostgreSQL, Strapi and Nuxt are only it for the ACME challenge and to redirect to HTTPS. PostgreSQL, Strapi and Nuxt are only
@@ -92,10 +92,9 @@ reachable inside the Docker network — do not publish their ports.
| Variable | Value | | Variable | Value |
|---|---| |---|---|
| `PUBLIC_DOMAIN` | `example.com` | | `PUBLIC_DOMAIN` | `example.com` |
| `CMS_DOMAIN` | `cms.example.com` |
| `ACME_EMAIL` | a mailbox you read — Let's Encrypt sends expiry warnings there | | `ACME_EMAIL` | a mailbox you read — Let's Encrypt sends expiry warnings there |
| `PUBLIC_SITE_URL` | `https://example.com` | | `PUBLIC_SITE_URL` | `https://example.com` |
| `PUBLIC_STRAPI_URL` | `https://cms.example.com` | | `PUBLIC_STRAPI_URL` | `https://example.com` — same origin, Caddy proxies `/admin` and Strapi's other plugin paths there (see `caddy/Caddyfile`) |
| `STRAPI_URL` | leave it as `http://cms:1337` — internal address, never public | | `STRAPI_URL` | leave it as `http://cms:1337` — internal address, never public |
Then generate **fresh** secrets on that machine with the same loop as in development — Then generate **fresh** secrets on that machine with the same loop as in development —
@@ -112,11 +111,11 @@ already ignored.
docker compose up -d --build docker compose up -d --build
``` ```
This time Caddy is included: it serves the website on `PUBLIC_DOMAIN`, the CMS on This time Caddy is included: it serves both the website and, under `/admin` and Strapi's
`CMS_DOMAIN`, obtains and renews the TLS certificates on its own, and adds HSTS and the other plugin paths, the CMS on `PUBLIC_DOMAIN`, obtains and renews the TLS certificate on
other security headers. its own, and adds HSTS and the other security headers.
**5. Create the administrator account** at `https://cms.example.com/admin`, immediately, **5. Create the administrator account** at `https://example.com/admin`, immediately,
before anyone else finds the URL — the first visitor to that form is the one who gets the before anyone else finds the URL — the first visitor to that form is the one who gets the
account. Then publish as in development. account. Then publish as in development.
+18 -5
View File
@@ -15,15 +15,28 @@
{$PUBLIC_DOMAIN} { {$PUBLIC_DOMAIN} {
import security_headers import security_headers
encode zstd gzip encode zstd gzip
reverse_proxy frontend:3000
}
{$CMS_DOMAIN} { # Strapi mounts each of its (and its plugins') admin APIs at its own
import security_headers # top-level path, not all under /admin - the admin panel's dashboard
encode zstd gzip # widgets, media library, i18n, etc each call their own plugin prefix.
# This list is every @strapi/* package in cms/package.json plus the
# core-bundled plugins (content-manager, content-type-builder, upload,
# i18n, email, content-releases, review-workflows). Adding a new Strapi
# plugin later means adding its prefix here too.
# None of this touches /api, reserved for the frontend's own Nitro
# endpoints.
@cms path /admin* /content-manager* /content-type-builder* /upload*\
/i18n* /email* /content-releases* /review-workflows*\
/users-permissions* /cloud*
handle @cms {
# Uploaded media can be large; Strapi's own limit still applies. # Uploaded media can be large; Strapi's own limit still applies.
request_body { request_body {
max_size 100MB max_size 100MB
} }
reverse_proxy cms:1337 reverse_proxy cms:1337
} }
handle {
reverse_proxy frontend:3000
}
}
@@ -8,33 +8,44 @@
"description": "Blog article" "description": "Blog article"
}, },
"options": { "options": {
"draftAndPublish": true "draftAndPublish": true,
"populateCreatorFields": true
},
"pluginOptions": {
"i18n": {
"localized": true
}
}, },
"attributes": { "attributes": {
"title": { "title": {
"type": "string", "type": "string",
"required": true, "required": true,
"maxLength": 160 "maxLength": 160,
"pluginOptions": { "i18n": { "localized": true } }
}, },
"slug": { "slug": {
"type": "uid", "type": "uid",
"targetField": "title", "targetField": "title",
"required": true "required": true,
"pluginOptions": { "i18n": { "localized": false } }
}, },
"content": { "content": {
"type": "richtext", "type": "richtext",
"required": true "required": true,
"pluginOptions": { "i18n": { "localized": true } }
}, },
"cover": { "cover": {
"type": "media", "type": "media",
"multiple": false, "multiple": false,
"allowedTypes": ["images"] "allowedTypes": ["images"],
"pluginOptions": { "i18n": { "localized": false } }
}, },
"category": { "category": {
"type": "relation", "type": "relation",
"relation": "manyToOne", "relation": "manyToOne",
"target": "api::category.category", "target": "api::category.category",
"inversedBy": "articles" "inversedBy": "articles",
"pluginOptions": { "i18n": { "localized": false } }
} }
} }
} }
@@ -10,22 +10,30 @@
"options": { "options": {
"draftAndPublish": false "draftAndPublish": false
}, },
"pluginOptions": {
"i18n": {
"localized": true
}
},
"attributes": { "attributes": {
"name": { "name": {
"type": "string", "type": "string",
"required": true, "required": true,
"unique": true "unique": true,
"pluginOptions": { "i18n": { "localized": true } }
}, },
"slug": { "slug": {
"type": "uid", "type": "uid",
"targetField": "name", "targetField": "name",
"required": true "required": true,
"pluginOptions": { "i18n": { "localized": false } }
}, },
"articles": { "articles": {
"type": "relation", "type": "relation",
"relation": "oneToMany", "relation": "oneToMany",
"target": "api::article.article", "target": "api::article.article",
"mappedBy": "category" "mappedBy": "category",
"pluginOptions": { "i18n": { "localized": false } }
} }
} }
} }
+14
View File
@@ -45,11 +45,25 @@ async function disablePublicSignUp(strapi: Core.Strapi) {
} }
} }
/**
* The site content is authored in Italian and English. Strapi ships with only
* the default `it` locale, so the `en` locale is created here if missing.
*/
async function ensureEnglishLocale(strapi: Core.Strapi) {
const locales = strapi.plugin('i18n').service('locales');
const existing = await locales.find({ where: { code: 'en' } });
if (existing.length === 0) {
await locales.create({ code: 'en', name: 'English (en)', isDefault: false });
}
}
export default { export default {
register() {}, register() {},
async bootstrap({ strapi }: { strapi: Core.Strapi }) { async bootstrap({ strapi }: { strapi: Core.Strapi }) {
await grantPublicReadAccess(strapi); await grantPublicReadAccess(strapi);
await disablePublicSignUp(strapi); await disablePublicSignUp(strapi);
await ensureEnglishLocale(strapi);
}, },
}; };
-3
View File
@@ -9,8 +9,6 @@ services:
cms: cms:
ports: ports:
- "127.0.0.1:1337:1337" - "127.0.0.1:1337:1337"
environment:
STRAPI_URL: http://localhost:1337
frontend: frontend:
ports: ports:
@@ -18,4 +16,3 @@ services:
environment: environment:
NUXT_PUBLIC_SITE_URL: http://localhost:3000 NUXT_PUBLIC_SITE_URL: http://localhost:3000
NUXT_PUBLIC_STRAPI_URL: http://localhost:1337 NUXT_PUBLIC_STRAPI_URL: http://localhost:1337
NUXT_PUBLIC_I18N_BASE_URL: http://localhost:3000
+5 -4
View File
@@ -36,7 +36,6 @@ services:
TRANSFER_TOKEN_SALT: ${TRANSFER_TOKEN_SALT} TRANSFER_TOKEN_SALT: ${TRANSFER_TOKEN_SALT}
JWT_SECRET: ${JWT_SECRET} JWT_SECRET: ${JWT_SECRET}
ENCRYPTION_KEY: ${ENCRYPTION_KEY} ENCRYPTION_KEY: ${ENCRYPTION_KEY}
STRAPI_URL: https://${CMS_DOMAIN}
volumes: volumes:
- cms-uploads:/app/public/uploads - cms-uploads:/app/public/uploads
@@ -52,8 +51,6 @@ services:
NUXT_STRAPI_URL: ${STRAPI_URL} NUXT_STRAPI_URL: ${STRAPI_URL}
NUXT_PUBLIC_SITE_URL: ${PUBLIC_SITE_URL} NUXT_PUBLIC_SITE_URL: ${PUBLIC_SITE_URL}
NUXT_PUBLIC_STRAPI_URL: ${PUBLIC_STRAPI_URL} NUXT_PUBLIC_STRAPI_URL: ${PUBLIC_STRAPI_URL}
# Absolute origin for the alternate-language links.
NUXT_PUBLIC_I18N_BASE_URL: ${PUBLIC_SITE_URL}
caddy: caddy:
image: caddy:2-alpine image: caddy:2-alpine
@@ -64,9 +61,13 @@ services:
ports: ports:
- "80:80" - "80:80"
- "443:443" - "443:443"
# Host uses systemd-resolved (127.0.0.53), unreachable from inside the
# container network namespace; ACME lookups need a real resolver.
dns:
- 1.1.1.1
- 8.8.8.8
environment: environment:
PUBLIC_DOMAIN: ${PUBLIC_DOMAIN} PUBLIC_DOMAIN: ${PUBLIC_DOMAIN}
CMS_DOMAIN: ${CMS_DOMAIN}
ACME_EMAIL: ${ACME_EMAIL} ACME_EMAIL: ${ACME_EMAIL}
volumes: volumes:
- ./caddy/Caddyfile:/etc/caddy/Caddyfile:ro - ./caddy/Caddyfile:/etc/caddy/Caddyfile:ro
+2 -2
View File
@@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
// Emits <html lang>, the alternate-language links and og:locale for every page. const { locale } = useLocale()
useHead(useLocaleHead()) useHead({ htmlAttrs: { lang: locale } })
</script> </script>
<template> <template>
+41 -8
View File
@@ -13,8 +13,18 @@
--width: 76rem; --width: 76rem;
--width-prose: 40rem; --width-prose: 40rem;
--space: 1.5rem;
--radius: 2px; --radius: 2px;
/* Breakpoints used throughout: 48rem = tablet, 64rem = desktop. */
--space: 1.1rem;
--gap-section: 2.5rem;
}
@media (min-width: 48rem) {
:root {
--space: 1.5rem;
--gap-section: 4rem;
}
} }
*, *,
@@ -99,7 +109,7 @@ h3 {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 1.25rem; gap: 1.25rem;
margin-block: 4rem 2rem; margin-block: var(--gap-section) 1.75rem;
} }
.section-heading::after { .section-heading::after {
@@ -111,8 +121,8 @@ h3 {
/* Centred title block at the top of a listing page. */ /* Centred title block at the top of a listing page. */
.page-header { .page-header {
margin-bottom: 3.5rem; margin-bottom: var(--gap-section);
padding-bottom: 2rem; padding-bottom: 1.75rem;
text-align: center; text-align: center;
border-bottom: 1px solid var(--color-border); border-bottom: 1px solid var(--color-border);
} }
@@ -127,18 +137,41 @@ h3 {
.card-grid { .card-grid {
display: grid; display: grid;
gap: 3rem 2.5rem; gap: 2.25rem 1.5rem;
grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); /* One column on phones, two on tablets, three or more on wide screens. */
grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr));
padding: 0; padding: 0;
margin: 0; margin: 0;
list-style: none; list-style: none;
} }
@media (min-width: 48rem) {
.card-grid {
gap: 3rem 2.5rem;
}
}
/* Article body */ /* Article body */
.prose { .prose {
max-width: var(--width-prose); max-width: var(--width-prose);
font-size: 1.0125rem;
/* Editors paste long URLs; without this they push the page sideways. */
overflow-wrap: break-word;
}
@media (min-width: 48rem) {
.prose {
font-size: 1.075rem; font-size: 1.075rem;
} }
}
/* Markdown tables have no wrapper to scroll, so the table scrolls itself. */
.prose table {
display: block;
max-width: 100%;
overflow-x: auto;
border-collapse: collapse;
}
.prose h2, .prose h2,
.prose h3 { .prose h3 {
@@ -193,10 +226,10 @@ h3 {
.pagination { .pagination {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
gap: 2rem; gap: 1rem 2rem;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
margin-top: 4rem; margin-top: var(--gap-section);
padding-top: 2rem; padding-top: 2rem;
border-top: 1px solid var(--color-border); border-top: 1px solid var(--color-border);
font-size: 0.85rem; font-size: 0.85rem;
+10 -11
View File
@@ -3,21 +3,23 @@ import type { ArticleSummary } from '#shared/types/blog'
const props = defineProps<{ article: ArticleSummary }>() const props = defineProps<{ article: ArticleSummary }>()
const { locale } = useI18n()
const mediaUrl = useMediaUrl() const mediaUrl = useMediaUrl()
const cover = computed(() => mediaUrl(props.article.cover)) const cover = computed(() => mediaUrl(props.article.cover))
const { locale } = useLocale()
</script> </script>
<template> <template>
<article class="card"> <article class="card">
<NuxtLinkLocale <!-- No placeholder box when there is no cover: an empty grey rectangle
reads as a broken image rather than as a deliberate choice. -->
<NuxtLink
v-if="cover"
class="cover-link" class="cover-link"
:to="`/blog/${article.slug}`" :to="`/blog/${article.slug}`"
tabindex="-1" tabindex="-1"
aria-hidden="true" aria-hidden="true"
> >
<img <img
v-if="cover"
class="cover" class="cover"
:src="cover" :src="cover"
:alt="article.cover?.alternativeText ?? ''" :alt="article.cover?.alternativeText ?? ''"
@@ -25,13 +27,12 @@ const cover = computed(() => mediaUrl(props.article.cover))
:height="article.cover?.height ?? undefined" :height="article.cover?.height ?? undefined"
loading="lazy" loading="lazy"
> >
<span v-else class="cover placeholder" /> </NuxtLink>
</NuxtLinkLocale>
<p v-if="article.category" class="kicker">{{ article.category.name }}</p> <p v-if="article.category" class="kicker">{{ article.category.name }}</p>
<h2> <h2>
<NuxtLinkLocale :to="`/blog/${article.slug}`">{{ article.title }}</NuxtLinkLocale> <NuxtLink :to="`/blog/${article.slug}`">{{ article.title }}</NuxtLink>
</h2> </h2>
<p class="kicker date"> <p class="kicker date">
@@ -60,11 +61,9 @@ const cover = computed(() => mediaUrl(props.article.cover))
transform: scale(1.03); transform: scale(1.03);
} }
.placeholder { /* Without a cover the kicker leads the card, so it needs no offset. */
display: block; .cover-link + .kicker,
} .cover-link + h2 {
.kicker {
margin-top: 1.1rem; margin-top: 1.1rem;
} }
@@ -1,71 +0,0 @@
<script setup lang="ts">
const { locale, locales, t } = useI18n()
const switchLocalePath = useSwitchLocalePath()
const router = useRouter()
/**
* A native select: it gets keyboard support, the platform picker on mobile and
* correct labelling for free, which a hand-built dropdown would have to rebuild.
*/
function onChange(event: Event) {
const code = (event.target as HTMLSelectElement).value as typeof locale.value
const path = switchLocalePath(code)
if (path) router.push(path)
}
</script>
<template>
<div class="switcher">
<label class="visually-hidden" for="locale-select">{{ t('site.languageLabel') }}</label>
<select id="locale-select" :value="locale" @change="onChange">
<option v-for="option in locales" :key="option.code" :value="option.code">
{{ option.name }}
</option>
</select>
<span class="arrow" aria-hidden="true">▾</span>
</div>
</template>
<style scoped>
.switcher {
position: relative;
display: inline-flex;
align-items: center;
}
select {
appearance: none;
padding: 0.35rem 1.6rem 0.35rem 0.7rem;
border: 1px solid var(--color-border);
border-radius: 0;
background: transparent;
color: var(--color-body);
font: inherit;
font-size: 0.75rem;
font-weight: 600;
letter-spacing: 0.14em;
text-transform: uppercase;
cursor: pointer;
}
select:hover {
border-color: var(--color-ink);
color: var(--color-ink);
}
.arrow {
position: absolute;
right: 0.6rem;
font-size: 0.65rem;
pointer-events: none;
}
.visually-hidden {
position: absolute;
width: 1px;
height: 1px;
overflow: hidden;
clip-path: inset(50%);
white-space: nowrap;
}
</style>
+38
View File
@@ -0,0 +1,38 @@
<script setup lang="ts">
// The official brand marks, inlined at build time from the simple-icons
// package (CC0) rather than redrawn here. Importing the three files directly
// keeps the other ~3000 icons out of the bundle.
import facebookMark from 'simple-icons/icons/facebook.svg?raw'
import instagramMark from 'simple-icons/icons/instagram.svg?raw'
import xMark from 'simple-icons/icons/x.svg?raw'
const MARKS = {
X: xMark,
Instagram: instagramMark,
Facebook: facebookMark,
} as const
const props = defineProps<{ name: keyof typeof MARKS }>()
const mark = computed(() => MARKS[props.name])
</script>
<template>
<!-- eslint-disable-next-line vue/no-v-html -- build-time asset, not user input -->
<span class="icon" aria-hidden="true" v-html="mark" />
</template>
<style scoped>
.icon {
flex: none;
display: inline-flex;
width: 0.95rem;
height: 0.95rem;
}
.icon :deep(svg) {
width: 100%;
height: 100%;
fill: currentColor;
}
</style>
+21
View File
@@ -0,0 +1,21 @@
import { STRINGS, type Strings } from '../i18n/strings'
export type Locale = 'it' | 'en'
/**
* Site language, persisted in a cookie so SSR renders the right language on
* the first request. `t(key)` reads the current locale's UI string.
*/
export function useLocale() {
const locale = useCookie<Locale>('lang', { default: () => 'it', sameSite: 'lax' })
function setLocale(value: Locale) {
locale.value = value
}
function t<K extends keyof Strings>(key: K): Strings[K] {
return STRINGS[locale.value][key]
}
return { locale, setLocale, t }
}
+5 -4
View File
@@ -5,20 +5,21 @@ const props = defineProps<{ error: NuxtError }>()
const isNotFound = computed(() => props.error.statusCode === 404) const isNotFound = computed(() => props.error.statusCode === 404)
useHead(useLocaleHead())
useSeoMeta({ robots: 'noindex' }) useSeoMeta({ robots: 'noindex' })
</script> </script>
<template> <template>
<NuxtLayout> <NuxtLayout>
<h1>{{ isNotFound ? $t('error.notFoundTitle') : $t('error.genericTitle') }}</h1> <h1>{{ isNotFound ? 'Pagina non trovata' : 'Qualcosa è andato storto' }}</h1>
<p class="muted"> <p class="muted">
{{ isNotFound ? $t('error.notFoundBody') : $t('error.genericBody') }} {{ isNotFound
? 'La pagina che cerchi non esiste o è stata spostata.'
: 'Riprova tra qualche istante.' }}
</p> </p>
<p> <p>
<NuxtLinkLocale to="/">{{ $t('error.backHome') }}</NuxtLinkLocale> <NuxtLink to="/">Torna alla home</NuxtLink>
</p> </p>
</NuxtLayout> </NuxtLayout>
</template> </template>
+104
View File
@@ -0,0 +1,104 @@
/** Static UI strings, keyed once and translated for each supported locale. */
export interface Strings {
skipToContent: string
tagline: string
navHome: string
navAllArticles: string
navCorralito: string
navPrimary: string
footerNavigate: string
footerFollow: string
footerContact: string
footerRights: string
switchLanguage: string
loadError: string
noArticlesYet: string
latestFallback: string
readArticle: string
seeAllArticles: string
archiveKicker: string
articlesTitle: string
allArticlesDescription: string
pagePrefix: string
loading: string
pagination: string
prevPage: string
nextPage: string
pageOf: (page: number, pageCount: number) => string
breadcrumbArticles: string
byAuthor: (name: string) => string
backToArticles: string
categoryKicker: string
categoryDescription: (name: string) => string
noArticlesInCategory: string
}
export const STRINGS: Record<'it' | 'en', Strings> = {
it: {
skipToContent: 'Vai al contenuto',
tagline: 'Articoli, guide e analisi.',
navHome: 'Home',
navAllArticles: 'Tutti gli articoli',
navCorralito: 'Come difendersi dal corralito',
navPrimary: 'Navigazione principale',
footerNavigate: 'Naviga',
footerFollow: 'Seguici',
footerContact: 'Contatti:',
footerRights: 'Tutti i diritti riservati.',
switchLanguage: 'English',
loadError: 'Non è stato possibile caricare gli articoli. Riprova più tardi.',
noArticlesYet: 'Non è stato ancora pubblicato nulla.',
latestFallback: 'Ultimo',
readArticle: "Leggi l'articolo",
seeAllArticles: 'Vedi tutti gli articoli',
archiveKicker: "L'archivio",
articlesTitle: 'Articoli',
allArticlesDescription: 'Tutti gli articoli pubblicati sul blog.',
pagePrefix: 'pagina',
loading: 'Caricamento…',
pagination: 'Paginazione',
prevPage: 'Pagina precedente',
nextPage: 'Pagina successiva',
pageOf: (page: number, pageCount: number) => `Pagina ${page} di ${pageCount}`,
breadcrumbArticles: 'Articoli',
byAuthor: (name: string) => `Di ${name}`,
backToArticles: 'Torna a tutti gli articoli',
categoryKicker: 'Categoria',
categoryDescription: (name: string) => `Tutti gli articoli nella categoria ${name}.`,
noArticlesInCategory: 'Non ci sono articoli in questa categoria.',
},
en: {
skipToContent: 'Skip to content',
tagline: 'Articles, guides and analysis.',
navHome: 'Home',
navAllArticles: 'All articles',
navCorralito: 'Come difendersi dal corralito',
navPrimary: 'Main navigation',
footerNavigate: 'Navigate',
footerFollow: 'Follow',
footerContact: 'Contact:',
footerRights: 'All rights reserved.',
switchLanguage: 'Italiano',
loadError: 'The articles could not be loaded. Please try again later.',
noArticlesYet: 'Nothing has been published yet.',
latestFallback: 'Latest',
readArticle: 'Read the article',
seeAllArticles: 'See all articles',
archiveKicker: 'The archive',
articlesTitle: 'Articles',
allArticlesDescription: 'All articles published on the blog.',
pagePrefix: 'page',
loading: 'Loading…',
pagination: 'Pagination',
prevPage: 'Previous page',
nextPage: 'Next page',
pageOf: (page: number, pageCount: number) => `Page ${page} of ${pageCount}`,
breadcrumbArticles: 'Articles',
byAuthor: (name: string) => `By ${name}`,
backToArticles: 'Back to all articles',
categoryKicker: 'Category',
categoryDescription: (name: string) => `All articles in the ${name} category.`,
noArticlesInCategory: 'There are no articles in this category.',
},
}
+125 -43
View File
@@ -1,39 +1,43 @@
<script setup lang="ts"> <script setup lang="ts">
import type { Category } from '#shared/types/blog' const { locale, setLocale, t } = useLocale()
const { locale } = useI18n() const otherLocale = computed(() => (locale.value === 'it' ? 'en' : 'it'))
const { data: categories } = await useFetch<Category[]>('/api/categories', { /**
key: 'nav-categories', * Switches the site language. On an article/category page, jumps to the
default: () => [], * translated counterpart's slug if one exists; elsewhere reloads the current
}) * route so it refetches its content in the new language.
*/
function switchLanguage() {
setLocale(otherLocale.value)
reloadNuxtApp({ path: useRoute().fullPath })
}
</script> </script>
<template> <template>
<div class="page"> <div class="page">
<a class="skip-link" href="#main">{{ $t('site.skipToContent') }}</a> <a class="skip-link" href="#main">{{ t('skipToContent') }}</a>
<header class="site-header"> <header class="site-header">
<div class="container"> <div class="container">
<p class="wordmark"> <p class="wordmark">
<NuxtLinkLocale to="/"> <NuxtLink to="/">
<img src="/logo.png" :alt="SITE_NAME" width="400" height="400"> <img src="/logo.png" :alt="SITE_NAME" width="400" height="400">
</NuxtLinkLocale> </NuxtLink>
</p> </p>
<p class="tagline kicker">{{ $t('site.tagline') }}</p> <p class="tagline kicker">{{ t('tagline') }}</p>
</div> </div>
<nav class="site-nav" :aria-label="$t('site.mainNavigation')"> <nav class="site-nav" :aria-label="t('navPrimary')">
<div class="container nav-inner"> <div class="container nav-inner">
<ul> <ul>
<li><NuxtLinkLocale to="/blog">{{ $t('site.allArticles') }}</NuxtLinkLocale></li> <li><NuxtLink to="/">{{ t('navHome') }}</NuxtLink></li>
<li v-for="category in categories" :key="category.slug"> <li><NuxtLink to="/blog">{{ t('navAllArticles') }}</NuxtLink></li>
<NuxtLinkLocale :to="`/category/${category.slug}`"> <li><NuxtLink to="/come-difendersi-dal-corralito">{{ t('navCorralito') }}</NuxtLink></li>
{{ category.name }}
</NuxtLinkLocale>
</li>
</ul> </ul>
<LanguageSwitcher /> <button type="button" class="lang-switch" @click="switchLanguage">
{{ t('switchLanguage') }}
</button>
</div> </div>
</nav> </nav>
</header> </header>
@@ -46,36 +50,37 @@ const { data: categories } = await useFetch<Category[]>('/api/categories', {
<div class="container footer-inner"> <div class="container footer-inner">
<div class="footer-block"> <div class="footer-block">
<img class="footer-logo" src="/logo.png" :alt="SITE_NAME" width="400" height="400"> <img class="footer-logo" src="/logo.png" :alt="SITE_NAME" width="400" height="400">
<p class="muted">{{ $t('site.tagline') }}</p> <p class="muted">{{ t('tagline') }}</p>
<address class="contact"> <address class="contact">
{{ $t('site.contact') }}: {{ t('footerContact') }}
<a :href="`mailto:${SITE_EMAIL}`">{{ SITE_EMAIL }}</a> <a :href="`mailto:${SITE_EMAIL}`">{{ SITE_EMAIL }}</a>
</address> </address>
</div> </div>
<nav class="footer-block" :aria-label="$t('site.categories')"> <nav class="footer-block" :aria-label="t('footerNavigate')">
<p class="kicker">{{ $t('site.categories') }}</p> <p class="kicker">{{ t('footerNavigate') }}</p>
<ul> <ul>
<li v-for="category in categories" :key="category.slug"> <li><NuxtLink to="/">{{ t('navHome') }}</NuxtLink></li>
<NuxtLinkLocale :to="`/category/${category.slug}`"> <li><NuxtLink to="/blog">{{ t('navAllArticles') }}</NuxtLink></li>
{{ category.name }} <li><NuxtLink to="/come-difendersi-dal-corralito">{{ t('navCorralito') }}</NuxtLink></li>
</NuxtLinkLocale>
</li>
<li v-if="!categories.length" class="muted">{{ $t('site.noCategories') }}</li>
</ul> </ul>
</nav> </nav>
<nav class="footer-block" :aria-label="$t('site.browse')"> <nav class="footer-block" :aria-label="t('footerFollow')">
<p class="kicker">{{ $t('site.browse') }}</p> <p class="kicker">{{ t('footerFollow') }}</p>
<ul> <ul>
<li><NuxtLinkLocale to="/">{{ $t('site.home') }}</NuxtLinkLocale></li> <li v-for="social in SOCIAL_LINKS" :key="social.name">
<li><NuxtLinkLocale to="/blog">{{ $t('site.allArticles') }}</NuxtLinkLocale></li> <a class="social" :href="social.url" target="_blank" rel="noopener me">
<SocialIcon :name="social.name" />
<span>{{ social.name }}</span>
</a>
</li>
</ul> </ul>
</nav> </nav>
</div> </div>
<p class="container copyright kicker" :lang="locale"> <p class="container copyright kicker">
&copy; {{ new Date().getFullYear() }} {{ SITE_NAME }}. {{ $t('site.rights') }} &copy; {{ new Date().getFullYear() }} {{ SITE_NAME }}. {{ t('footerRights') }}
</p> </p>
</footer> </footer>
</div> </div>
@@ -90,11 +95,17 @@ const { data: categories } = await useFetch<Category[]>('/api/categories', {
/* Header: centred wordmark over a thin rule of links. */ /* Header: centred wordmark over a thin rule of links. */
.site-header { .site-header {
padding-top: 2.5rem; padding-top: 1.5rem;
text-align: center; text-align: center;
border-bottom: 1px solid var(--color-border); border-bottom: 1px solid var(--color-border);
} }
@media (min-width: 48rem) {
.site-header {
padding-top: 2.5rem;
}
}
.wordmark { .wordmark {
margin: 0; margin: 0;
} }
@@ -115,23 +126,23 @@ const { data: categories } = await useFetch<Category[]>('/api/categories', {
} }
.site-nav { .site-nav {
margin-top: 2rem; margin-top: 1.25rem;
border-top: 1px solid var(--color-border); border-top: 1px solid var(--color-border);
} }
.nav-inner { .nav-inner {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
gap: 0.75rem 2rem; justify-content: center;
align-items: center; align-items: center;
justify-content: space-between; gap: 0.75rem 1.5rem;
padding-block: 0.9rem; padding-block: 0.6rem;
} }
.site-nav ul { .site-nav ul {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
gap: 0.25rem 2rem; gap: 0 1.25rem;
justify-content: center; justify-content: center;
padding: 0; padding: 0;
margin: 0; margin: 0;
@@ -142,10 +153,44 @@ const { data: categories } = await useFetch<Category[]>('/api/categories', {
text-transform: uppercase; text-transform: uppercase;
} }
.lang-switch {
font: inherit;
font-size: 0.75rem;
font-weight: 600;
letter-spacing: 0.14em;
text-transform: uppercase;
padding: 0.35rem 0.75rem;
color: var(--color-body);
background: none;
border: 1px solid var(--color-border);
cursor: pointer;
}
.lang-switch:hover {
color: var(--color-ink);
border-color: var(--color-ink);
}
@media (min-width: 48rem) {
.site-nav {
margin-top: 2rem;
}
.nav-inner {
padding-block: 0.9rem;
}
.site-nav ul {
gap: 0.25rem 2rem;
}
}
.site-nav a { .site-nav a {
display: inline-block;
text-decoration: none; text-decoration: none;
color: var(--color-body); color: var(--color-body);
padding-block: 0.25rem; /* Roomy enough to tap accurately on a phone. */
padding-block: 0.6rem;
border-bottom: 1px solid transparent; border-bottom: 1px solid transparent;
} }
@@ -157,8 +202,14 @@ const { data: categories } = await useFetch<Category[]>('/api/categories', {
.site-main { .site-main {
flex: 1; flex: 1;
padding-block: 2.25rem 3.5rem;
}
@media (min-width: 48rem) {
.site-main {
padding-block: 3.5rem 5rem; padding-block: 3.5rem 5rem;
} }
}
/* Footer: columns, then a centred copyright line. */ /* Footer: columns, then a centred copyright line. */
.site-footer { .site-footer {
@@ -167,13 +218,28 @@ const { data: categories } = await useFetch<Category[]>('/api/categories', {
border-top: 1px solid var(--color-border); border-top: 1px solid var(--color-border);
} }
/* One column on phones, two on tablets, four on desktop — auto-fit would
otherwise leave the fourth block stranded on its own row on a tablet. */
.footer-inner { .footer-inner {
display: grid; display: grid;
gap: 2.5rem; gap: 2rem;
grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); grid-template-columns: 1fr;
padding-bottom: 2.5rem; padding-bottom: 2.5rem;
} }
@media (min-width: 48rem) {
.footer-inner {
grid-template-columns: repeat(2, 1fr);
gap: 2.5rem;
}
}
@media (min-width: 64rem) {
.footer-inner {
grid-template-columns: repeat(4, 1fr);
}
}
.footer-block p:last-of-type { .footer-block p:last-of-type {
margin-bottom: 0; margin-bottom: 0;
} }
@@ -215,6 +281,22 @@ const { data: categories } = await useFetch<Category[]>('/api/categories', {
text-underline-offset: 0.2em; text-underline-offset: 0.2em;
} }
.social {
display: inline-flex;
align-items: center;
gap: 0.55rem;
}
/* Keep the underline on the label, not stretched across the icon. */
.social:hover {
text-decoration: none;
}
.social:hover span {
text-decoration: underline;
text-underline-offset: 0.2em;
}
.copyright { .copyright {
padding-top: 1.75rem; padding-top: 1.75rem;
text-align: center; text-align: center;
+30 -10
View File
@@ -1,11 +1,15 @@
<script setup lang="ts"> <script setup lang="ts">
import type { Article } from '#shared/types/blog' import type { Article } from '#shared/types/blog'
const { locale } = useI18n()
const route = useRoute() const route = useRoute()
const slug = route.params.slug as string const slug = route.params.slug as string
const { data: article } = await useFetch<Article>(`/api/articles/${slug}`) const { locale, t } = useLocale()
const { data: article } = await useFetch<Article>(`/api/articles/${slug}`, {
key: () => `article-${slug}-${locale.value}`,
query: { lang: locale },
})
if (!article.value) { if (!article.value) {
throw createError({ statusCode: 404, statusMessage: 'Article not found', fatal: true }) throw createError({ statusCode: 404, statusMessage: 'Article not found', fatal: true })
@@ -39,6 +43,10 @@ useHead({
headline: article.value.title, headline: article.value.title,
description: article.value.summary, description: article.value.summary,
datePublished: isoDate(article.value.publishedAt), datePublished: isoDate(article.value.publishedAt),
inLanguage: locale.value,
author: article.value.author
? { '@type': 'Person', name: article.value.author }
: undefined,
image: cover.value ? [cover.value] : undefined, image: cover.value ? [cover.value] : undefined,
mainEntityOfPage: { '@type': 'WebPage', '@id': canonical }, mainEntityOfPage: { '@type': 'WebPage', '@id': canonical },
}), }),
@@ -50,13 +58,13 @@ useHead({
<template> <template>
<article v-if="article"> <article v-if="article">
<header class="article-header"> <header class="article-header">
<nav class="kicker" :aria-label="$t('article.breadcrumb')"> <nav class="kicker" aria-label="Percorso di navigazione">
<NuxtLinkLocale to="/blog">{{ $t('list.articles') }}</NuxtLinkLocale> <NuxtLink to="/blog">{{ t('breadcrumbArticles') }}</NuxtLink>
<template v-if="article.category"> <template v-if="article.category">
<span aria-hidden="true"> / </span> <span aria-hidden="true"> / </span>
<NuxtLinkLocale :to="`/category/${article.category.slug}`"> <NuxtLink :to="`/category/${article.category.slug}`">
{{ article.category.name }} {{ article.category.name }}
</NuxtLinkLocale> </NuxtLink>
</template> </template>
</nav> </nav>
@@ -64,8 +72,12 @@ useHead({
<p class="kicker date"> <p class="kicker date">
<time :datetime="isoDate(article.publishedAt)"> <time :datetime="isoDate(article.publishedAt)">
{{ formatDate(article.publishedAt, locale) }} {{ formatDateTime(article.publishedAt, locale) }}
</time> </time>
<template v-if="article.author">
<span aria-hidden="true"> · </span>
<span>{{ t('byAuthor')(article.author) }}</span>
</template>
</p> </p>
</header> </header>
@@ -82,7 +94,7 @@ useHead({
<div class="prose" v-html="article.html" /> <div class="prose" v-html="article.html" />
<p class="back"> <p class="back">
<NuxtLinkLocale to="/blog">{{ $t('article.back') }}</NuxtLinkLocale> <NuxtLink to="/blog">{{ t('backToArticles') }}</NuxtLink>
</p> </p>
</article> </article>
</template> </template>
@@ -90,10 +102,18 @@ useHead({
<style scoped> <style scoped>
.article-header { .article-header {
max-width: 46rem; max-width: 46rem;
margin-inline: auto; /* The gap below the header lives here, not on the cover: an article without
a cover image would otherwise have its body butting against the byline. */
margin: 0 auto 2rem;
text-align: center; text-align: center;
} }
@media (min-width: 48rem) {
.article-header {
margin-bottom: 3rem;
}
}
.article-header nav a { .article-header nav a {
text-decoration: none; text-decoration: none;
} }
@@ -139,7 +159,7 @@ h1 {
width: 100%; width: 100%;
aspect-ratio: 3 / 2; aspect-ratio: 3 / 2;
object-fit: cover; object-fit: cover;
margin-block: 3rem; margin-block: 0 3rem;
background: var(--color-surface); background: var(--color-surface);
} }
</style> </style>
+15 -13
View File
@@ -1,7 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import type { ArticleSummary, Paginated } from '#shared/types/blog' import type { ArticleSummary, Paginated } from '#shared/types/blog'
const { t } = useI18n()
const route = useRoute() const route = useRoute()
const page = computed(() => { const page = computed(() => {
@@ -9,8 +8,11 @@ const page = computed(() => {
return Number.isInteger(value) && value > 0 ? value : 1 return Number.isInteger(value) && value > 0 ? value : 1
}) })
const { locale, t } = useLocale()
const { data, error, status } = await useFetch<Paginated<ArticleSummary>>('/api/articles', { const { data, error, status } = await useFetch<Paginated<ArticleSummary>>('/api/articles', {
query: { page }, key: () => `blog-articles-${locale.value}-${page.value}`,
query: { page, lang: locale },
}) })
const { public: config } = useRuntimeConfig() const { public: config } = useRuntimeConfig()
@@ -19,8 +21,8 @@ const canonical = computed(
) )
useSeoMeta({ useSeoMeta({
title: () => (page.value > 1 ? t('list.articlesPage', { page: page.value }) : t('list.articles')), title: () => (page.value > 1 ? `${t('articlesTitle')} — ${t('pagePrefix')} ${page.value}` : t('articlesTitle')),
description: () => t('list.archiveDescription'), description: () => t('allArticlesDescription'),
ogType: 'website', ogType: 'website',
}) })
@@ -30,15 +32,15 @@ useHead({ link: [{ rel: 'canonical', href: canonical }] })
<template> <template>
<div> <div>
<header class="page-header"> <header class="page-header">
<p class="kicker">{{ $t('list.archive') }}</p> <p class="kicker">{{ t('archiveKicker') }}</p>
<h1>{{ $t('list.articles') }}</h1> <h1>{{ t('articlesTitle') }}</h1>
</header> </header>
<p v-if="error">{{ $t('list.failed') }}</p> <p v-if="error">{{ t('loadError') }}</p>
<p v-else-if="status === 'pending'">{{ $t('list.loading') }}</p> <p v-else-if="status === 'pending'">{{ t('loading') }}</p>
<p v-else-if="!data?.items.length">{{ $t('list.empty') }}</p> <p v-else-if="!data?.items.length">{{ t('noArticlesYet') }}</p>
<template v-else> <template v-else>
<ul class="card-grid"> <ul class="card-grid">
@@ -47,19 +49,19 @@ useHead({ link: [{ rel: 'canonical', href: canonical }] })
</li> </li>
</ul> </ul>
<nav v-if="data.pageCount > 1" class="pagination" :aria-label="$t('pagination.label')"> <nav v-if="data.pageCount > 1" class="pagination" :aria-label="t('pagination')">
<NuxtLink v-if="data.page > 1" :to="{ query: { page: data.page - 1 } }" rel="prev"> <NuxtLink v-if="data.page > 1" :to="{ query: { page: data.page - 1 } }" rel="prev">
{{ $t('pagination.previous') }} {{ t('prevPage') }}
</NuxtLink> </NuxtLink>
<span class="muted"> <span class="muted">
{{ $t('pagination.position', { page: data.page, total: data.pageCount }) }} {{ t('pageOf')(data.page, data.pageCount) }}
</span> </span>
<NuxtLink <NuxtLink
v-if="data.page < data.pageCount" v-if="data.page < data.pageCount"
:to="{ query: { page: data.page + 1 } }" :to="{ query: { page: data.page + 1 } }"
rel="next" rel="next"
> >
{{ $t('pagination.next') }} {{ t('nextPage') }}
</NuxtLink> </NuxtLink>
</nav> </nav>
</template> </template>
+17 -12
View File
@@ -1,7 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import type { ArticleSummary, Paginated, Category } from '#shared/types/blog' import type { ArticleSummary, Paginated, Category } from '#shared/types/blog'
const { t } = useI18n()
const route = useRoute() const route = useRoute()
const slug = route.params.slug as string const slug = route.params.slug as string
@@ -10,14 +9,20 @@ const page = computed(() => {
return Number.isInteger(value) && value > 0 ? value : 1 return Number.isInteger(value) && value > 0 ? value : 1
}) })
const { data: category } = await useFetch<Category>(`/api/categories/${slug}`) const { locale, t } = useLocale()
const { data: category } = await useFetch<Category>(`/api/categories/${slug}`, {
key: () => `category-${slug}-${locale.value}`,
query: { lang: locale },
})
if (!category.value) { if (!category.value) {
throw createError({ statusCode: 404, statusMessage: 'Category not found', fatal: true }) throw createError({ statusCode: 404, statusMessage: 'Category not found', fatal: true })
} }
const { data, error } = await useFetch<Paginated<ArticleSummary>>('/api/articles', { const { data, error } = await useFetch<Paginated<ArticleSummary>>('/api/articles', {
query: { page, category: slug }, key: () => `category-articles-${slug}-${locale.value}-${page.value}`,
query: { page, category: slug, lang: locale },
}) })
const { public: config } = useRuntimeConfig() const { public: config } = useRuntimeConfig()
@@ -26,8 +31,8 @@ const canonical = computed(
) )
useSeoMeta({ useSeoMeta({
title: category.value.name, title: () => category.value?.name ?? '',
description: () => t('list.categoryDescription', { name: category.value?.name ?? '' }), description: () => t('categoryDescription')(category.value?.name ?? ''),
ogType: 'website', ogType: 'website',
}) })
@@ -37,13 +42,13 @@ useHead({ link: [{ rel: 'canonical', href: canonical }] })
<template> <template>
<div> <div>
<header class="page-header"> <header class="page-header">
<p class="kicker">{{ $t('list.category') }}</p> <p class="kicker">{{ t('categoryKicker') }}</p>
<h1>{{ category?.name }}</h1> <h1>{{ category?.name }}</h1>
</header> </header>
<p v-if="error">{{ $t('list.failed') }}</p> <p v-if="error">{{ t('loadError') }}</p>
<p v-else-if="!data?.items.length">{{ $t('list.categoryEmpty') }}</p> <p v-else-if="!data?.items.length">{{ t('noArticlesInCategory') }}</p>
<template v-else> <template v-else>
<ul class="card-grid"> <ul class="card-grid">
@@ -52,19 +57,19 @@ useHead({ link: [{ rel: 'canonical', href: canonical }] })
</li> </li>
</ul> </ul>
<nav v-if="data.pageCount > 1" class="pagination" :aria-label="$t('pagination.label')"> <nav v-if="data.pageCount > 1" class="pagination" :aria-label="t('pagination')">
<NuxtLink v-if="data.page > 1" :to="{ query: { page: data.page - 1 } }" rel="prev"> <NuxtLink v-if="data.page > 1" :to="{ query: { page: data.page - 1 } }" rel="prev">
{{ $t('pagination.previous') }} {{ t('prevPage') }}
</NuxtLink> </NuxtLink>
<span class="muted"> <span class="muted">
{{ $t('pagination.position', { page: data.page, total: data.pageCount }) }} {{ t('pageOf')(data.page, data.pageCount) }}
</span> </span>
<NuxtLink <NuxtLink
v-if="data.page < data.pageCount" v-if="data.page < data.pageCount"
:to="{ query: { page: data.page + 1 } }" :to="{ query: { page: data.page + 1 } }"
rel="next" rel="next"
> >
{{ $t('pagination.next') }} {{ t('nextPage') }}
</NuxtLink> </NuxtLink>
</nav> </nav>
</template> </template>
@@ -0,0 +1,132 @@
<script setup lang="ts">
const { public: config } = useRuntimeConfig()
const route = useRoute()
const canonical = computed(() => `${config.siteUrl}${route.path}`)
const title = 'Corsi di formazione sulle criptovalute'
const description = 'Corsi pratici, individuali o di gruppo, per capire come funzionano le criptovalute e difendersi dal corralito.'
useSeoMeta({
title,
description,
ogTitle: title,
ogDescription: description,
ogType: 'website',
ogUrl: canonical,
ogImage: `${config.siteUrl}/protesta-bancaria.jpg`,
})
useHead({ link: [{ rel: 'canonical', href: canonical }] })
</script>
<template>
<article>
<header class="article-header">
<h1>Come difendersi dal corralito</h1>
</header>
<img
class="cover"
src="/protesta-bancaria.jpg"
alt="Manifesti e scritte contro le banche durante una crisi bancaria"
width="770"
height="420"
>
<div class="prose">
<p>
Stai pensando di avvicinarti al mondo delle criptovalute (un mercato parallelo al
mercato tradizionale finanziario), ma non sai da dove cominciare?
</p>
<p>
È possibile organizzare corsi individuali o di gruppo dedicati alla conoscenza e al
funzionamento delle criptovalute, con un approccio prevalentemente pratico e senza
fornire consigli o raccomandazioni finanziarie.
</p>
<p>Durante il corso possiamo affrontare, tra gli altri, questi argomenti:</p>
<ul>
<li>quali sono i principali tipi di criptovalute e quali differenze esistono tra loro;</li>
<li>come funziona una blockchain e cosa significa realmente effettuare una transazione;</li>
<li>dove e come vengono conservate le criptovalute: wallet, exchange e sistemi di custodia;</li>
<li>come acquistare e vendere criptovalute e quali sono le principali modalità disponibili;</li>
<li>come utilizzare un wallet e gestire correttamente le proprie chiavi;</li>
<li>quali sono i principali rischi legati alla sicurezza e alla custodia;</li>
<li>come orientarsi nel vastissimo universo delle criptovalute e dei token.</li>
</ul>
<p>
Non si tratta di consulenza finanziaria e non verranno fornite indicazioni su quali
criptovalute acquistare o vendere. L'obiettivo è fornire conoscenze e strumenti per
comprendere questo nuovo mondo e muoversi al suo interno con maggiore consapevolezza.
</p>
</div>
<div class="contact-cta">
<p class="kicker">Per informazioni sui corsi, modalità e disponibilità</p>
<p class="contact-links">
<a :href="`mailto:${SITE_EMAIL}`">Scrivimi via email</a>
<span aria-hidden="true">·</span>
<a href="https://t.me/Ito1505" target="_blank" rel="noopener">Scrivimi su Telegram</a>
</p>
</div>
</article>
</template>
<style scoped>
.article-header {
max-width: 46rem;
margin: 0 auto 2rem;
text-align: center;
}
@media (min-width: 48rem) {
.article-header {
margin-bottom: 3rem;
}
}
.cover {
width: 100%;
aspect-ratio: 16 / 9;
object-fit: cover;
margin-block: 0 3rem;
background: var(--color-surface);
}
.prose {
margin-inline: auto;
}
.contact-cta {
max-width: var(--width-prose);
margin: 3rem auto 0;
padding-top: 2rem;
border-top: 1px solid var(--color-border);
text-align: center;
}
.contact-links {
margin-top: 0.75rem;
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 0.6rem;
font-size: 0.75rem;
font-weight: 600;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.contact-links a {
padding-bottom: 0.35rem;
text-decoration: none;
border-bottom: 1px solid var(--color-ink);
}
.contact-links a:hover {
color: var(--color-ink);
}
</style>
+102 -41
View File
@@ -1,16 +1,14 @@
<script setup lang="ts"> <script setup lang="ts">
import type { ArticleSummary, Paginated } from '#shared/types/blog' import type { ArticleSummary, Paginated } from '#shared/types/blog'
const { t, locale } = useI18n() const { locale, t } = useLocale()
const { data, error } = await useFetch<Paginated<ArticleSummary>>('/api/articles', { const { data, error } = await useFetch<Paginated<ArticleSummary>>('/api/articles', {
key: 'home-articles', key: () => `home-articles-${locale.value}`,
query: { page: 1 }, query: { page: 1, lang: locale },
}) })
/** The newest article leads the page; the next six fill the grid below it. */
const featured = computed(() => data.value?.items[0] ?? null) const featured = computed(() => data.value?.items[0] ?? null)
const rest = computed(() => data.value?.items.slice(1, 7) ?? [])
const mediaUrl = useMediaUrl() const mediaUrl = useMediaUrl()
const featuredCover = computed(() => mediaUrl(featured.value?.cover)) const featuredCover = computed(() => mediaUrl(featured.value?.cover))
@@ -24,9 +22,9 @@ useHead({ titleTemplate: '%s', link: [{ rel: 'canonical', href: canonical }] })
useSeoMeta({ useSeoMeta({
title: SITE_NAME, title: SITE_NAME,
description: () => t('site.tagline'), description: () => t('tagline'),
ogTitle: SITE_NAME, ogTitle: SITE_NAME,
ogDescription: () => t('site.tagline'), ogDescription: () => t('tagline'),
ogType: 'website', ogType: 'website',
ogUrl: canonical, ogUrl: canonical,
ogImage: `${config.siteUrl}/logo.png`, ogImage: `${config.siteUrl}/logo.png`,
@@ -35,103 +33,166 @@ useSeoMeta({
<template> <template>
<div> <div>
<p v-if="error">{{ $t('list.failed') }}</p> <section class="landing">
<img
class="landing-image"
src="/protesta-bancaria.jpg"
alt="Manifesti e scritte contro le banche durante una crisi bancaria"
width="770"
height="420"
>
<p v-else-if="!featured">{{ $t('list.empty') }}</p> <h1>La fine dell'Unione Europea per come l'abbiamo conosciuta.</h1>
<img
class="landing-image"
src="/eurozona-crisi.jpg"
alt="Bandiera dell'Unione Europea incrinata"
width="1000"
height="736"
>
<div class="landing-text">
<p>
La fine della nostra moneta come moneta forte: la fine di quella moneta che ci ha
dato la vera libertà di viaggiare, consumare e fare.
</p>
<p>
Una fine che avverrà a seguito di un "incidente" nucleare, al quale farà seguito un
corralito bancario, ossia l'impossibilità, da parte dei cittadini europei, di
disporre liberamente dei propri depositi.
</p>
<p>
Le monete fiduciarie sono per loro natura cannibalizzanti. Oggi tocca all'euro.
Anche perché le altre hanno praticamente perso tutte tutto.
</p>
</div>
</section>
<p v-if="error">{{ t('loadError') }}</p>
<p v-else-if="!featured">{{ t('noArticlesYet') }}</p>
<template v-else> <template v-else>
<article class="featured"> <article class="featured" :class="{ 'has-cover': featuredCover }">
<NuxtLinkLocale <NuxtLink
v-if="featuredCover"
class="featured-cover" class="featured-cover"
:to="`/blog/${featured.slug}`" :to="`/blog/${featured.slug}`"
tabindex="-1" tabindex="-1"
aria-hidden="true" aria-hidden="true"
> >
<img <img
v-if="featuredCover"
:src="featuredCover" :src="featuredCover"
:alt="featured.cover?.alternativeText ?? ''" :alt="featured.cover?.alternativeText ?? ''"
:width="featured.cover?.width ?? undefined" :width="featured.cover?.width ?? undefined"
:height="featured.cover?.height ?? undefined" :height="featured.cover?.height ?? undefined"
> >
<span v-else class="placeholder" /> </NuxtLink>
</NuxtLinkLocale>
<div class="featured-text"> <div class="featured-text">
<p class="kicker"> <p class="kicker">
{{ featured.category ? featured.category.name : $t('home.latest') }} {{ featured.category ? featured.category.name : t('latestFallback') }}
</p> </p>
<h1> <h2>
<NuxtLinkLocale :to="`/blog/${featured.slug}`">{{ featured.title }}</NuxtLinkLocale> <NuxtLink :to="`/blog/${featured.slug}`">{{ featured.title }}</NuxtLink>
</h1> </h2>
<p class="kicker date"> <p class="kicker date">
<time :datetime="isoDate(featured.publishedAt)"> <time :datetime="isoDate(featured.publishedAt)">
{{ formatDate(featured.publishedAt, locale) }} {{ formatDate(featured.publishedAt, locale) }}
</time> </time>
</p> </p>
<p class="read-more"> <p class="read-more">
<NuxtLinkLocale :to="`/blog/${featured.slug}`"> <NuxtLink :to="`/blog/${featured.slug}`">
{{ $t('home.readArticle') }} {{ t('readArticle') }}
</NuxtLinkLocale> </NuxtLink>
</p> </p>
</div> </div>
</article> </article>
<template v-if="rest.length">
<h2 class="section-heading kicker">{{ $t('home.moreStories') }}</h2>
<ul class="card-grid">
<li v-for="article in rest" :key="article.slug">
<ArticleCard :article="article" />
</li>
</ul>
</template>
<p class="more"> <p class="more">
<NuxtLinkLocale to="/blog">{{ $t('home.viewAll') }}</NuxtLinkLocale> <NuxtLink to="/blog">{{ t('seeAllArticles') }}</NuxtLink>
</p> </p>
</template> </template>
</div> </div>
</template> </template>
<style scoped> <style scoped>
.landing {
max-width: var(--width-prose);
margin-inline: auto;
margin-bottom: var(--gap-section);
padding-bottom: var(--gap-section);
border-bottom: 1px solid var(--color-border);
text-align: center;
}
.landing-image {
width: 100%;
aspect-ratio: 16 / 9;
object-fit: cover;
background: var(--color-surface);
}
.landing h1 {
margin-block: 1.75rem;
font-size: clamp(2rem, 4.5vw, 3.1rem);
}
.landing-text {
margin-top: 1.75rem;
text-align: left;
}
.landing-text p {
margin-top: 1.1rem;
}
.featured { .featured {
display: grid; display: grid;
gap: 2.5rem; gap: 1.5rem;
align-items: center; align-items: center;
grid-template-columns: 1fr; grid-template-columns: 1fr;
} }
@media (min-width: 52rem) { /* Stacked on phones and portrait tablets — a side-by-side split below this
.featured { width leaves both the image and the headline too cramped to read. The split
also needs a cover to sit in it, or one column would just be empty. */
@media (min-width: 64rem) {
.featured.has-cover {
grid-template-columns: 1.35fr 1fr; grid-template-columns: 1.35fr 1fr;
gap: 3.5rem; gap: 3.5rem;
} }
} }
/* Without a cover the headline is the whole lead, so it gets the full width
but stays inside a readable measure. */
.featured:not(.has-cover) .featured-text {
max-width: 46rem;
}
.featured-cover { .featured-cover {
display: block; display: block;
overflow: hidden; overflow: hidden;
} }
.featured-cover img, .featured-cover img {
.placeholder {
width: 100%; width: 100%;
aspect-ratio: 3 / 2; aspect-ratio: 3 / 2;
object-fit: cover; object-fit: cover;
background: var(--color-surface); background: var(--color-surface);
} }
.featured h1 { .featured h2 {
margin-top: 0.6rem; margin-top: 0.6rem;
font-size: clamp(2rem, 4.5vw, 3.1rem); font-size: clamp(2rem, 4.5vw, 3.1rem);
} }
.featured h1 a { .featured h2 a {
text-decoration: none; text-decoration: none;
} }
.featured h1 a:hover { .featured h2 a:hover {
text-decoration: underline; text-decoration: underline;
text-underline-offset: 0.12em; text-underline-offset: 0.12em;
} }
@@ -156,7 +217,7 @@ useSeoMeta({
} }
.more { .more {
margin-top: 4rem; margin-top: var(--gap-section);
text-align: center; text-align: center;
font-size: 0.75rem; font-size: 0.75rem;
font-weight: 600; font-weight: 600;
-50
View File
@@ -1,50 +0,0 @@
{
"site": {
"tagline": "Articles, guides and analysis.",
"skipToContent": "Skip to content",
"mainNavigation": "Main navigation",
"languageLabel": "Language",
"allArticles": "All articles",
"home": "Home",
"browse": "Browse",
"categories": "Categories",
"contact": "Contact",
"noCategories": "Nothing published yet",
"rights": "All rights reserved."
},
"home": {
"latest": "Latest",
"readArticle": "Read the article",
"moreStories": "More stories",
"viewAll": "View all articles"
},
"list": {
"archive": "The archive",
"articles": "Articles",
"articlesPage": "Articles — page {page}",
"archiveDescription": "Every article published on the blog.",
"category": "Category",
"categoryDescription": "Every article in the {name} category.",
"loading": "Loading…",
"empty": "Nothing has been published yet.",
"categoryEmpty": "There are no articles in this category.",
"failed": "Articles could not be loaded. Please try again later."
},
"pagination": {
"label": "Pagination",
"previous": "Previous page",
"next": "Next page",
"position": "Page {page} of {total}"
},
"article": {
"breadcrumb": "Breadcrumb",
"back": "Back to all articles"
},
"error": {
"notFoundTitle": "Page not found",
"notFoundBody": "The page you are looking for does not exist or has moved.",
"genericTitle": "Something went wrong",
"genericBody": "Please try again in a moment.",
"backHome": "Back to home"
}
}
-50
View File
@@ -1,50 +0,0 @@
{
"site": {
"tagline": "Artículos, guías y análisis.",
"skipToContent": "Ir al contenido",
"mainNavigation": "Navegación principal",
"languageLabel": "Idioma",
"allArticles": "Todos los artículos",
"home": "Inicio",
"browse": "Explorar",
"categories": "Categorías",
"contact": "Contacto",
"noCategories": "Aún no hay publicaciones",
"rights": "Todos los derechos reservados."
},
"home": {
"latest": "Último",
"readArticle": "Leer el artículo",
"moreStories": "Más artículos",
"viewAll": "Ver todos los artículos"
},
"list": {
"archive": "El archivo",
"articles": "Artículos",
"articlesPage": "Artículos — página {page}",
"archiveDescription": "Todos los artículos publicados en el blog.",
"category": "Categoría",
"categoryDescription": "Todos los artículos de la categoría {name}.",
"loading": "Cargando…",
"empty": "Todavía no se ha publicado nada.",
"categoryEmpty": "No hay artículos en esta categoría.",
"failed": "No se han podido cargar los artículos. Inténtalo de nuevo más tarde."
},
"pagination": {
"label": "Paginación",
"previous": "Página anterior",
"next": "Página siguiente",
"position": "Página {page} de {total}"
},
"article": {
"breadcrumb": "Ruta de navegación",
"back": "Volver a todos los artículos"
},
"error": {
"notFoundTitle": "Página no encontrada",
"notFoundBody": "La página que buscas no existe o se ha movido.",
"genericTitle": "Algo ha salido mal",
"genericBody": "Inténtalo de nuevo en unos instantes.",
"backHome": "Volver al inicio"
}
}
-50
View File
@@ -1,50 +0,0 @@
{
"site": {
"tagline": "Articles, guides et analyses.",
"skipToContent": "Aller au contenu",
"mainNavigation": "Navigation principale",
"languageLabel": "Langue",
"allArticles": "Tous les articles",
"home": "Accueil",
"browse": "Parcourir",
"categories": "Catégories",
"contact": "Contact",
"noCategories": "Rien n'a encore été publié",
"rights": "Tous droits réservés."
},
"home": {
"latest": "Dernier",
"readArticle": "Lire l'article",
"moreStories": "Autres articles",
"viewAll": "Voir tous les articles"
},
"list": {
"archive": "Les archives",
"articles": "Articles",
"articlesPage": "Articles — page {page}",
"archiveDescription": "Tous les articles publiés sur le blog.",
"category": "Catégorie",
"categoryDescription": "Tous les articles de la catégorie {name}.",
"loading": "Chargement…",
"empty": "Rien n'a encore été publié.",
"categoryEmpty": "Il n'y a aucun article dans cette catégorie.",
"failed": "Les articles n'ont pas pu être chargés. Veuillez réessayer plus tard."
},
"pagination": {
"label": "Pagination",
"previous": "Page précédente",
"next": "Page suivante",
"position": "Page {page} sur {total}"
},
"article": {
"breadcrumb": "Fil d'Ariane",
"back": "Retour à tous les articles"
},
"error": {
"notFoundTitle": "Page introuvable",
"notFoundBody": "La page que vous cherchez n'existe pas ou a été déplacée.",
"genericTitle": "Une erreur est survenue",
"genericBody": "Veuillez réessayer dans un instant.",
"backHome": "Retour à l'accueil"
}
}
-50
View File
@@ -1,50 +0,0 @@
{
"site": {
"tagline": "Articoli, guide e analisi.",
"skipToContent": "Vai al contenuto",
"mainNavigation": "Navigazione principale",
"languageLabel": "Lingua",
"allArticles": "Tutti gli articoli",
"home": "Home",
"browse": "Naviga",
"categories": "Categorie",
"contact": "Contatti",
"noCategories": "Ancora nessuna pubblicazione",
"rights": "Tutti i diritti riservati."
},
"home": {
"latest": "Ultimo",
"readArticle": "Leggi l'articolo",
"moreStories": "Altri articoli",
"viewAll": "Vedi tutti gli articoli"
},
"list": {
"archive": "L'archivio",
"articles": "Articoli",
"articlesPage": "Articoli — pagina {page}",
"archiveDescription": "Tutti gli articoli pubblicati sul blog.",
"category": "Categoria",
"categoryDescription": "Tutti gli articoli nella categoria {name}.",
"loading": "Caricamento…",
"empty": "Non è stato ancora pubblicato nulla.",
"categoryEmpty": "Non ci sono articoli in questa categoria.",
"failed": "Non è stato possibile caricare gli articoli. Riprova più tardi."
},
"pagination": {
"label": "Paginazione",
"previous": "Pagina precedente",
"next": "Pagina successiva",
"position": "Pagina {page} di {total}"
},
"article": {
"breadcrumb": "Percorso di navigazione",
"back": "Torna a tutti gli articoli"
},
"error": {
"notFoundTitle": "Pagina non trovata",
"notFoundBody": "La pagina che cerchi non esiste o è stata spostata.",
"genericTitle": "Qualcosa è andato storto",
"genericBody": "Riprova tra qualche istante.",
"backHome": "Torna alla home"
}
}
+1 -23
View File
@@ -5,12 +5,11 @@ export default defineNuxtConfig({
compatibilityDate: '2025-07-15', compatibilityDate: '2025-07-15',
devtools: { enabled: true }, devtools: { enabled: true },
modules: ['@nuxtjs/i18n'],
css: ['~/assets/css/main.css'], css: ['~/assets/css/main.css'],
app: { app: {
head: { head: {
htmlAttrs: { lang: 'it' },
titleTemplate: `%s · ${SITE_NAME}`, titleTemplate: `%s · ${SITE_NAME}`,
meta: [{ name: 'viewport', content: 'width=device-width, initial-scale=1' }], meta: [{ name: 'viewport', content: 'width=device-width, initial-scale=1' }],
link: [ link: [
@@ -20,27 +19,6 @@ export default defineNuxtConfig({
}, },
}, },
i18n: {
// English keeps the bare URLs; the others are prefixed (/it/blog, /es/blog…).
defaultLocale: 'en',
strategy: 'prefix_except_default',
locales: [
{ code: 'en', language: 'en-GB', name: 'English', file: 'en.json' },
{ code: 'it', language: 'it-IT', name: 'Italiano', file: 'it.json' },
{ code: 'es', language: 'es-ES', name: 'Español', file: 'es.json' },
{ code: 'fr', language: 'fr-FR', name: 'Français', file: 'fr.json' },
],
// First visit follows the browser language; after that the cookie wins.
detectBrowserLanguage: {
useCookie: true,
cookieKey: 'locale',
redirectOn: 'root',
},
// Overridden per environment with NUXT_PUBLIC_I18N_BASE_URL, so the
// alternate-language links are absolute and correct in production.
baseUrl: 'http://localhost:3000',
},
runtimeConfig: { runtimeConfig: {
// Server-only: internal Strapi address, never exposed to the browser. // Server-only: internal Strapi address, never exposed to the browser.
strapiUrl: 'http://localhost:1337', strapiUrl: 'http://localhost:1337',
+21 -2766
View File
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -11,9 +11,9 @@
"typecheck": "nuxt typecheck" "typecheck": "nuxt typecheck"
}, },
"dependencies": { "dependencies": {
"@nuxtjs/i18n": "^10.6.0",
"marked": "^18.0.11", "marked": "^18.0.11",
"nuxt": "^4.5.2", "nuxt": "^4.5.2",
"simple-icons": "^16.28.0",
"vue": "^3.5.41", "vue": "^3.5.41",
"vue-router": "^5.2.0" "vue-router": "^5.2.0"
}, },
Binary file not shown.

After

Width:  |  Height:  |  Size: 404 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

+24 -4
View File
@@ -1,16 +1,31 @@
import type { Article } from '#shared/types/blog' import type { Article } from '#shared/types/blog'
type RawArticle = Omit<Article, 'html' | 'summary'> & { content: string | null } interface AdminUser {
firstname: string | null
lastname: string | null
}
type RawArticle = Omit<Article, 'html' | 'summary' | 'author'> & {
content: string | null
createdBy?: AdminUser | null
}
/** Joins the admin user's name parts; returns null when neither is set. */
function byline(user: AdminUser | null | undefined): string | null {
const name = [user?.firstname, user?.lastname].filter(Boolean).join(' ').trim()
return name || null
}
export default defineEventHandler(async (event): Promise<Article> => { export default defineEventHandler(async (event): Promise<Article> => {
const slug = getRouterParam(event, 'slug') const slug = getRouterParam(event, 'slug')
const locale = localeParam(getQuery(event).lang)
if (!slug) { if (!slug) {
throw createError({ statusCode: 400, statusMessage: 'Missing article slug' }) throw createError({ statusCode: 400, statusMessage: 'Missing article slug' })
} }
const response = await strapiFetch<StrapiList<RawArticle>>( const response = await strapiFetch<StrapiList<RawArticle>>(
`/api/articles?${ARTICLE_DETAIL_QUERY}&filters[slug][$eq]=${encodeURIComponent(slug)}&pagination[pageSize]=1` `/api/articles?${ARTICLE_DETAIL_QUERY}&locale=${locale}&filters[slug][$eq]=${encodeURIComponent(slug)}&pagination[pageSize]=1`
) )
const article = response.data[0] const article = response.data[0]
@@ -19,6 +34,11 @@ export default defineEventHandler(async (event): Promise<Article> => {
throw createError({ statusCode: 404, statusMessage: 'Article not found' }) throw createError({ statusCode: 404, statusMessage: 'Article not found' })
} }
const { content, ...rest } = article const { content, createdBy, ...rest } = article
return { ...rest, html: renderMarkdown(content), summary: summarise(content) } return {
...rest,
html: renderMarkdown(content),
summary: summarise(content),
author: byline(createdBy),
}
}) })
+2 -1
View File
@@ -3,6 +3,7 @@ import type { ArticleSummary, Paginated } from '#shared/types/blog'
export default defineEventHandler(async (event): Promise<Paginated<ArticleSummary>> => { export default defineEventHandler(async (event): Promise<Paginated<ArticleSummary>> => {
const query = getQuery(event) const query = getQuery(event)
const page = pageParam(query.page) const page = pageParam(query.page)
const locale = localeParam(query.lang)
const category = typeof query.category === 'string' ? query.category : null const category = typeof query.category === 'string' ? query.category : null
const filter = category const filter = category
@@ -10,7 +11,7 @@ export default defineEventHandler(async (event): Promise<Paginated<ArticleSummar
: '' : ''
const response = await strapiFetch<StrapiList<ArticleSummary>>( const response = await strapiFetch<StrapiList<ArticleSummary>>(
`/api/articles?${ARTICLE_SUMMARY_QUERY}&${pagination(page)}${filter}` `/api/articles?${ARTICLE_SUMMARY_QUERY}&locale=${locale}&${pagination(page)}${filter}`
) )
return { return {
+2 -1
View File
@@ -2,13 +2,14 @@ import type { Category } from '#shared/types/blog'
export default defineEventHandler(async (event): Promise<Category> => { export default defineEventHandler(async (event): Promise<Category> => {
const slug = getRouterParam(event, 'slug') const slug = getRouterParam(event, 'slug')
const locale = localeParam(getQuery(event).lang)
if (!slug) { if (!slug) {
throw createError({ statusCode: 400, statusMessage: 'Missing category slug' }) throw createError({ statusCode: 400, statusMessage: 'Missing category slug' })
} }
const response = await strapiFetch<StrapiList<Category>>( const response = await strapiFetch<StrapiList<Category>>(
`/api/categories?fields[0]=name&fields[1]=slug&filters[slug][$eq]=${encodeURIComponent(slug)}&pagination[pageSize]=1` `/api/categories?fields[0]=name&fields[1]=slug&locale=${locale}&filters[slug][$eq]=${encodeURIComponent(slug)}&pagination[pageSize]=1`
) )
const category = response.data[0] const category = response.data[0]
+4 -2
View File
@@ -1,8 +1,10 @@
import type { Category } from '#shared/types/blog' import type { Category } from '#shared/types/blog'
export default defineEventHandler(async (): Promise<Category[]> => { export default defineEventHandler(async (event): Promise<Category[]> => {
const locale = localeParam(getQuery(event).lang)
const response = await strapiFetch<StrapiList<Category>>( const response = await strapiFetch<StrapiList<Category>>(
'/api/categories?fields[0]=name&fields[1]=slug&sort[0]=name:asc&pagination[pageSize]=100' `/api/categories?fields[0]=name&fields[1]=slug&locale=${locale}&sort[0]=name:asc&pagination[pageSize]=100`
) )
return response.data return response.data
+8
View File
@@ -16,6 +16,9 @@ export const ARTICLE_DETAIL_QUERY = [
list('fields', ['title', 'slug', 'content', 'publishedAt']), list('fields', ['title', 'slug', 'content', 'publishedAt']),
list('populate[cover][fields]', IMAGE_FIELDS), list('populate[cover][fields]', IMAGE_FIELDS),
list('populate[category][fields]', ['name', 'slug']), list('populate[category][fields]', ['name', 'slug']),
// The byline is the admin user who created the entry; Strapi exposes the
// name fields only because the content type sets populateCreatorFields.
list('populate[createdBy][fields]', ['firstname', 'lastname']),
].join('&') ].join('&')
export const PAGE_SIZE = 12 export const PAGE_SIZE = 12
@@ -28,3 +31,8 @@ export const pageParam = (value: unknown): number => {
const page = Number(value) const page = Number(value)
return Number.isInteger(page) && page > 0 ? page : 1 return Number.isInteger(page) && page > 0 ? page : 1
} }
export type Locale = 'it' | 'en'
/** Reads the `lang` query param, falling back to the site default `it`. */
export const localeParam = (value: unknown): Locale => (value === 'en' ? 'en' : 'it')
+2
View File
@@ -26,6 +26,8 @@ export interface Article extends ArticleSummary {
html: string html: string
/** Plain-text opening of the body, used as the meta description. */ /** Plain-text opening of the body, used as the meta description. */
summary: string summary: string
/** Byline: the full name of the admin user who wrote the article. */
author: string | null
} }
export interface Paginated<T> { export interface Paginated<T> {
+14 -2
View File
@@ -1,7 +1,19 @@
const INTL_LOCALE = { it: 'it-IT', en: 'en-GB' } as const
/** Human-readable date for display; returns an empty string when unset. */ /** Human-readable date for display; returns an empty string when unset. */
export function formatDate(value: string | null | undefined, locale = 'en-GB'): string { export function formatDate(value: string | null | undefined, locale: 'it' | 'en' = 'it'): string {
if (!value) return '' if (!value) return ''
return new Intl.DateTimeFormat(locale, { dateStyle: 'long' }).format(new Date(value)) return new Intl.DateTimeFormat(INTL_LOCALE[locale], { dateStyle: 'long' }).format(new Date(value))
}
/** Date and time of publication, shown in the article byline. */
export function formatDateTime(
value: string | null | undefined,
locale: 'it' | 'en' = 'it'
): string {
if (!value) return ''
return new Intl.DateTimeFormat(INTL_LOCALE[locale], { dateStyle: 'long', timeStyle: 'short' })
.format(new Date(value))
} }
/** Machine-readable date for the `datetime` attribute and structured data. */ /** Machine-readable date for the `datetime` attribute and structured data. */
+7
View File
@@ -3,3 +3,10 @@ export const SITE_NAME = 'CorralitoComing'
/** Public contact address, shown in the footer. */ /** Public contact address, shown in the footer. */
export const SITE_EMAIL = 'corralitocoming@gmail.com' export const SITE_EMAIL = 'corralitocoming@gmail.com'
/** Social profiles listed in the footer. Names are brands, so untranslated. */
export const SOCIAL_LINKS = [
{ name: 'X', url: 'https://x.com/CORRALITOCOMING' },
{ name: 'Instagram', url: 'https://www.instagram.com/corralitocoming' },
{ name: 'Facebook', url: 'https://www.facebook.com/share/1JwXwQWyQA/' },
] as const