Pass siteDescription to page metadata; document media cache rule
createPageMetadata read Site Settings → siteDescription but never passed it to buildMetadata, so pages without their own meta description had no <meta name="description"> or og:description. Regression test in seo.test.ts. storage.md: Cloudflare Cache Rule for the media domain (R2 objects carry no Cache-Control; storage-s3 cannot set it, Cloudflare defaults to 4 h). Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
d28cbe2570
commit
a6eda2e3a3
@@ -8,6 +8,23 @@ wersji naraz przejdź po kolei wszystkie sekcje „Wymaga zmian w projekcie” o
|
||||
wersji, którą masz. Nowe wydanie = nowa sekcja na górze; najstarsze usuwamy
|
||||
dopiero powyżej 20.
|
||||
|
||||
## 1.10.1
|
||||
|
||||
### Poprawki
|
||||
- **Zapasowy metaopis działa.** `createPageMetadata` (a więc `createPageRoute` / `generatePageMetadata`) czytał
|
||||
Site Settings → `siteDescription`, ale nie przekazywał go do `buildMetadata` — strona bez własnego
|
||||
`meta.description` nie miała `<meta name="description">` ani `og:description` (Lighthouse SEO: „Dokument nie
|
||||
ma metaopisu”). Test regresyjny w `test/seo.test.ts`.
|
||||
|
||||
### Dokumentacja
|
||||
- storage.md → „Pamięć podręczna mediów”: reguła Cache Rules w Cloudflare dla domeny mediów (1 rok). Pliki w R2
|
||||
nie mają `Cache-Control` (adapter S3 nie pozwala go ustawić), a Cloudflare daje domyślnie 4 h.
|
||||
|
||||
### Wymaga zmian w projekcie
|
||||
- Obejście metaopisu w projekcie (własne uzupełnianie `description` w `generateMetadata`) można usunąć —
|
||||
wystarczy `export const generateMetadata = route.generateMetadata`.
|
||||
- Cloudflare: dodaj regułę Cache Rules dla domeny mediów (storage.md).
|
||||
|
||||
## 1.10.0
|
||||
|
||||
### Nowe
|
||||
|
||||
@@ -132,6 +132,27 @@ ustawiona). Bez niej Payload zwróci URL wskazujący na prywatny endpoint S3 →
|
||||
Bez tego media wgrają się do R2, ale front pokaże 403. Konfiguracja domeny jest
|
||||
po stronie Cloudflare, publiczny URL po stronie projektu (.env).
|
||||
|
||||
### Pamięć podręczna mediów (Cache Rule — obowiązkowo)
|
||||
|
||||
Pliki w R2 nie mają nagłówka `Cache-Control`: `@payloadcms/storage-s3` przy wysyłce ustawia tylko
|
||||
`ContentType` i `ACL`, bez opcji na nagłówki. Cloudflare daje wtedy przeglądarce domyślne **4 h** —
|
||||
Lighthouse: „Używaj efektywnego czasu przechowywania w pamięci podręcznej” (wideo, logo, tła pobierane od
|
||||
nowa przy każdej wizycie po 4 h). Nazwy plików są stałe (nowa wersja = nowy plik z `normalizeFilename`),
|
||||
więc długi czas jest bezpieczny.
|
||||
|
||||
Cloudflare → strefa domeny → **Caching → Cache Rules → Create rule**:
|
||||
- *When incoming requests match*: `Hostname` equals `media.klient.pl` (domena z `R2_PUBLIC_URL`);
|
||||
- *Cache eligibility*: Eligible for cache;
|
||||
- *Edge TTL*: Ignore cache-control header and use this TTL → **1 year**;
|
||||
- *Browser TTL*: Override origin and use this TTL → **1 year**.
|
||||
|
||||
Sprawdzenie (po kilku minutach):
|
||||
```bash
|
||||
curl -sI https://media.klient.pl/<plik> | grep -iE 'cache-control|cf-cache-status'
|
||||
# cache-control: max-age=31536000 cf-cache-status: HIT (przy drugim zapytaniu)
|
||||
```
|
||||
Podmiana pliku pod TĄ SAMĄ nazwą (rzadkie — panel nadaje nową) wymaga Caching → Purge → Custom (URL).
|
||||
|
||||
## Migracja istniejących mediów
|
||||
|
||||
Jeśli projekt miał media lokalnie i przełączasz na R2 — nowe uploady idą do R2,
|
||||
|
||||
@@ -142,6 +142,8 @@ export function createPageMetadata(args: CreatePageMetadataArgs) {
|
||||
locale,
|
||||
order: site.order,
|
||||
separator: site.separator,
|
||||
// fallback opisu: strona bez meta.description dostaje Site Settings → siteDescription (seo.md)
|
||||
siteDescription: site.siteDescription,
|
||||
siteName: site.siteName,
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import { buildCsp } from '../src/modules/security/buildCsp.js'
|
||||
import { buildSecurityHeaders } from '../src/modules/security/buildSecurityHeaders.js'
|
||||
import { AI_TRAINING_BOTS, buildRobots } from '../src/modules/seo/buildRobots.js'
|
||||
import { buildSitemapXml } from '../src/modules/seo/buildSitemapXml.js'
|
||||
import { createPageMetadata } from '../src/modules/seo/createPageMetadata.js'
|
||||
import { buildHreflangAlternates } from '../src/modules/seo/hreflang.js'
|
||||
|
||||
const config: I18nConfig = {
|
||||
@@ -259,3 +260,31 @@ describe('site-wide noindex (IPAL_NOINDEX) and Markdown headers', () => {
|
||||
expect(res.headers.get('link')).toBe('<https://acme.pl/pl/o-nas>; rel="canonical"')
|
||||
})
|
||||
})
|
||||
|
||||
describe('createPageMetadata — siteDescription fallback', () => {
|
||||
// Regresja 1.10.0: readSiteMetaConfig czytał siteDescription, ale nie trafiał do buildMetadata —
|
||||
// strona bez meta.description nie miała <meta name="description"> (Lighthouse SEO).
|
||||
const settings = { homepage: null, siteDescription: 'Opis firmy z Site Settings', siteName: 'Acme' }
|
||||
const payload = {} as never
|
||||
|
||||
test('page without its own description gets Site Settings → siteDescription', async () => {
|
||||
const pageMetadata = createPageMetadata({
|
||||
baseUrl: 'https://acme.pl',
|
||||
config,
|
||||
loaders: { getSettings: async () => settings, resolveRoute: async () => null },
|
||||
})
|
||||
const metadata = await pageMetadata({ slug: ['o-nas'], locale: 'pl', payload })
|
||||
expect(metadata.description).toBe('Opis firmy z Site Settings')
|
||||
expect(metadata.openGraph?.description).toBe('Opis firmy z Site Settings')
|
||||
})
|
||||
|
||||
test('no siteDescription → no description (field omitted, not invented)', async () => {
|
||||
const pageMetadata = createPageMetadata({
|
||||
baseUrl: 'https://acme.pl',
|
||||
config,
|
||||
loaders: { getSettings: async () => ({ ...settings, siteDescription: null }), resolveRoute: async () => null },
|
||||
})
|
||||
const metadata = await pageMetadata({ slug: ['o-nas'], locale: 'pl', payload })
|
||||
expect(metadata.description).toBeUndefined()
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user