Compare commits
10
Commits
ec5976135f
...
c08f53ca69
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c08f53ca69 | ||
|
|
f5639111f9 | ||
|
|
9256def085 | ||
|
|
4e8d1a892e | ||
|
|
55b70f0805 | ||
|
|
005c90f33a | ||
|
|
d97fd3f92f | ||
|
|
c9ee871c44 | ||
|
|
960b007ba7 | ||
|
|
a808f1010f |
No files matched your search
@@ -0,0 +1,28 @@
|
|||||||
|
# Copy to .env and replace every placeholder. Never commit .env.
|
||||||
|
|
||||||
|
# --- Domains (Caddy) ---
|
||||||
|
PUBLIC_DOMAIN=blog.localhost
|
||||||
|
CMS_DOMAIN=cms.blog.localhost
|
||||||
|
ACME_EMAIL=admin@example.com
|
||||||
|
|
||||||
|
# --- Database ---
|
||||||
|
POSTGRES_DB=blog
|
||||||
|
POSTGRES_USER=blog
|
||||||
|
POSTGRES_PASSWORD=change-me
|
||||||
|
|
||||||
|
# --- Strapi ---
|
||||||
|
# Generate each secret with: openssl rand -base64 32
|
||||||
|
APP_KEYS=change-me-1,change-me-2
|
||||||
|
API_TOKEN_SALT=change-me
|
||||||
|
ADMIN_JWT_SECRET=change-me
|
||||||
|
TRANSFER_TOKEN_SALT=change-me
|
||||||
|
JWT_SECRET=change-me
|
||||||
|
ENCRYPTION_KEY=change-me
|
||||||
|
|
||||||
|
# --- Frontend ---
|
||||||
|
# Server-side only: internal Docker address of Strapi.
|
||||||
|
STRAPI_URL=http://cms:1337
|
||||||
|
# Public base URL of the website, used for canonical URLs and Open Graph.
|
||||||
|
PUBLIC_SITE_URL=https://blog.localhost
|
||||||
|
# Public base URL of Strapi, used to build absolute media URLs in the browser.
|
||||||
|
PUBLIC_STRAPI_URL=https://cms.blog.localhost
|
||||||
@@ -10,17 +10,8 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
|||||||
|
|
||||||
## Stato
|
## Stato
|
||||||
|
|
||||||
Repository a **stato bootstrap**: contiene solo questo file. Tutto ciò che segue descrive il
|
Struttura, content type, pagine blog, Docker e Caddy sono in piedi. Restano da fare:
|
||||||
target, non l'esistente. Verifica sempre cosa esiste prima di assumere.
|
sitemap e `robots.txt` dinamici, ricerca, e i test (nessun framework ancora configurato).
|
||||||
|
|
||||||
Ordine di costruzione:
|
|
||||||
|
|
||||||
1. `frontend/` — Nuxt 4 (`npx nuxi@latest init frontend --package-manager npm --no-install-git`)
|
|
||||||
2. `cms/` — Strapi 5 (`npx create-strapi@latest cms --typescript --dbclient=postgres --no-example --no-git-init`)
|
|
||||||
3. `docker-compose.yml` + `.env.example` — Postgres, cms, frontend
|
|
||||||
4. Content types Strapi + permessi ruolo Public (solo `find`/`findOne`)
|
|
||||||
5. Client Strapi in Nuxt + pagine blog
|
|
||||||
6. `caddy/Caddyfile` + hardening
|
|
||||||
|
|
||||||
## Architettura
|
## Architettura
|
||||||
|
|
||||||
@@ -32,8 +23,20 @@ Browser → Caddy ─┬─ dominio pubblico → Nuxt 4 (SSR) → REST Strapi
|
|||||||
- 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.
|
||||||
- Nuxt parla con Strapi **server-side** (`STRAPI_URL` interno Docker). Il token privilegiato non
|
- **Il browser non parla mai con Strapi.** Le pagine chiamano gli endpoint Nitro in
|
||||||
raggiunge mai il browser: se serve, sta in `runtimeConfig` (non `public`).
|
`frontend/server/api/`, che sono l'unico posto dove si costruiscono query Strapi. Così
|
||||||
|
`NUXT_STRAPI_URL` resta l'indirizzo interno Docker, niente CORS e niente token nel client.
|
||||||
|
Se aggiungi una vista, aggiungi l'endpoint lì e tipizza il ritorno in `shared/types/blog.ts`.
|
||||||
|
- 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.
|
||||||
|
- L'**interfaccia** è tradotta in en/it/es/fr con `@nuxtjs/i18n`: stringhe in
|
||||||
|
`frontend/i18n/locales/*.json`, rotte `prefix_except_default` (inglese senza prefisso),
|
||||||
|
`hreflang` e `og:locale` generati da `useLocaleHead()` in `app.vue`. Nessuna stringa
|
||||||
|
visibile va scritta a mano in un componente: aggiungi la chiave nei quattro file.
|
||||||
|
I **contenuti** invece restano monolingua — la localizzazione di Strapi è disattivata.
|
||||||
|
- `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.
|
||||||
|
Qualsiasi permesso in più va motivato.
|
||||||
- Postgres non è esposto pubblicamente. Media su volume persistente, mai binari nel DB.
|
- Postgres non è esposto pubblicamente. Media su volume persistente, mai binari nel DB.
|
||||||
|
|
||||||
## Comandi
|
## Comandi
|
||||||
@@ -52,11 +55,17 @@ npm run develop # Strapi con content-type builder attivo
|
|||||||
npm run build # admin panel
|
npm run build # admin panel
|
||||||
npm run start # produzione
|
npm run start # produzione
|
||||||
|
|
||||||
# stack
|
# stack completo (con Caddy e domini reali)
|
||||||
docker compose up -d --build
|
docker compose up -d --build
|
||||||
docker compose logs -f cms
|
docker compose logs -f cms
|
||||||
|
|
||||||
|
# stack locale senza domini né TLS: porte su localhost, niente Caddy
|
||||||
|
docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d --build database cms frontend
|
||||||
```
|
```
|
||||||
|
|
||||||
|
`docker-compose.dev.yml` va passato **sempre esplicitamente**: non è un `override.yml` proprio
|
||||||
|
per non finire per sbaglio in produzione esponendo le porte.
|
||||||
|
|
||||||
Nessun test framework è ancora configurato. Se ne aggiungi uno, documenta qui il comando per
|
Nessun test framework è ancora configurato. Se ne aggiungi uno, documenta qui il comando per
|
||||||
lanciare **un singolo test**.
|
lanciare **un singolo test**.
|
||||||
|
|
||||||
@@ -64,10 +73,13 @@ lanciare **un singolo test**.
|
|||||||
|
|
||||||
| Type | Campi |
|
| Type | Campi |
|
||||||
|---|---|
|
|---|---|
|
||||||
| Article | title, slug (UID da title), excerpt, content (rich text), cover, author (rel), category (rel), tags (rel n:n), publishedDate, seoTitle, seoDescription, seoImage |
|
| Article | title, slug (UID da title), content (Markdown), cover, category (rel) |
|
||||||
| Category | name, slug |
|
| Category | name, slug |
|
||||||
| Tag | name, slug |
|
|
||||||
| Author | name, biography, image |
|
Deliberatamente minimale: **niente Author** (l'unico autore è l'admin), niente tag, nessun campo
|
||||||
|
SEO separato. La meta description è ricavata dall'inizio del body (`summarise` in
|
||||||
|
`frontend/server/utils/strapi.ts`), la data è il `publishedAt` di Draft & Publish, l'immagine
|
||||||
|
social è la cover. Non reintrodurre questi campi senza che servano davvero.
|
||||||
|
|
||||||
Draft & Publish attivo su Article. Le URL pubbliche usano lo **slug**, mai l'id numerico.
|
Draft & Publish attivo su Article. Le URL pubbliche usano lo **slug**, mai l'id numerico.
|
||||||
|
|
||||||
|
|||||||
@@ -1,34 +1,136 @@
|
|||||||
# Blog
|
# Blog
|
||||||
|
|
||||||
Blog platform: a public website built with Nuxt, and a private Strapi CMS where
|
Blog platform: a public website built with Nuxt, and a private Strapi CMS where the
|
||||||
editors write the articles. 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 ─┬─ public domain → Nuxt (website)
|
||||||
└─ cms subdomain → Strapi (CMS) → PostgreSQL
|
└─ cms subdomain → Strapi (CMS) → PostgreSQL
|
||||||
```
|
```
|
||||||
|
|
||||||
> Status: bootstrap. The application code is not in place yet.
|
There are no front-end accounts: sign-up is disabled and only administrators write
|
||||||
|
content. An article is a title, a Markdown body, a cover image and a category.
|
||||||
|
|
||||||
## Getting started
|
## Development
|
||||||
|
|
||||||
Requires Docker and Node.js 20+.
|
No domain and no TLS needed — the services are published on localhost instead of going
|
||||||
|
through Caddy. Requires Docker.
|
||||||
|
|
||||||
|
**1. Create the environment file**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cp .env.example .env
|
||||||
|
```
|
||||||
|
|
||||||
|
**2. Generate the secrets.** Every `change-me` must become a different random value —
|
||||||
|
Strapi refuses to start otherwise. This fills them all:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
for var in POSTGRES_PASSWORD API_TOKEN_SALT ADMIN_JWT_SECRET TRANSFER_TOKEN_SALT JWT_SECRET ENCRYPTION_KEY; do
|
||||||
|
sed -i "s|^$var=.*|$var=$(openssl rand -base64 32)|" .env
|
||||||
|
done
|
||||||
|
sed -i "s|^APP_KEYS=.*|APP_KEYS=$(openssl rand -base64 32),$(openssl rand -base64 32)|" .env
|
||||||
|
chmod 600 .env
|
||||||
|
```
|
||||||
|
|
||||||
|
`grep change-me .env` must print nothing. The domain and URL variables can stay as they
|
||||||
|
are for local use.
|
||||||
|
|
||||||
|
**3. Start the stack**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d --build database cms frontend
|
||||||
|
```
|
||||||
|
|
||||||
|
The first build takes a few minutes. `docker-compose.dev.yml` publishes the ports on
|
||||||
|
`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.
|
||||||
|
|
||||||
|
**4. Create the administrator account** at http://localhost:1337/admin. This is the first
|
||||||
|
run, so the form creates the account — pick your own credentials.
|
||||||
|
|
||||||
|
**5. Write something.** In the admin panel: create a **Category**, then an **Article**
|
||||||
|
(the body field is Markdown), then press **Publish** — the website only shows published
|
||||||
|
content.
|
||||||
|
|
||||||
|
**6. Open the website** at http://localhost:3000 — home, `/blog`, `/blog/<slug>` and
|
||||||
|
`/category/<slug>`.
|
||||||
|
|
||||||
|
Useful commands:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker compose logs -f cms # follow the CMS logs
|
||||||
|
docker compose -f docker-compose.yml -f docker-compose.dev.yml restart frontend
|
||||||
|
docker compose down # stop, keep the data
|
||||||
|
docker compose down -v # stop and WIPE the database and media
|
||||||
|
```
|
||||||
|
|
||||||
|
To iterate on the code without rebuilding an image every time, run a package directly —
|
||||||
|
`cd frontend && npm run dev`, or `cd cms && npm run develop`. The frontend defaults to
|
||||||
|
`http://localhost:1337` for Strapi, so it works against the containerised CMS as is;
|
||||||
|
override it with `NUXT_STRAPI_URL` if needed. Strapi reads its own `cms/.env`.
|
||||||
|
|
||||||
|
## Production
|
||||||
|
|
||||||
|
**1. Point the DNS at the server.** Two `A` records (and `AAAA` if you have IPv6) on the
|
||||||
|
public IP of the machine:
|
||||||
|
|
||||||
|
| Record | Purpose |
|
||||||
|
|---|---|
|
||||||
|
| `example.com` | the website |
|
||||||
|
| `cms.example.com` | the Strapi admin panel |
|
||||||
|
|
||||||
|
Wait for the records to resolve before starting the stack — Caddy requests the
|
||||||
|
certificates 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
|
||||||
|
it for the ACME challenge and to redirect to HTTPS. PostgreSQL, Strapi and Nuxt are only
|
||||||
|
reachable inside the Docker network — do not publish their ports.
|
||||||
|
|
||||||
|
**3. Configure the environment.** Copy `.env.example` to `.env` on the server and set:
|
||||||
|
|
||||||
|
| Variable | Value |
|
||||||
|
|---|---|
|
||||||
|
| `PUBLIC_DOMAIN` | `example.com` |
|
||||||
|
| `CMS_DOMAIN` | `cms.example.com` |
|
||||||
|
| `ACME_EMAIL` | a mailbox you read — Let's Encrypt sends expiry warnings there |
|
||||||
|
| `PUBLIC_SITE_URL` | `https://example.com` |
|
||||||
|
| `PUBLIC_STRAPI_URL` | `https://cms.example.com` |
|
||||||
|
| `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 —
|
||||||
|
different values from the ones you use locally. Keep `.env` out of version control; it is
|
||||||
|
already ignored.
|
||||||
|
|
||||||
|
> Changing `APP_KEYS`, `ADMIN_JWT_SECRET` or `JWT_SECRET` later logs everyone out.
|
||||||
|
> Changing `ENCRYPTION_KEY` after content exists makes already-encrypted values
|
||||||
|
> unreadable. Set them once, then back up the file somewhere safe.
|
||||||
|
|
||||||
|
**4. Start everything**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cp .env.example .env # fill in the secrets, never commit this file
|
|
||||||
docker compose up -d --build
|
docker compose up -d --build
|
||||||
```
|
```
|
||||||
|
|
||||||
Then open the CMS URL to create the first admin account and start publishing.
|
This time Caddy is included: it serves the website on `PUBLIC_DOMAIN`, the CMS on
|
||||||
The public site picks up published articles automatically.
|
`CMS_DOMAIN`, obtains and renews the TLS certificates on its own, and adds HSTS and the
|
||||||
|
other security headers.
|
||||||
|
|
||||||
## Working on it
|
**5. Create the administrator account** at `https://cms.example.com/admin`, immediately,
|
||||||
|
before anyone else finds the URL — the first visitor to that form is the one who gets the
|
||||||
|
account. Then publish as in development.
|
||||||
|
|
||||||
|
**6. Back up what is not in git**: the `postgres-data` volume (all content) and the
|
||||||
|
`cms-uploads` volume (all images). Nothing else on the server holds state.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd frontend && npm run dev # website
|
docker compose exec -T database pg_dump -U "$POSTGRES_USER" "$POSTGRES_DB" > backup.sql
|
||||||
cd cms && npm run develop # CMS
|
docker run --rm -v blog_cms-uploads:/data -v "$PWD:/out" alpine tar czf /out/uploads.tar.gz -C /data .
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Updating a running site**: pull the new code, then `docker compose up -d --build`.
|
||||||
|
Strapi applies its own schema changes at startup; take a backup first.
|
||||||
|
|
||||||
Architecture, conventions and constraints are documented in [CLAUDE.md](CLAUDE.md).
|
Architecture, conventions and constraints are documented in [CLAUDE.md](CLAUDE.md).
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
email {$ACME_EMAIL}
|
||||||
|
}
|
||||||
|
|
||||||
|
(security_headers) {
|
||||||
|
header {
|
||||||
|
Strict-Transport-Security "max-age=31536000; includeSubDomains"
|
||||||
|
X-Content-Type-Options "nosniff"
|
||||||
|
X-Frame-Options "SAMEORIGIN"
|
||||||
|
Referrer-Policy "strict-origin-when-cross-origin"
|
||||||
|
-Server
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{$PUBLIC_DOMAIN} {
|
||||||
|
import security_headers
|
||||||
|
encode zstd gzip
|
||||||
|
reverse_proxy frontend:3000
|
||||||
|
}
|
||||||
|
|
||||||
|
{$CMS_DOMAIN} {
|
||||||
|
import security_headers
|
||||||
|
encode zstd gzip
|
||||||
|
# Uploaded media can be large; Strapi's own limit still applies.
|
||||||
|
request_body {
|
||||||
|
max_size 100MB
|
||||||
|
}
|
||||||
|
reverse_proxy cms:1337
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
# Local testing without domains or TLS: publishes the app ports on localhost and
|
||||||
|
# leaves Caddy out. Never used in production — it must be passed explicitly:
|
||||||
|
# docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d --build cms frontend
|
||||||
|
services:
|
||||||
|
database:
|
||||||
|
ports:
|
||||||
|
- "127.0.0.1:5432:5432"
|
||||||
|
|
||||||
|
cms:
|
||||||
|
ports:
|
||||||
|
- "127.0.0.1:1337:1337"
|
||||||
|
environment:
|
||||||
|
STRAPI_URL: http://localhost:1337
|
||||||
|
|
||||||
|
frontend:
|
||||||
|
ports:
|
||||||
|
- "127.0.0.1:3000:3000"
|
||||||
|
environment:
|
||||||
|
NUXT_PUBLIC_SITE_URL: http://localhost:3000
|
||||||
|
NUXT_PUBLIC_STRAPI_URL: http://localhost:1337
|
||||||
|
NUXT_PUBLIC_I18N_BASE_URL: http://localhost:3000
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
services:
|
||||||
|
database:
|
||||||
|
image: postgres:17-alpine
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
POSTGRES_DB: ${POSTGRES_DB}
|
||||||
|
POSTGRES_USER: ${POSTGRES_USER}
|
||||||
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
||||||
|
volumes:
|
||||||
|
- postgres-data:/var/lib/postgresql/data
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 5
|
||||||
|
|
||||||
|
cms:
|
||||||
|
build: ./cms
|
||||||
|
restart: unless-stopped
|
||||||
|
depends_on:
|
||||||
|
database:
|
||||||
|
condition: service_healthy
|
||||||
|
environment:
|
||||||
|
NODE_ENV: production
|
||||||
|
HOST: 0.0.0.0
|
||||||
|
PORT: 1337
|
||||||
|
DATABASE_CLIENT: postgres
|
||||||
|
DATABASE_HOST: database
|
||||||
|
DATABASE_PORT: 5432
|
||||||
|
DATABASE_NAME: ${POSTGRES_DB}
|
||||||
|
DATABASE_USERNAME: ${POSTGRES_USER}
|
||||||
|
DATABASE_PASSWORD: ${POSTGRES_PASSWORD}
|
||||||
|
APP_KEYS: ${APP_KEYS}
|
||||||
|
API_TOKEN_SALT: ${API_TOKEN_SALT}
|
||||||
|
ADMIN_JWT_SECRET: ${ADMIN_JWT_SECRET}
|
||||||
|
TRANSFER_TOKEN_SALT: ${TRANSFER_TOKEN_SALT}
|
||||||
|
JWT_SECRET: ${JWT_SECRET}
|
||||||
|
ENCRYPTION_KEY: ${ENCRYPTION_KEY}
|
||||||
|
STRAPI_URL: https://${CMS_DOMAIN}
|
||||||
|
volumes:
|
||||||
|
- cms-uploads:/app/public/uploads
|
||||||
|
|
||||||
|
frontend:
|
||||||
|
build: ./frontend
|
||||||
|
restart: unless-stopped
|
||||||
|
depends_on:
|
||||||
|
- cms
|
||||||
|
environment:
|
||||||
|
NODE_ENV: production
|
||||||
|
HOST: 0.0.0.0
|
||||||
|
PORT: 3000
|
||||||
|
NUXT_STRAPI_URL: ${STRAPI_URL}
|
||||||
|
NUXT_PUBLIC_SITE_URL: ${PUBLIC_SITE_URL}
|
||||||
|
NUXT_PUBLIC_STRAPI_URL: ${PUBLIC_STRAPI_URL}
|
||||||
|
# Absolute origin for the alternate-language links.
|
||||||
|
NUXT_PUBLIC_I18N_BASE_URL: ${PUBLIC_SITE_URL}
|
||||||
|
|
||||||
|
caddy:
|
||||||
|
image: caddy:2-alpine
|
||||||
|
restart: unless-stopped
|
||||||
|
depends_on:
|
||||||
|
- frontend
|
||||||
|
- cms
|
||||||
|
ports:
|
||||||
|
- "80:80"
|
||||||
|
- "443:443"
|
||||||
|
environment:
|
||||||
|
PUBLIC_DOMAIN: ${PUBLIC_DOMAIN}
|
||||||
|
CMS_DOMAIN: ${CMS_DOMAIN}
|
||||||
|
ACME_EMAIL: ${ACME_EMAIL}
|
||||||
|
volumes:
|
||||||
|
- ./caddy/Caddyfile:/etc/caddy/Caddyfile:ro
|
||||||
|
- caddy-data:/data
|
||||||
|
- caddy-config:/config
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
postgres-data:
|
||||||
|
cms-uploads:
|
||||||
|
caddy-data:
|
||||||
|
caddy-config:
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
node_modules
|
||||||
|
.nuxt
|
||||||
|
.output
|
||||||
|
.data
|
||||||
|
.env
|
||||||
|
.git
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
# Nuxt dev/build outputs
|
||||||
|
.output
|
||||||
|
.data
|
||||||
|
.nuxt
|
||||||
|
.nitro
|
||||||
|
.cache
|
||||||
|
dist
|
||||||
|
|
||||||
|
# Node dependencies
|
||||||
|
node_modules
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
|
||||||
|
# Misc
|
||||||
|
.DS_Store
|
||||||
|
.fleet
|
||||||
|
.idea
|
||||||
|
|
||||||
|
# Local env files
|
||||||
|
.env
|
||||||
|
.env.*
|
||||||
|
!.env.example
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
FROM node:22-alpine AS build
|
||||||
|
WORKDIR /app
|
||||||
|
COPY package*.json ./
|
||||||
|
RUN npm ci
|
||||||
|
COPY . .
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
FROM node:22-alpine AS runtime
|
||||||
|
WORKDIR /app
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
COPY --from=build /app/.output /app/.output
|
||||||
|
USER node
|
||||||
|
EXPOSE 3000
|
||||||
|
CMD ["node", ".output/server/index.mjs"]
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
# Nuxt Minimal Starter
|
||||||
|
|
||||||
|
Look at the [Nuxt documentation](https://nuxt.com/docs/getting-started/introduction) to learn more.
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
|
||||||
|
Make sure to install dependencies:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# npm
|
||||||
|
npm install
|
||||||
|
|
||||||
|
# pnpm
|
||||||
|
pnpm install
|
||||||
|
|
||||||
|
# yarn
|
||||||
|
yarn install
|
||||||
|
|
||||||
|
# bun
|
||||||
|
bun install
|
||||||
|
```
|
||||||
|
|
||||||
|
## Development Server
|
||||||
|
|
||||||
|
Start the development server on `http://localhost:3000`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# npm
|
||||||
|
npm run dev
|
||||||
|
|
||||||
|
# pnpm
|
||||||
|
pnpm dev
|
||||||
|
|
||||||
|
# yarn
|
||||||
|
yarn dev
|
||||||
|
|
||||||
|
# bun
|
||||||
|
bun run dev
|
||||||
|
```
|
||||||
|
|
||||||
|
## Production
|
||||||
|
|
||||||
|
Build the application for production:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# npm
|
||||||
|
npm run build
|
||||||
|
|
||||||
|
# pnpm
|
||||||
|
pnpm build
|
||||||
|
|
||||||
|
# yarn
|
||||||
|
yarn build
|
||||||
|
|
||||||
|
# bun
|
||||||
|
bun run build
|
||||||
|
```
|
||||||
|
|
||||||
|
Locally preview production build:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# npm
|
||||||
|
npm run preview
|
||||||
|
|
||||||
|
# pnpm
|
||||||
|
pnpm preview
|
||||||
|
|
||||||
|
# yarn
|
||||||
|
yarn preview
|
||||||
|
|
||||||
|
# bun
|
||||||
|
bun run preview
|
||||||
|
```
|
||||||
|
|
||||||
|
Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information.
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
// Emits <html lang>, the alternate-language links and og:locale for every page.
|
||||||
|
useHead(useLocaleHead())
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<NuxtRouteAnnouncer />
|
||||||
|
<NuxtLayout>
|
||||||
|
<NuxtPage />
|
||||||
|
</NuxtLayout>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,205 @@
|
|||||||
|
:root {
|
||||||
|
/* Neutral editorial palette: warm off-white paper, near-black ink. */
|
||||||
|
--color-ink: #14130f;
|
||||||
|
--color-body: #3d3a34;
|
||||||
|
--color-muted: #857f74;
|
||||||
|
--color-bg: #fbfaf7;
|
||||||
|
--color-surface: #f1efe9;
|
||||||
|
--color-border: #e0ddd4;
|
||||||
|
--color-rule: #14130f;
|
||||||
|
|
||||||
|
--font-display: Georgia, "Iowan Old Style", "Times New Roman", serif;
|
||||||
|
--font-sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
|
||||||
|
|
||||||
|
--width: 76rem;
|
||||||
|
--width-prose: 40rem;
|
||||||
|
--space: 1.5rem;
|
||||||
|
--radius: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
*,
|
||||||
|
*::before,
|
||||||
|
*::after {
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
color: var(--color-body);
|
||||||
|
background: var(--color-bg);
|
||||||
|
font-family: var(--font-sans);
|
||||||
|
font-size: 1rem;
|
||||||
|
line-height: 1.7;
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
}
|
||||||
|
|
||||||
|
img {
|
||||||
|
display: block;
|
||||||
|
max-width: 100%;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1,
|
||||||
|
h2,
|
||||||
|
h3 {
|
||||||
|
margin: 0;
|
||||||
|
color: var(--color-ink);
|
||||||
|
font-family: var(--font-display);
|
||||||
|
font-weight: 400;
|
||||||
|
line-height: 1.2;
|
||||||
|
text-wrap: balance;
|
||||||
|
}
|
||||||
|
|
||||||
|
:focus-visible {
|
||||||
|
outline: 2px solid var(--color-ink);
|
||||||
|
outline-offset: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container {
|
||||||
|
width: 100%;
|
||||||
|
max-width: var(--width);
|
||||||
|
margin-inline: auto;
|
||||||
|
padding-inline: var(--space);
|
||||||
|
}
|
||||||
|
|
||||||
|
.skip-link {
|
||||||
|
position: absolute;
|
||||||
|
left: -9999px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.skip-link:focus {
|
||||||
|
left: var(--space);
|
||||||
|
top: var(--space);
|
||||||
|
z-index: 10;
|
||||||
|
padding: 0.5rem 0.75rem;
|
||||||
|
background: var(--color-bg);
|
||||||
|
border: 1px solid var(--color-ink);
|
||||||
|
}
|
||||||
|
|
||||||
|
.muted {
|
||||||
|
color: var(--color-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Small uppercase label used for categories, dates and section headings. */
|
||||||
|
.kicker {
|
||||||
|
margin: 0;
|
||||||
|
font-family: var(--font-sans);
|
||||||
|
font-size: 0.7rem;
|
||||||
|
font-weight: 600;
|
||||||
|
letter-spacing: 0.14em;
|
||||||
|
text-transform: uppercase;
|
||||||
|
color: var(--color-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-heading {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 1.25rem;
|
||||||
|
margin-block: 4rem 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-heading::after {
|
||||||
|
content: "";
|
||||||
|
flex: 1;
|
||||||
|
height: 1px;
|
||||||
|
background: var(--color-border);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Centred title block at the top of a listing page. */
|
||||||
|
.page-header {
|
||||||
|
margin-bottom: 3.5rem;
|
||||||
|
padding-bottom: 2rem;
|
||||||
|
text-align: center;
|
||||||
|
border-bottom: 1px solid var(--color-border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-header h1 {
|
||||||
|
font-size: clamp(2rem, 5vw, 3rem);
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-header .kicker {
|
||||||
|
margin-bottom: 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-grid {
|
||||||
|
display: grid;
|
||||||
|
gap: 3rem 2.5rem;
|
||||||
|
grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
list-style: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Article body */
|
||||||
|
.prose {
|
||||||
|
max-width: var(--width-prose);
|
||||||
|
font-size: 1.075rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prose h2,
|
||||||
|
.prose h3 {
|
||||||
|
margin-block: 2.5rem 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prose h2 {
|
||||||
|
font-size: 1.6rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prose h3 {
|
||||||
|
font-size: 1.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prose p,
|
||||||
|
.prose ul,
|
||||||
|
.prose ol {
|
||||||
|
margin-block: 0 1.4rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prose a {
|
||||||
|
text-decoration: underline;
|
||||||
|
text-underline-offset: 0.2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prose blockquote {
|
||||||
|
margin: 2.5rem 0;
|
||||||
|
padding-left: 1.5rem;
|
||||||
|
border-left: 2px solid var(--color-ink);
|
||||||
|
font-family: var(--font-display);
|
||||||
|
font-size: 1.3rem;
|
||||||
|
line-height: 1.45;
|
||||||
|
color: var(--color-ink);
|
||||||
|
}
|
||||||
|
|
||||||
|
.prose img {
|
||||||
|
margin-block: 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prose pre {
|
||||||
|
overflow-x: auto;
|
||||||
|
padding: 1rem 1.25rem;
|
||||||
|
background: var(--color-surface);
|
||||||
|
border-radius: var(--radius);
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prose code {
|
||||||
|
font-size: 0.9em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pagination {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 2rem;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
margin-top: 4rem;
|
||||||
|
padding-top: 2rem;
|
||||||
|
border-top: 1px solid var(--color-border);
|
||||||
|
font-size: 0.85rem;
|
||||||
|
letter-spacing: 0.06em;
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import type { ArticleSummary } from '#shared/types/blog'
|
||||||
|
|
||||||
|
const props = defineProps<{ article: ArticleSummary }>()
|
||||||
|
|
||||||
|
const { locale } = useI18n()
|
||||||
|
const mediaUrl = useMediaUrl()
|
||||||
|
const cover = computed(() => mediaUrl(props.article.cover))
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<article class="card">
|
||||||
|
<NuxtLinkLocale
|
||||||
|
class="cover-link"
|
||||||
|
:to="`/blog/${article.slug}`"
|
||||||
|
tabindex="-1"
|
||||||
|
aria-hidden="true"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
v-if="cover"
|
||||||
|
class="cover"
|
||||||
|
:src="cover"
|
||||||
|
:alt="article.cover?.alternativeText ?? ''"
|
||||||
|
:width="article.cover?.width ?? undefined"
|
||||||
|
:height="article.cover?.height ?? undefined"
|
||||||
|
loading="lazy"
|
||||||
|
>
|
||||||
|
<span v-else class="cover placeholder" />
|
||||||
|
</NuxtLinkLocale>
|
||||||
|
|
||||||
|
<p v-if="article.category" class="kicker">{{ article.category.name }}</p>
|
||||||
|
|
||||||
|
<h2>
|
||||||
|
<NuxtLinkLocale :to="`/blog/${article.slug}`">{{ article.title }}</NuxtLinkLocale>
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<p class="kicker date">
|
||||||
|
<time :datetime="isoDate(article.publishedAt)">
|
||||||
|
{{ formatDate(article.publishedAt, locale) }}
|
||||||
|
</time>
|
||||||
|
</p>
|
||||||
|
</article>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.cover-link {
|
||||||
|
display: block;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cover {
|
||||||
|
width: 100%;
|
||||||
|
aspect-ratio: 4 / 5;
|
||||||
|
object-fit: cover;
|
||||||
|
background: var(--color-surface);
|
||||||
|
transition: transform 0.4s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cover-link:hover .cover {
|
||||||
|
transform: scale(1.03);
|
||||||
|
}
|
||||||
|
|
||||||
|
.placeholder {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.kicker {
|
||||||
|
margin-top: 1.1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
margin-top: 0.5rem;
|
||||||
|
font-size: 1.35rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 a {
|
||||||
|
text-decoration: none;
|
||||||
|
background-image: linear-gradient(var(--color-ink), var(--color-ink));
|
||||||
|
background-size: 0 1px;
|
||||||
|
background-position: 0 100%;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
transition: background-size 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 a:hover {
|
||||||
|
background-size: 100% 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.date {
|
||||||
|
margin-top: 0.6rem;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
<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>
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import type { StrapiImage } from '#shared/types/blog'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Strapi returns media paths relative to its own origin; the browser needs
|
||||||
|
* absolute ones. Remote providers (S3) already return absolute URLs.
|
||||||
|
*/
|
||||||
|
export function useMediaUrl() {
|
||||||
|
const { public: config } = useRuntimeConfig()
|
||||||
|
|
||||||
|
return (image: StrapiImage | null | undefined): string | null => {
|
||||||
|
if (!image?.url) return null
|
||||||
|
return image.url.startsWith('http') ? image.url : `${config.strapiUrl}${image.url}`
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import type { NuxtError } from '#app'
|
||||||
|
|
||||||
|
const props = defineProps<{ error: NuxtError }>()
|
||||||
|
|
||||||
|
const isNotFound = computed(() => props.error.statusCode === 404)
|
||||||
|
|
||||||
|
useHead(useLocaleHead())
|
||||||
|
useSeoMeta({ robots: 'noindex' })
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<NuxtLayout>
|
||||||
|
<h1>{{ isNotFound ? $t('error.notFoundTitle') : $t('error.genericTitle') }}</h1>
|
||||||
|
|
||||||
|
<p class="muted">
|
||||||
|
{{ isNotFound ? $t('error.notFoundBody') : $t('error.genericBody') }}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<NuxtLinkLocale to="/">{{ $t('error.backHome') }}</NuxtLinkLocale>
|
||||||
|
</p>
|
||||||
|
</NuxtLayout>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,223 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import type { Category } from '#shared/types/blog'
|
||||||
|
|
||||||
|
const { locale } = useI18n()
|
||||||
|
|
||||||
|
const { data: categories } = await useFetch<Category[]>('/api/categories', {
|
||||||
|
key: 'nav-categories',
|
||||||
|
default: () => [],
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="page">
|
||||||
|
<a class="skip-link" href="#main">{{ $t('site.skipToContent') }}</a>
|
||||||
|
|
||||||
|
<header class="site-header">
|
||||||
|
<div class="container">
|
||||||
|
<p class="wordmark">
|
||||||
|
<NuxtLinkLocale to="/">
|
||||||
|
<img src="/logo.png" :alt="SITE_NAME" width="400" height="400">
|
||||||
|
</NuxtLinkLocale>
|
||||||
|
</p>
|
||||||
|
<p class="tagline kicker">{{ $t('site.tagline') }}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<nav class="site-nav" :aria-label="$t('site.mainNavigation')">
|
||||||
|
<div class="container nav-inner">
|
||||||
|
<ul>
|
||||||
|
<li><NuxtLinkLocale to="/blog">{{ $t('site.allArticles') }}</NuxtLinkLocale></li>
|
||||||
|
<li v-for="category in categories" :key="category.slug">
|
||||||
|
<NuxtLinkLocale :to="`/category/${category.slug}`">
|
||||||
|
{{ category.name }}
|
||||||
|
</NuxtLinkLocale>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<LanguageSwitcher />
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<main id="main" class="container site-main">
|
||||||
|
<slot />
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<footer class="site-footer">
|
||||||
|
<div class="container footer-inner">
|
||||||
|
<div class="footer-block">
|
||||||
|
<img class="footer-logo" src="/logo.png" :alt="SITE_NAME" width="400" height="400">
|
||||||
|
<p class="muted">{{ $t('site.tagline') }}</p>
|
||||||
|
<address class="contact">
|
||||||
|
{{ $t('site.contact') }}:
|
||||||
|
<a :href="`mailto:${SITE_EMAIL}`">{{ SITE_EMAIL }}</a>
|
||||||
|
</address>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<nav class="footer-block" :aria-label="$t('site.categories')">
|
||||||
|
<p class="kicker">{{ $t('site.categories') }}</p>
|
||||||
|
<ul>
|
||||||
|
<li v-for="category in categories" :key="category.slug">
|
||||||
|
<NuxtLinkLocale :to="`/category/${category.slug}`">
|
||||||
|
{{ category.name }}
|
||||||
|
</NuxtLinkLocale>
|
||||||
|
</li>
|
||||||
|
<li v-if="!categories.length" class="muted">{{ $t('site.noCategories') }}</li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<nav class="footer-block" :aria-label="$t('site.browse')">
|
||||||
|
<p class="kicker">{{ $t('site.browse') }}</p>
|
||||||
|
<ul>
|
||||||
|
<li><NuxtLinkLocale to="/">{{ $t('site.home') }}</NuxtLinkLocale></li>
|
||||||
|
<li><NuxtLinkLocale to="/blog">{{ $t('site.allArticles') }}</NuxtLinkLocale></li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p class="container copyright kicker" :lang="locale">
|
||||||
|
© {{ new Date().getFullYear() }} {{ SITE_NAME }}. {{ $t('site.rights') }}
|
||||||
|
</p>
|
||||||
|
</footer>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.page {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
min-height: 100vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Header: centred wordmark over a thin rule of links. */
|
||||||
|
.site-header {
|
||||||
|
padding-top: 2.5rem;
|
||||||
|
text-align: center;
|
||||||
|
border-bottom: 1px solid var(--color-border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.wordmark {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wordmark a {
|
||||||
|
display: inline-block;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The seal carries the name itself, so it stands in for a text wordmark. */
|
||||||
|
.wordmark img {
|
||||||
|
width: clamp(6rem, 14vw, 8.5rem);
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tagline {
|
||||||
|
margin-top: 0.6rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.site-nav {
|
||||||
|
margin-top: 2rem;
|
||||||
|
border-top: 1px solid var(--color-border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-inner {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 0.75rem 2rem;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding-block: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.site-nav ul {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 0.25rem 2rem;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
list-style: none;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
font-weight: 600;
|
||||||
|
letter-spacing: 0.14em;
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
|
||||||
|
.site-nav a {
|
||||||
|
text-decoration: none;
|
||||||
|
color: var(--color-body);
|
||||||
|
padding-block: 0.25rem;
|
||||||
|
border-bottom: 1px solid transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.site-nav a:hover,
|
||||||
|
.site-nav a.router-link-active {
|
||||||
|
color: var(--color-ink);
|
||||||
|
border-bottom-color: var(--color-ink);
|
||||||
|
}
|
||||||
|
|
||||||
|
.site-main {
|
||||||
|
flex: 1;
|
||||||
|
padding-block: 3.5rem 5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Footer: columns, then a centred copyright line. */
|
||||||
|
.site-footer {
|
||||||
|
padding-block: 3.5rem 2rem;
|
||||||
|
background: var(--color-surface);
|
||||||
|
border-top: 1px solid var(--color-border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer-inner {
|
||||||
|
display: grid;
|
||||||
|
gap: 2.5rem;
|
||||||
|
grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
|
||||||
|
padding-bottom: 2.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer-block p:last-of-type {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer-logo {
|
||||||
|
width: 4.5rem;
|
||||||
|
height: auto;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contact {
|
||||||
|
margin-top: 0.75rem;
|
||||||
|
font-size: 0.95rem;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contact a {
|
||||||
|
text-decoration: underline;
|
||||||
|
text-underline-offset: 0.2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer-block ul {
|
||||||
|
padding: 0;
|
||||||
|
margin: 0.9rem 0 0;
|
||||||
|
list-style: none;
|
||||||
|
font-size: 0.95rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer-block li + li {
|
||||||
|
margin-top: 0.35rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer-block a {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer-block a:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
text-underline-offset: 0.2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copyright {
|
||||||
|
padding-top: 1.75rem;
|
||||||
|
text-align: center;
|
||||||
|
border-top: 1px solid var(--color-border);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,145 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import type { Article } from '#shared/types/blog'
|
||||||
|
|
||||||
|
const { locale } = useI18n()
|
||||||
|
const route = useRoute()
|
||||||
|
const slug = route.params.slug as string
|
||||||
|
|
||||||
|
const { data: article } = await useFetch<Article>(`/api/articles/${slug}`)
|
||||||
|
|
||||||
|
if (!article.value) {
|
||||||
|
throw createError({ statusCode: 404, statusMessage: 'Article not found', fatal: true })
|
||||||
|
}
|
||||||
|
|
||||||
|
const { public: config } = useRuntimeConfig()
|
||||||
|
const mediaUrl = useMediaUrl()
|
||||||
|
|
||||||
|
const canonical = `${config.siteUrl}${route.path}`
|
||||||
|
const cover = computed(() => mediaUrl(article.value?.cover) ?? undefined)
|
||||||
|
|
||||||
|
useSeoMeta({
|
||||||
|
title: article.value.title,
|
||||||
|
description: article.value.summary,
|
||||||
|
ogTitle: article.value.title,
|
||||||
|
ogDescription: article.value.summary,
|
||||||
|
ogType: 'article',
|
||||||
|
ogUrl: canonical,
|
||||||
|
ogImage: cover,
|
||||||
|
twitterCard: 'summary_large_image',
|
||||||
|
})
|
||||||
|
|
||||||
|
useHead({
|
||||||
|
link: [{ rel: 'canonical', href: canonical }],
|
||||||
|
script: [
|
||||||
|
{
|
||||||
|
type: 'application/ld+json',
|
||||||
|
innerHTML: JSON.stringify({
|
||||||
|
'@context': 'https://schema.org',
|
||||||
|
'@type': 'BlogPosting',
|
||||||
|
headline: article.value.title,
|
||||||
|
description: article.value.summary,
|
||||||
|
datePublished: isoDate(article.value.publishedAt),
|
||||||
|
image: cover.value ? [cover.value] : undefined,
|
||||||
|
mainEntityOfPage: { '@type': 'WebPage', '@id': canonical },
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<article v-if="article">
|
||||||
|
<header class="article-header">
|
||||||
|
<nav class="kicker" :aria-label="$t('article.breadcrumb')">
|
||||||
|
<NuxtLinkLocale to="/blog">{{ $t('list.articles') }}</NuxtLinkLocale>
|
||||||
|
<template v-if="article.category">
|
||||||
|
<span aria-hidden="true"> / </span>
|
||||||
|
<NuxtLinkLocale :to="`/category/${article.category.slug}`">
|
||||||
|
{{ article.category.name }}
|
||||||
|
</NuxtLinkLocale>
|
||||||
|
</template>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<h1>{{ article.title }}</h1>
|
||||||
|
|
||||||
|
<p class="kicker date">
|
||||||
|
<time :datetime="isoDate(article.publishedAt)">
|
||||||
|
{{ formatDate(article.publishedAt, locale) }}
|
||||||
|
</time>
|
||||||
|
</p>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<img
|
||||||
|
v-if="cover"
|
||||||
|
class="cover"
|
||||||
|
:src="cover"
|
||||||
|
:alt="article.cover?.alternativeText ?? ''"
|
||||||
|
:width="article.cover?.width ?? undefined"
|
||||||
|
:height="article.cover?.height ?? undefined"
|
||||||
|
>
|
||||||
|
|
||||||
|
<!-- eslint-disable-next-line vue/no-v-html -- rendered server-side from editor Markdown -->
|
||||||
|
<div class="prose" v-html="article.html" />
|
||||||
|
|
||||||
|
<p class="back">
|
||||||
|
<NuxtLinkLocale to="/blog">{{ $t('article.back') }}</NuxtLinkLocale>
|
||||||
|
</p>
|
||||||
|
</article>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.article-header {
|
||||||
|
max-width: 46rem;
|
||||||
|
margin-inline: auto;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-header nav a {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-header nav a:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
text-underline-offset: 0.2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
margin: 1rem 0 0;
|
||||||
|
font-size: clamp(2rem, 5vw, 3.2rem);
|
||||||
|
}
|
||||||
|
|
||||||
|
.date {
|
||||||
|
margin-top: 1rem;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prose {
|
||||||
|
margin-inline: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.back {
|
||||||
|
max-width: var(--width-prose);
|
||||||
|
margin: 4rem auto 0;
|
||||||
|
padding-top: 2rem;
|
||||||
|
border-top: 1px solid var(--color-border);
|
||||||
|
text-align: center;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
font-weight: 600;
|
||||||
|
letter-spacing: 0.14em;
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
|
||||||
|
.back a {
|
||||||
|
text-decoration: none;
|
||||||
|
border-bottom: 1px solid var(--color-ink);
|
||||||
|
padding-bottom: 0.3rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cover {
|
||||||
|
width: 100%;
|
||||||
|
aspect-ratio: 3 / 2;
|
||||||
|
object-fit: cover;
|
||||||
|
margin-block: 3rem;
|
||||||
|
background: var(--color-surface);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import type { ArticleSummary, Paginated } from '#shared/types/blog'
|
||||||
|
|
||||||
|
const { t } = useI18n()
|
||||||
|
const route = useRoute()
|
||||||
|
|
||||||
|
const page = computed(() => {
|
||||||
|
const value = Number(route.query.page)
|
||||||
|
return Number.isInteger(value) && value > 0 ? value : 1
|
||||||
|
})
|
||||||
|
|
||||||
|
const { data, error, status } = await useFetch<Paginated<ArticleSummary>>('/api/articles', {
|
||||||
|
query: { page },
|
||||||
|
})
|
||||||
|
|
||||||
|
const { public: config } = useRuntimeConfig()
|
||||||
|
const canonical = computed(
|
||||||
|
() => `${config.siteUrl}${route.path}${page.value > 1 ? `?page=${page.value}` : ''}`
|
||||||
|
)
|
||||||
|
|
||||||
|
useSeoMeta({
|
||||||
|
title: () => (page.value > 1 ? t('list.articlesPage', { page: page.value }) : t('list.articles')),
|
||||||
|
description: () => t('list.archiveDescription'),
|
||||||
|
ogType: 'website',
|
||||||
|
})
|
||||||
|
|
||||||
|
useHead({ link: [{ rel: 'canonical', href: canonical }] })
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<header class="page-header">
|
||||||
|
<p class="kicker">{{ $t('list.archive') }}</p>
|
||||||
|
<h1>{{ $t('list.articles') }}</h1>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<p v-if="error">{{ $t('list.failed') }}</p>
|
||||||
|
|
||||||
|
<p v-else-if="status === 'pending'">{{ $t('list.loading') }}</p>
|
||||||
|
|
||||||
|
<p v-else-if="!data?.items.length">{{ $t('list.empty') }}</p>
|
||||||
|
|
||||||
|
<template v-else>
|
||||||
|
<ul class="card-grid">
|
||||||
|
<li v-for="article in data.items" :key="article.slug">
|
||||||
|
<ArticleCard :article="article" />
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<nav v-if="data.pageCount > 1" class="pagination" :aria-label="$t('pagination.label')">
|
||||||
|
<NuxtLink v-if="data.page > 1" :to="{ query: { page: data.page - 1 } }" rel="prev">
|
||||||
|
{{ $t('pagination.previous') }}
|
||||||
|
</NuxtLink>
|
||||||
|
<span class="muted">
|
||||||
|
{{ $t('pagination.position', { page: data.page, total: data.pageCount }) }}
|
||||||
|
</span>
|
||||||
|
<NuxtLink
|
||||||
|
v-if="data.page < data.pageCount"
|
||||||
|
:to="{ query: { page: data.page + 1 } }"
|
||||||
|
rel="next"
|
||||||
|
>
|
||||||
|
{{ $t('pagination.next') }}
|
||||||
|
</NuxtLink>
|
||||||
|
</nav>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import type { ArticleSummary, Paginated, Category } from '#shared/types/blog'
|
||||||
|
|
||||||
|
const { t } = useI18n()
|
||||||
|
const route = useRoute()
|
||||||
|
const slug = route.params.slug as string
|
||||||
|
|
||||||
|
const page = computed(() => {
|
||||||
|
const value = Number(route.query.page)
|
||||||
|
return Number.isInteger(value) && value > 0 ? value : 1
|
||||||
|
})
|
||||||
|
|
||||||
|
const { data: category } = await useFetch<Category>(`/api/categories/${slug}`)
|
||||||
|
|
||||||
|
if (!category.value) {
|
||||||
|
throw createError({ statusCode: 404, statusMessage: 'Category not found', fatal: true })
|
||||||
|
}
|
||||||
|
|
||||||
|
const { data, error } = await useFetch<Paginated<ArticleSummary>>('/api/articles', {
|
||||||
|
query: { page, category: slug },
|
||||||
|
})
|
||||||
|
|
||||||
|
const { public: config } = useRuntimeConfig()
|
||||||
|
const canonical = computed(
|
||||||
|
() => `${config.siteUrl}${route.path}${page.value > 1 ? `?page=${page.value}` : ''}`
|
||||||
|
)
|
||||||
|
|
||||||
|
useSeoMeta({
|
||||||
|
title: category.value.name,
|
||||||
|
description: () => t('list.categoryDescription', { name: category.value?.name ?? '' }),
|
||||||
|
ogType: 'website',
|
||||||
|
})
|
||||||
|
|
||||||
|
useHead({ link: [{ rel: 'canonical', href: canonical }] })
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<header class="page-header">
|
||||||
|
<p class="kicker">{{ $t('list.category') }}</p>
|
||||||
|
<h1>{{ category?.name }}</h1>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<p v-if="error">{{ $t('list.failed') }}</p>
|
||||||
|
|
||||||
|
<p v-else-if="!data?.items.length">{{ $t('list.categoryEmpty') }}</p>
|
||||||
|
|
||||||
|
<template v-else>
|
||||||
|
<ul class="card-grid">
|
||||||
|
<li v-for="article in data.items" :key="article.slug">
|
||||||
|
<ArticleCard :article="article" />
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<nav v-if="data.pageCount > 1" class="pagination" :aria-label="$t('pagination.label')">
|
||||||
|
<NuxtLink v-if="data.page > 1" :to="{ query: { page: data.page - 1 } }" rel="prev">
|
||||||
|
{{ $t('pagination.previous') }}
|
||||||
|
</NuxtLink>
|
||||||
|
<span class="muted">
|
||||||
|
{{ $t('pagination.position', { page: data.page, total: data.pageCount }) }}
|
||||||
|
</span>
|
||||||
|
<NuxtLink
|
||||||
|
v-if="data.page < data.pageCount"
|
||||||
|
:to="{ query: { page: data.page + 1 } }"
|
||||||
|
rel="next"
|
||||||
|
>
|
||||||
|
{{ $t('pagination.next') }}
|
||||||
|
</NuxtLink>
|
||||||
|
</nav>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,180 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import type { ArticleSummary, Paginated } from '#shared/types/blog'
|
||||||
|
|
||||||
|
const { t, locale } = useI18n()
|
||||||
|
|
||||||
|
const { data, error } = await useFetch<Paginated<ArticleSummary>>('/api/articles', {
|
||||||
|
key: 'home-articles',
|
||||||
|
query: { page: 1 },
|
||||||
|
})
|
||||||
|
|
||||||
|
/** The newest article leads the page; the next six fill the grid below it. */
|
||||||
|
const featured = computed(() => data.value?.items[0] ?? null)
|
||||||
|
const rest = computed(() => data.value?.items.slice(1, 7) ?? [])
|
||||||
|
|
||||||
|
const mediaUrl = useMediaUrl()
|
||||||
|
const featuredCover = computed(() => mediaUrl(featured.value?.cover))
|
||||||
|
|
||||||
|
const { public: config } = useRuntimeConfig()
|
||||||
|
const route = useRoute()
|
||||||
|
const canonical = computed(() => `${config.siteUrl}${route.path}`)
|
||||||
|
|
||||||
|
// The home page is the site itself, so it carries the bare name as its title.
|
||||||
|
useHead({ titleTemplate: '%s', link: [{ rel: 'canonical', href: canonical }] })
|
||||||
|
|
||||||
|
useSeoMeta({
|
||||||
|
title: SITE_NAME,
|
||||||
|
description: () => t('site.tagline'),
|
||||||
|
ogTitle: SITE_NAME,
|
||||||
|
ogDescription: () => t('site.tagline'),
|
||||||
|
ogType: 'website',
|
||||||
|
ogUrl: canonical,
|
||||||
|
ogImage: `${config.siteUrl}/logo.png`,
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<p v-if="error">{{ $t('list.failed') }}</p>
|
||||||
|
|
||||||
|
<p v-else-if="!featured">{{ $t('list.empty') }}</p>
|
||||||
|
|
||||||
|
<template v-else>
|
||||||
|
<article class="featured">
|
||||||
|
<NuxtLinkLocale
|
||||||
|
class="featured-cover"
|
||||||
|
:to="`/blog/${featured.slug}`"
|
||||||
|
tabindex="-1"
|
||||||
|
aria-hidden="true"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
v-if="featuredCover"
|
||||||
|
:src="featuredCover"
|
||||||
|
:alt="featured.cover?.alternativeText ?? ''"
|
||||||
|
:width="featured.cover?.width ?? undefined"
|
||||||
|
:height="featured.cover?.height ?? undefined"
|
||||||
|
>
|
||||||
|
<span v-else class="placeholder" />
|
||||||
|
</NuxtLinkLocale>
|
||||||
|
|
||||||
|
<div class="featured-text">
|
||||||
|
<p class="kicker">
|
||||||
|
{{ featured.category ? featured.category.name : $t('home.latest') }}
|
||||||
|
</p>
|
||||||
|
<h1>
|
||||||
|
<NuxtLinkLocale :to="`/blog/${featured.slug}`">{{ featured.title }}</NuxtLinkLocale>
|
||||||
|
</h1>
|
||||||
|
<p class="kicker date">
|
||||||
|
<time :datetime="isoDate(featured.publishedAt)">
|
||||||
|
{{ formatDate(featured.publishedAt, locale) }}
|
||||||
|
</time>
|
||||||
|
</p>
|
||||||
|
<p class="read-more">
|
||||||
|
<NuxtLinkLocale :to="`/blog/${featured.slug}`">
|
||||||
|
{{ $t('home.readArticle') }}
|
||||||
|
</NuxtLinkLocale>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</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">
|
||||||
|
<NuxtLinkLocale to="/blog">{{ $t('home.viewAll') }}</NuxtLinkLocale>
|
||||||
|
</p>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.featured {
|
||||||
|
display: grid;
|
||||||
|
gap: 2.5rem;
|
||||||
|
align-items: center;
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 52rem) {
|
||||||
|
.featured {
|
||||||
|
grid-template-columns: 1.35fr 1fr;
|
||||||
|
gap: 3.5rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.featured-cover {
|
||||||
|
display: block;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.featured-cover img,
|
||||||
|
.placeholder {
|
||||||
|
width: 100%;
|
||||||
|
aspect-ratio: 3 / 2;
|
||||||
|
object-fit: cover;
|
||||||
|
background: var(--color-surface);
|
||||||
|
}
|
||||||
|
|
||||||
|
.featured h1 {
|
||||||
|
margin-top: 0.6rem;
|
||||||
|
font-size: clamp(2rem, 4.5vw, 3.1rem);
|
||||||
|
}
|
||||||
|
|
||||||
|
.featured h1 a {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.featured h1 a:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
text-underline-offset: 0.12em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.date {
|
||||||
|
margin-top: 1rem;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
|
||||||
|
.read-more {
|
||||||
|
margin-top: 1.75rem;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
font-weight: 600;
|
||||||
|
letter-spacing: 0.14em;
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
|
||||||
|
.read-more a {
|
||||||
|
padding-bottom: 0.35rem;
|
||||||
|
text-decoration: none;
|
||||||
|
border-bottom: 1px solid var(--color-ink);
|
||||||
|
}
|
||||||
|
|
||||||
|
.more {
|
||||||
|
margin-top: 4rem;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
font-weight: 600;
|
||||||
|
letter-spacing: 0.14em;
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
|
||||||
|
.more a {
|
||||||
|
padding: 0.85rem 2.5rem;
|
||||||
|
text-decoration: none;
|
||||||
|
border: 1px solid var(--color-ink);
|
||||||
|
color: var(--color-ink);
|
||||||
|
display: inline-block;
|
||||||
|
transition: background 0.2s ease, color 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.more a:hover {
|
||||||
|
background: var(--color-ink);
|
||||||
|
color: var(--color-bg);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
{
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
{
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
{
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
{
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
import { SITE_NAME } from './shared/utils/site'
|
||||||
|
|
||||||
|
// https://nuxt.com/docs/api/configuration/nuxt-config
|
||||||
|
export default defineNuxtConfig({
|
||||||
|
compatibilityDate: '2025-07-15',
|
||||||
|
devtools: { enabled: true },
|
||||||
|
|
||||||
|
modules: ['@nuxtjs/i18n'],
|
||||||
|
|
||||||
|
css: ['~/assets/css/main.css'],
|
||||||
|
|
||||||
|
app: {
|
||||||
|
head: {
|
||||||
|
titleTemplate: `%s · ${SITE_NAME}`,
|
||||||
|
meta: [{ name: 'viewport', content: 'width=device-width, initial-scale=1' }],
|
||||||
|
link: [
|
||||||
|
{ rel: 'icon', href: '/favicon.ico', sizes: '16x16 32x32 48x48 64x64' },
|
||||||
|
{ rel: 'apple-touch-icon', href: '/apple-touch-icon.png' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
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: {
|
||||||
|
// Server-only: internal Strapi address, never exposed to the browser.
|
||||||
|
strapiUrl: 'http://localhost:1337',
|
||||||
|
strapiToken: '',
|
||||||
|
public: {
|
||||||
|
// Canonical origin of the public website.
|
||||||
|
siteUrl: 'http://localhost:3000',
|
||||||
|
// Browser-reachable Strapi origin, used to build absolute media URLs.
|
||||||
|
strapiUrl: 'http://localhost:1337',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
typescript: {
|
||||||
|
strict: true,
|
||||||
|
},
|
||||||
|
})
|
||||||
Generated
+12107
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"name": "frontend",
|
||||||
|
"type": "module",
|
||||||
|
"private": true,
|
||||||
|
"scripts": {
|
||||||
|
"build": "nuxt build",
|
||||||
|
"dev": "nuxt dev",
|
||||||
|
"generate": "nuxt generate",
|
||||||
|
"preview": "nuxt preview",
|
||||||
|
"postinstall": "nuxt prepare",
|
||||||
|
"typecheck": "nuxt typecheck"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@nuxtjs/i18n": "^10.6.0",
|
||||||
|
"marked": "^18.0.11",
|
||||||
|
"nuxt": "^4.5.2",
|
||||||
|
"vue": "^3.5.41",
|
||||||
|
"vue-router": "^5.2.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"typescript": "^5.9.3",
|
||||||
|
"vue-tsc": "^3.3.11"
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 31 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 118 KiB |
@@ -0,0 +1,2 @@
|
|||||||
|
User-Agent: *
|
||||||
|
Disallow:
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import type { Article } from '#shared/types/blog'
|
||||||
|
|
||||||
|
type RawArticle = Omit<Article, 'html' | 'summary'> & { content: string | null }
|
||||||
|
|
||||||
|
export default defineEventHandler(async (event): Promise<Article> => {
|
||||||
|
const slug = getRouterParam(event, 'slug')
|
||||||
|
|
||||||
|
if (!slug) {
|
||||||
|
throw createError({ statusCode: 400, statusMessage: 'Missing article slug' })
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await strapiFetch<StrapiList<RawArticle>>(
|
||||||
|
`/api/articles?${ARTICLE_DETAIL_QUERY}&filters[slug][$eq]=${encodeURIComponent(slug)}&pagination[pageSize]=1`
|
||||||
|
)
|
||||||
|
|
||||||
|
const article = response.data[0]
|
||||||
|
|
||||||
|
if (!article) {
|
||||||
|
throw createError({ statusCode: 404, statusMessage: 'Article not found' })
|
||||||
|
}
|
||||||
|
|
||||||
|
const { content, ...rest } = article
|
||||||
|
return { ...rest, html: renderMarkdown(content), summary: summarise(content) }
|
||||||
|
})
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import type { ArticleSummary, Paginated } from '#shared/types/blog'
|
||||||
|
|
||||||
|
export default defineEventHandler(async (event): Promise<Paginated<ArticleSummary>> => {
|
||||||
|
const query = getQuery(event)
|
||||||
|
const page = pageParam(query.page)
|
||||||
|
const category = typeof query.category === 'string' ? query.category : null
|
||||||
|
|
||||||
|
const filter = category
|
||||||
|
? `&filters[category][slug][$eq]=${encodeURIComponent(category)}`
|
||||||
|
: ''
|
||||||
|
|
||||||
|
const response = await strapiFetch<StrapiList<ArticleSummary>>(
|
||||||
|
`/api/articles?${ARTICLE_SUMMARY_QUERY}&${pagination(page)}${filter}`
|
||||||
|
)
|
||||||
|
|
||||||
|
return {
|
||||||
|
items: response.data,
|
||||||
|
page: response.meta.pagination.page,
|
||||||
|
pageCount: response.meta.pagination.pageCount,
|
||||||
|
total: response.meta.pagination.total,
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import type { Category } from '#shared/types/blog'
|
||||||
|
|
||||||
|
export default defineEventHandler(async (event): Promise<Category> => {
|
||||||
|
const slug = getRouterParam(event, 'slug')
|
||||||
|
|
||||||
|
if (!slug) {
|
||||||
|
throw createError({ statusCode: 400, statusMessage: 'Missing category slug' })
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await strapiFetch<StrapiList<Category>>(
|
||||||
|
`/api/categories?fields[0]=name&fields[1]=slug&filters[slug][$eq]=${encodeURIComponent(slug)}&pagination[pageSize]=1`
|
||||||
|
)
|
||||||
|
|
||||||
|
const category = response.data[0]
|
||||||
|
|
||||||
|
if (!category) {
|
||||||
|
throw createError({ statusCode: 404, statusMessage: 'Category not found' })
|
||||||
|
}
|
||||||
|
|
||||||
|
return category
|
||||||
|
})
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import type { Category } from '#shared/types/blog'
|
||||||
|
|
||||||
|
export default defineEventHandler(async (): Promise<Category[]> => {
|
||||||
|
const response = await strapiFetch<StrapiList<Category>>(
|
||||||
|
'/api/categories?fields[0]=name&fields[1]=slug&sort[0]=name:asc&pagination[pageSize]=100'
|
||||||
|
)
|
||||||
|
|
||||||
|
return response.data
|
||||||
|
})
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
/** Strapi query fragments. Only the fields the pages actually render are requested. */
|
||||||
|
|
||||||
|
const list = (prefix: string, names: readonly string[]) =>
|
||||||
|
names.map((name, i) => `${prefix}[${i}]=${name}`).join('&')
|
||||||
|
|
||||||
|
const IMAGE_FIELDS = ['url', 'alternativeText', 'width', 'height'] as const
|
||||||
|
|
||||||
|
export const ARTICLE_SUMMARY_QUERY = [
|
||||||
|
list('fields', ['title', 'slug', 'publishedAt']),
|
||||||
|
list('populate[cover][fields]', IMAGE_FIELDS),
|
||||||
|
list('populate[category][fields]', ['name', 'slug']),
|
||||||
|
'sort[0]=publishedAt:desc',
|
||||||
|
].join('&')
|
||||||
|
|
||||||
|
export const ARTICLE_DETAIL_QUERY = [
|
||||||
|
list('fields', ['title', 'slug', 'content', 'publishedAt']),
|
||||||
|
list('populate[cover][fields]', IMAGE_FIELDS),
|
||||||
|
list('populate[category][fields]', ['name', 'slug']),
|
||||||
|
].join('&')
|
||||||
|
|
||||||
|
export const PAGE_SIZE = 12
|
||||||
|
|
||||||
|
export const pagination = (page: number, pageSize = PAGE_SIZE) =>
|
||||||
|
`pagination[page]=${page}&pagination[pageSize]=${pageSize}`
|
||||||
|
|
||||||
|
/** Reads a positive integer query param, falling back to 1. */
|
||||||
|
export const pageParam = (value: unknown): number => {
|
||||||
|
const page = Number(value)
|
||||||
|
return Number.isInteger(page) && page > 0 ? page : 1
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
import { marked } from 'marked'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calls the Strapi REST API from the server only, so the internal URL and any
|
||||||
|
* future API token never reach the browser.
|
||||||
|
*/
|
||||||
|
export async function strapiFetch<T>(path: string): Promise<T> {
|
||||||
|
const { strapiUrl, strapiToken } = useRuntimeConfig()
|
||||||
|
|
||||||
|
try {
|
||||||
|
return (await $fetch(path, {
|
||||||
|
baseURL: strapiUrl,
|
||||||
|
headers: strapiToken ? { Authorization: `Bearer ${strapiToken}` } : undefined,
|
||||||
|
})) as T
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`Strapi request failed: ${path}`, error)
|
||||||
|
throw createError({ statusCode: 502, statusMessage: 'Content service unavailable' })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renders the Markdown body server-side, so the HTML is crawlable and `marked`
|
||||||
|
* stays out of the client bundle.
|
||||||
|
*
|
||||||
|
* ponytail: no HTML sanitisation — article bodies come from authenticated
|
||||||
|
* editors only. Add DOMPurify here if authoring is ever opened up further.
|
||||||
|
*/
|
||||||
|
export function renderMarkdown(source: string | null | undefined): string {
|
||||||
|
return source ? (marked.parse(source, { async: false }) as string) : ''
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* There is no excerpt field: the meta description is the opening of the body,
|
||||||
|
* stripped of Markdown syntax and clipped on a word boundary.
|
||||||
|
*/
|
||||||
|
export function summarise(source: string | null | undefined, maxLength = 155): string {
|
||||||
|
const text = (source ?? '')
|
||||||
|
.replace(/```[\s\S]*?```/g, ' ')
|
||||||
|
.replace(/!\[[^\]]*\]\([^)]*\)/g, ' ')
|
||||||
|
.replace(/\[([^\]]*)\]\([^)]*\)/g, '$1')
|
||||||
|
.replace(/[#>*_`~-]/g, ' ')
|
||||||
|
.replace(/\s+/g, ' ')
|
||||||
|
.trim()
|
||||||
|
|
||||||
|
if (text.length <= maxLength) return text
|
||||||
|
|
||||||
|
const clipped = text.slice(0, maxLength)
|
||||||
|
return `${clipped.slice(0, clipped.lastIndexOf(' ')).trimEnd()}…`
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface StrapiList<T> {
|
||||||
|
data: T[]
|
||||||
|
meta: { pagination: { page: number; pageCount: number; total: number } }
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
/** Shape of the Strapi payloads, narrowed to what the site actually renders. */
|
||||||
|
|
||||||
|
export interface StrapiImage {
|
||||||
|
url: string
|
||||||
|
alternativeText: string | null
|
||||||
|
width: number | null
|
||||||
|
height: number | null
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Category {
|
||||||
|
name: string
|
||||||
|
slug: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/** An article as returned by the listing endpoints. */
|
||||||
|
export interface ArticleSummary {
|
||||||
|
title: string
|
||||||
|
slug: string
|
||||||
|
publishedAt: string
|
||||||
|
cover: StrapiImage | null
|
||||||
|
category: Category | null
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A single article, with the body already rendered to HTML server-side. */
|
||||||
|
export interface Article extends ArticleSummary {
|
||||||
|
html: string
|
||||||
|
/** Plain-text opening of the body, used as the meta description. */
|
||||||
|
summary: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Paginated<T> {
|
||||||
|
items: T[]
|
||||||
|
page: number
|
||||||
|
pageCount: number
|
||||||
|
total: number
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
/** Human-readable date for display; returns an empty string when unset. */
|
||||||
|
export function formatDate(value: string | null | undefined, locale = 'en-GB'): string {
|
||||||
|
if (!value) return ''
|
||||||
|
return new Intl.DateTimeFormat(locale, { dateStyle: 'long' }).format(new Date(value))
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Machine-readable date for the `datetime` attribute and structured data. */
|
||||||
|
export function isoDate(value: string | null | undefined): string {
|
||||||
|
return value ? new Date(value).toISOString() : ''
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
/** Name of the blog. Not translated: it is the brand. */
|
||||||
|
export const SITE_NAME = 'CorralitoComing'
|
||||||
|
|
||||||
|
/** Public contact address, shown in the footer. */
|
||||||
|
export const SITE_EMAIL = 'corralitocoming@gmail.com'
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
// https://nuxt.com/docs/guide/concepts/typescript
|
||||||
|
"files": [],
|
||||||
|
"references": [
|
||||||
|
{
|
||||||
|
"path": "./.nuxt/tsconfig.app.json"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "./.nuxt/tsconfig.server.json"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "./.nuxt/tsconfig.shared.json"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "./.nuxt/tsconfig.node.json"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in new issue
Block a user