Added styled Xml
This commit is contained in:
+44
-1
@@ -884,4 +884,47 @@ pomija drafty i noindex. Poprawia widoczność w wyszukiwaniach AI (GEO —
|
||||
Generative Engine Optimization) i audytach „Agentic Browsing”.
|
||||
|
||||
Wymaga wypełnionego siteDescription i sensownych meta.description stron
|
||||
(inaczej llms.txt będzie ubogi).
|
||||
(inaczej llms.txt będzie ubogi).
|
||||
|
||||
## Sitemap jako czytelna tabela (XSL stylesheet)
|
||||
|
||||
Domyślny `/sitemap.xml` to surowy XML — Google go czyta, ale człowiek widzi
|
||||
„ścianę tagów". Można ostylować przez XSL (przeglądarka renderuje tabelę),
|
||||
zachowując poprawność dla crawlerów.
|
||||
|
||||
### Ograniczenie Next
|
||||
|
||||
Standardowy `app/sitemap.ts` (Next MetadataRoute) **nie pozwala** wstrzyknąć
|
||||
`<?xml-stylesheet?>`. Żeby mieć styl, serwuj sitemap własnym route przez
|
||||
`buildSitemapXml` (string XML z odwołaniem do XSL):
|
||||
|
||||
```ts
|
||||
// app/sitemap.xml/route.ts (zamiast app/sitemap.ts)
|
||||
import { buildSitemapXml } from '@intecion/ipal-kit'
|
||||
import { sitemap } from '@/lib/content'
|
||||
|
||||
export const dynamic = 'force-dynamic'
|
||||
|
||||
export async function GET() {
|
||||
const entries = await sitemap()
|
||||
const xml = buildSitemapXml(entries, { stylesheetUrl: '/sitemap.xsl' })
|
||||
return new Response(xml, {
|
||||
headers: { 'Content-Type': 'application/xml; charset=utf-8' },
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
### Plik XSL w /public
|
||||
|
||||
Skopiuj `sitemap.xsl` (z pluginu: `node_modules/@intecion/ipal-kit/dist/modules/seo/assets/sitemap.xsl`)
|
||||
do `public/sitemap.xsl` w projekcie. Zawiera responsywną tabelę (numer, URL,
|
||||
data, języki) z dark mode. `stylesheetUrl: '/sitemap.xsl'` wskazuje na niego.
|
||||
|
||||
### WAŻNE — jeden sitemap, nie dwa
|
||||
|
||||
Jeśli używasz route `app/sitemap.xml/route.ts` (styled), **USUŃ** `app/sitemap.ts`
|
||||
(MetadataRoute). Dwa sitemapy pod różnymi ścieżkami mylą crawlery. Wybierz jeden:
|
||||
- **styled** (`sitemap.xml/route.ts` + buildSitemapXml + XSL) — ładna tabela
|
||||
- **prosty** (`sitemap.ts` + reeksport z lib/content) — bez stylu, mniej kodu
|
||||
|
||||
Styl to kosmetyka (Google czyta oba tak samo) — rób, jeśli klient/audyt tego chce.
|
||||
Reference in New Issue
Block a user