Compare commits
6
Commits
e927396505
..
temp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
754b84e5f6 | ||
|
|
91b61caa37 | ||
|
|
b7bb664c95 | ||
|
|
809b60d85e | ||
|
|
448dd881e4 | ||
|
|
8021ea7254 |
No files matched your search
@@ -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/
|
||||||
|
|||||||
@@ -16,13 +16,16 @@ sitemap e `robots.txt` dinamici, ricerca, e i test (nessun framework ancora conf
|
|||||||
## Architettura
|
## Architettura
|
||||||
|
|
||||||
```text
|
```text
|
||||||
Browser → Caddy ─┬─ /admin, /uploads → Strapi 5 → PostgreSQL
|
Browser → Caddy ─┬─ /admin e i path dei plugin Strapi → Strapi 5 → PostgreSQL
|
||||||
└─ tutto il resto → Nuxt 4 (SSR) → REST Strapi
|
└─ tutto il resto → Nuxt 4 (SSR) → REST Strapi
|
||||||
```
|
```
|
||||||
|
|
||||||
Caddy instrada per **path**, non per sottodominio: `PUBLIC_DOMAIN` serve sia il sito che,
|
Caddy instrada per **path**, non per sottodominio: `PUBLIC_DOMAIN` serve sia il sito che il
|
||||||
sotto `/admin` e `/uploads`, il pannello Strapi (Strapi 5 annida l'intera admin UI e la sua
|
pannello Strapi. Ogni plugin Strapi monta la propria API admin sul proprio path di primo
|
||||||
API sotto `/admin`, senza toccare `/api`). Un solo dominio, un solo certificato TLS.
|
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.
|
||||||
@@ -37,11 +40,11 @@ API sotto `/admin`, senza toccare `/api`). Un solo dominio, un solo certificato
|
|||||||
richiesta né concessa).
|
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.
|
||||||
|
|||||||
@@ -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 ─┬─ /admin, /uploads → Strapi (CMS) → PostgreSQL
|
Browser → Caddy ─┬─ /admin and Strapi's plugin paths → Strapi (CMS) → PostgreSQL
|
||||||
└─ everything else → Nuxt (website)
|
└─ 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
|
||||||
@@ -94,7 +94,7 @@ reachable inside the Docker network — do not publish their ports.
|
|||||||
| `PUBLIC_DOMAIN` | `example.com` |
|
| `PUBLIC_DOMAIN` | `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://example.com` — same origin, Caddy proxies `/admin` and `/uploads` to Strapi |
|
| `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 —
|
||||||
@@ -111,9 +111,9 @@ already ignored.
|
|||||||
docker compose up -d --build
|
docker compose up -d --build
|
||||||
```
|
```
|
||||||
|
|
||||||
This time Caddy is included: it serves both the website and, under `/admin` and
|
This time Caddy is included: it serves both the website and, under `/admin` and Strapi's
|
||||||
`/uploads`, the CMS on `PUBLIC_DOMAIN`, obtains and renews the TLS certificate on its own,
|
other plugin paths, the CMS on `PUBLIC_DOMAIN`, obtains and renews the TLS certificate on
|
||||||
and adds HSTS and the other security headers.
|
its own, and adds HSTS and the other security headers.
|
||||||
|
|
||||||
**5. Create the administrator account** at `https://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
|
||||||
|
|||||||
+12
-5
@@ -16,11 +16,18 @@
|
|||||||
import security_headers
|
import security_headers
|
||||||
encode zstd gzip
|
encode zstd gzip
|
||||||
|
|
||||||
# /admin and /uploads go to Strapi; everything else to the frontend.
|
# Strapi mounts each of its (and its plugins') admin APIs at its own
|
||||||
# Strapi 5 nests the whole admin panel (UI + its own API) under /admin,
|
# top-level path, not all under /admin - the admin panel's dashboard
|
||||||
# so this single prefix is enough - it never touches /api, which stays
|
# widgets, media library, i18n, etc each call their own plugin prefix.
|
||||||
# reserved for the frontend's own Nitro endpoints.
|
# This list is every @strapi/* package in cms/package.json plus the
|
||||||
@cms path /admin* /uploads*
|
# 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 {
|
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 {
|
||||||
|
|||||||
@@ -11,31 +11,41 @@
|
|||||||
"draftAndPublish": true,
|
"draftAndPublish": true,
|
||||||
"populateCreatorFields": 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 } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -16,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
|
|
||||||
@@ -51,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
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -3,16 +3,16 @@ 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">
|
||||||
<!-- No placeholder box when there is no cover: an empty grey rectangle
|
<!-- No placeholder box when there is no cover: an empty grey rectangle
|
||||||
reads as a broken image rather than as a deliberate choice. -->
|
reads as a broken image rather than as a deliberate choice. -->
|
||||||
<NuxtLinkLocale
|
<NuxtLink
|
||||||
v-if="cover"
|
v-if="cover"
|
||||||
class="cover-link"
|
class="cover-link"
|
||||||
:to="`/blog/${article.slug}`"
|
:to="`/blog/${article.slug}`"
|
||||||
@@ -27,12 +27,12 @@ const cover = computed(() => mediaUrl(props.article.cover))
|
|||||||
:height="article.cover?.height ?? undefined"
|
:height="article.cover?.height ?? undefined"
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
>
|
>
|
||||||
</NuxtLinkLocale>
|
</NuxtLink>
|
||||||
|
|
||||||
<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">
|
||||||
|
|||||||
@@ -1,80 +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.4rem 1.7rem 0.4rem 0.7rem;
|
|
||||||
border: 1px solid var(--color-border);
|
|
||||||
border-radius: 0;
|
|
||||||
background: transparent;
|
|
||||||
color: var(--color-body);
|
|
||||||
font: inherit;
|
|
||||||
/* Safari on iOS zooms the page when a control smaller than 16px is tapped,
|
|
||||||
so the picker stays at 1rem on phones and shrinks only from tablet up. */
|
|
||||||
font-size: 1rem;
|
|
||||||
font-weight: 600;
|
|
||||||
letter-spacing: 0.14em;
|
|
||||||
text-transform: uppercase;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width: 48rem) {
|
|
||||||
select {
|
|
||||||
padding: 0.35rem 1.6rem 0.35rem 0.7rem;
|
|
||||||
font-size: 0.75rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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>
|
|
||||||
@@ -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,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>
|
||||||
@@ -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.',
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -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,35 +50,24 @@ 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>
|
|
||||||
<li><NuxtLinkLocale to="/">{{ $t('site.home') }}</NuxtLinkLocale></li>
|
|
||||||
<li><NuxtLinkLocale to="/blog">{{ $t('site.allArticles') }}</NuxtLinkLocale></li>
|
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
|
|
||||||
<nav class="footer-block" :aria-label="$t('site.follow')">
|
|
||||||
<p class="kicker">{{ $t('site.follow') }}</p>
|
|
||||||
<ul>
|
<ul>
|
||||||
<li v-for="social in SOCIAL_LINKS" :key="social.name">
|
<li v-for="social in SOCIAL_LINKS" :key="social.name">
|
||||||
<a class="social" :href="social.url" target="_blank" rel="noopener me">
|
<a class="social" :href="social.url" target="_blank" rel="noopener me">
|
||||||
@@ -86,8 +79,8 @@ const { data: categories } = await useFetch<Category[]>('/api/categories', {
|
|||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p class="container copyright kicker" :lang="locale">
|
<p class="container copyright kicker">
|
||||||
© {{ new Date().getFullYear() }} {{ SITE_NAME }}. {{ $t('site.rights') }}
|
© {{ new Date().getFullYear() }} {{ SITE_NAME }}. {{ t('footerRights') }}
|
||||||
</p>
|
</p>
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
@@ -137,13 +130,12 @@ const { data: categories } = await useFetch<Category[]>('/api/categories', {
|
|||||||
border-top: 1px solid var(--color-border);
|
border-top: 1px solid var(--color-border);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Phones stack the links above the language picker, both centred; from tablet
|
|
||||||
up they sit on one line with the picker pushed to the right. */
|
|
||||||
.nav-inner {
|
.nav-inner {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-wrap: wrap;
|
||||||
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 0.5rem;
|
gap: 0.75rem 1.5rem;
|
||||||
padding-block: 0.6rem;
|
padding-block: 0.6rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,16 +153,30 @@ 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) {
|
@media (min-width: 48rem) {
|
||||||
.site-nav {
|
.site-nav {
|
||||||
margin-top: 2rem;
|
margin-top: 2rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.nav-inner {
|
.nav-inner {
|
||||||
flex-direction: row;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
justify-content: space-between;
|
|
||||||
gap: 0.75rem 2rem;
|
|
||||||
padding-block: 0.9rem;
|
padding-block: 0.9rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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,7 @@ 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
|
author: article.value.author
|
||||||
? { '@type': 'Person', name: article.value.author }
|
? { '@type': 'Person', name: article.value.author }
|
||||||
: undefined,
|
: undefined,
|
||||||
@@ -53,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>
|
||||||
|
|
||||||
@@ -71,7 +76,7 @@ useHead({
|
|||||||
</time>
|
</time>
|
||||||
<template v-if="article.author">
|
<template v-if="article.author">
|
||||||
<span aria-hidden="true"> · </span>
|
<span aria-hidden="true"> · </span>
|
||||||
<span>{{ $t('article.by', { name: article.author }) }}</span>
|
<span>{{ t('byAuthor')(article.author) }}</span>
|
||||||
</template>
|
</template>
|
||||||
</p>
|
</p>
|
||||||
</header>
|
</header>
|
||||||
@@ -89,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>
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -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>
|
||||||
@@ -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,13 +33,49 @@ 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" :class="{ 'has-cover': featuredCover }">
|
<article class="featured" :class="{ 'has-cover': featuredCover }">
|
||||||
<NuxtLinkLocale
|
<NuxtLink
|
||||||
v-if="featuredCover"
|
v-if="featuredCover"
|
||||||
class="featured-cover"
|
class="featured-cover"
|
||||||
:to="`/blog/${featured.slug}`"
|
:to="`/blog/${featured.slug}`"
|
||||||
@@ -54,46 +88,66 @@ useSeoMeta({
|
|||||||
:width="featured.cover?.width ?? undefined"
|
:width="featured.cover?.width ?? undefined"
|
||||||
:height="featured.cover?.height ?? undefined"
|
:height="featured.cover?.height ?? undefined"
|
||||||
>
|
>
|
||||||
</NuxtLinkLocale>
|
</NuxtLink>
|
||||||
|
|
||||||
<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: 1.5rem;
|
gap: 1.5rem;
|
||||||
@@ -129,16 +183,16 @@ useSeoMeta({
|
|||||||
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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,52 +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.",
|
|
||||||
"follow": "Follow"
|
|
||||||
},
|
|
||||||
"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",
|
|
||||||
"by": "By {name}"
|
|
||||||
},
|
|
||||||
"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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,52 +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.",
|
|
||||||
"follow": "Síguenos"
|
|
||||||
},
|
|
||||||
"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",
|
|
||||||
"by": "Por {name}"
|
|
||||||
},
|
|
||||||
"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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,52 +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.",
|
|
||||||
"follow": "Suivez-nous"
|
|
||||||
},
|
|
||||||
"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",
|
|
||||||
"by": "Par {name}"
|
|
||||||
},
|
|
||||||
"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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,52 +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.",
|
|
||||||
"follow": "Seguici"
|
|
||||||
},
|
|
||||||
"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",
|
|
||||||
"by": "Di {name}"
|
|
||||||
},
|
|
||||||
"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
@@ -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',
|
||||||
|
|||||||
Generated
+1
-2766
File diff suppressed because it is too large.
Load diff
@@ -11,7 +11,6 @@
|
|||||||
"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",
|
"simple-icons": "^16.28.0",
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 404 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 88 KiB |
@@ -18,13 +18,14 @@ function byline(user: AdminUser | null | undefined): string | 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]
|
||||||
|
|||||||
@@ -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,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]
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -31,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')
|
||||||
@@ -1,13 +1,18 @@
|
|||||||
|
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. */
|
/** Date and time of publication, shown in the article byline. */
|
||||||
export function formatDateTime(value: string | null | undefined, locale = 'en-GB'): string {
|
export function formatDateTime(
|
||||||
|
value: string | null | undefined,
|
||||||
|
locale: 'it' | 'en' = 'it'
|
||||||
|
): string {
|
||||||
if (!value) return ''
|
if (!value) return ''
|
||||||
return new Intl.DateTimeFormat(locale, { dateStyle: 'long', timeStyle: 'short' })
|
return new Intl.DateTimeFormat(INTL_LOCALE[locale], { dateStyle: 'long', timeStyle: 'short' })
|
||||||
.format(new Date(value))
|
.format(new Date(value))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user