content-sdk-pages-router-graphql-data-fetching
/content-sdk-pages-router-graphql-data-fetching
Pobiera strony, słowniki i dane komponentów w aplikacji Content SDK Pages Router, w tym generowanie statyczne ścieżek.
- Autor
- Chris1415 ↗
- Repozytorium
- sitecore-skills-pocs ↗
- Licencja
- Apache-2.0
- Ostatnia zmiana repozytorium
- 05.11.2026
Ocena i bezpieczeństwo
- Pliki w paczce
- 1
- Skrypty
- 0
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 2
Brak sygnałów. Repozytorium zmienione 05.11.2026, bez odwołań do wycofanych modeli i API.
Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.
Co robi i kiedy
Pobiera strony, słowniki i dane komponentów w aplikacji Content SDK Pages Router, w tym generowanie statyczne ścieżek.
Oryginalny opis (EN)
Fetches page, dictionary and component data in a Content SDK Pages Router app: getPage, getDictionary, getComponentData, getPagePaths for SSG. Use when fetching page or dictionary content. Not App Router.
Jak działa
- When to use
- How to perform
- Hard Rules
- Stop Conditions
- References
Podgląd SKILL.md
---
name: content-sdk-pages-router-graphql-data-fetching
description: "Fetches page, dictionary and component data in a Content SDK Pages Router app: getPage, getDictionary, getComponentData, getPagePaths for SSG. Use when fetching page or dictionary content. Not App Router."
license: Apache-2.0
compatibility: "Requires @sitecore-content-sdk/* packages, Next.js 13+, and access to a SitecoreAI Edge endpoint with valid Edge context values (SITECORE_EDGE_CONTEXT_ID etc.)."
metadata:
author: Sitecore
version: "0.4.4"
upstream_repo: Sitecore/content-sdk
upstream_commit: 70eccc43
upstream_name: content-sdk-graphql-data-fetching
upstream_path: packages/create-content-sdk-app/src/templates/nextjs/.agents/skills/content-sdk-graphql-data-fetching/SKILL.md
---
# Content SDK GraphQL Data Fetching (Pages Router)
All Sitecore data fetching goes through the single client in `src/lib/sitecore-client.ts`. Use getPage, getDictionary, and **getComponentData** in the catch-all page. Path from **extractPath(context)**; locale from **context.locale**.
## When to use
- User asks how to fetch page data, layout, or dictionary phrases.
- Task involves getPage, getDictionary, getComponentData, getPreview, getDesignLibraryData, or getPagePaths.
- User mentions "sitecore client," "Layout Service," "page data," or "dictionary."
## How to perform
- Use the client from `src/lib/sitecore-client.ts` only. In [[...path]].tsx: use `extractPath(context)` and `context.locale`; call getPage(path, { locale: context.locale }), then getDictionary and getComponentData(page.layout, context, components). For SSG use getPagePaths in getStaticPaths. For preview use context.preview and getPreview/getDesignLibraryData(context.previewData).
## Hard Rules
- Use the single SitecoreClient instance in `src/lib/sitecore-client.ts`. Do not create a second client or instantiate SitecoreClient elsewhere.
- **Path and locale:** Use `extractPath(context)` (from `@sitecore-content-sdk/nextjs/utils`) to get the path array; use `context.locale` for locale. Do not assume path or locale from elsewhere.
- **Catch-all page flow:** In getStaticProps/getServerSideProps: `client.getPage(path, { locale: context.locale })`, then `client.getDictionary({ site: page.siteName, locale: page.locale })` and `client.getComponentData(page.layout, context, components)` for component props. Pass the result to the layout renderer.
- **SSG:** In getStaticPaths, use `client.getPagePaths(siteNames, context?.locales || [])` where site names come from `.sitecore/sites.json` (e.g. `sites.map((s) => s.name)`). Use `revalidate` in getStaticProps for ISR.
- **Preview:** Use `context.preview` and `context.previewData`; when in preview, use `client.getPreview(context.previewData)` or `client.getDesignLibraryData(context.previewData)`.
- Config for the client comes from `sitecore.config.ts`; use environment variables, never hardcode secrets.
## Stop Conditions
- Stop if the task requires moving the client to another folder without clear requirement; suggest keeping a single instance in lib.
- Do not add direct GraphQL or fetch to Layout Service bypassing the client unless the task explicitly requires it.
- Do not fetch in _app; all data flows from [[...path]].tsx.
## References
- [Content SDK skills overview](https://github.com/Chris1415/sitecore-skills-pocs#skills-by-cluster).
- [Official Content SDK docs](https://doc.sitecore.com/sai/en/developers/content-sdk/sitecore-content-sdk-for-sitecoreai.html).
Wersje
W bazie nie ma innych skilli o nazwie content-sdk-pages-router-graphql-data-fetching.
Migawka bazy z 13.11.2026 · wersja paczki ff4aaaf84f70 (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 0 · ranking
Podobne skille
- 90content-sdk-app-router-graphql-data-fetching
Pobiera dane stron, układów i słowników przez klienta Sitecore w App Router, z obsługą podglądu i statycznych parametrów. - 90content-sdk-pages-router-dictionary-and-i18n
Obsługuje słowniki i lokalizację w aplikacji Content SDK Pages Router: języki w konfiguracji, locale i tłumaczenia. - 100content-sdk-app-router-dictionary-and-i18n
Dodaje języki i tłumaczenia w aplikacji Content SDK App Router: lokale routingu, wiadomości next-intl, klucze słownika i atrybuty hreflang. - 100content-sdk-app-router-component-level-navigation
Buduje nawigację przez GraphQL na poziomie komponentu w aplikacji Content SDK: serwer pobiera wyższe poziomy, a klient dociąga głębsze. - 100nextjs-pages-router
Wdraża pobieranie danych w Pages Router przez getServerSideProps, getStaticProps i trasy API w starszych projektach Next.js z katalogiem pages. - 100nextjs-app-router-patterns
Prowadzi przez Next.js 14+ App Router: Server Components, streaming, trasy równoległe, pobieranie danych, SSR i SSG oraz optymalizację.