How sultandevts/frontend_ssr_page_router_news_portal works
Purpose and runtime
This is a Next.js TypeScript news-portal frontend using the Pages Router and server-side rendering patterns. It renders a home feed, article pages, category listings, SEO endpoints, and fallback/error pages. Application-wide initialization and document markup are defined in src/pages/_app.tsx, src/pages/_document.tsx, and src/pages/_error.tsx.
Route entry points
The primary public routes are the home page (src/pages/index.tsx), dynamic article route (src/pages/berita/[slug].tsx), and dynamic category route (src/pages/kategori/[slug].tsx). Non-content routes include not-found handling in src/pages/404.tsx plus crawler-facing src/pages/robots.ts and src/pages/sitemap.ts.
Data boundary
src/lib/api.ts is the central API boundary for page data and likely isolates upstream content-service access from route rendering. Dynamic route parameters from article and category pages drive content retrieval; returned data is passed into server-rendered presentation components. Shared domain constants reside in src/lib/constants.ts.
Article rendering pipeline
Article routes compose article metadata/header, body, engagement controls, related content, comments, and inline monetization. The central presentation layer is split across src/components/article/ArticleHeader.tsx, src/components/article/ArticleContent.tsx, and src/components/article/RelatedArticles.tsx. Browser-only interaction is explicitly isolated in src/components/article/LikeButton.client.tsx and src/components/article/ShareButton.client.tsx.
Feed and category browsing
Reusable article-card rendering supports home and category feeds through src/components/article/ArticleCard.tsx. Category pages add category context, client-side filtering, and pagination through src/components/category/CategoryHeader.tsx, src/components/category/FilterBar.client.tsx, and src/components/category/Pagination.tsx. This separates initial route rendering from interactive refinement.
Shared shell, interaction, and SEO
The site shell is provided by src/components/layout/Header.tsx, src/components/layout/NavMenu.tsx, and src/components/layout/Footer.tsx; mobile navigation and search are client components in src/components/layout/MobileNav.client.tsx and src/components/layout/SearchBar.client.tsx. Structured-data output is centralized in src/components/ui/JsonLd.tsx, while global styling is loaded from src/styles/globals.css.
External integrations and client-only boundaries
Advertising is encapsulated behind client-side ad slot components, including src/components/ads/AdSlot.client.tsx, src/components/ads/AdArticleMid.client.tsx, and src/components/ads/AdStickyFooter.client.tsx, keeping third-party browser ad behavior outside server-rendered content components. Comment submission is similarly browser-bound in src/components/comment/CommentForm.client.tsx, with rendering coordinated by src/components/comment/CommentSection.tsx.
Main entry points: api.ts Content API · ArticleContent.tsx Article presentation · Header.tsx Site shell · [slug].tsx Article route
Components 21
Pages Router
Server-rendered route entry points and framework fallbacks.
- App initialization
src/pages/_app.tsx - Document markup
src/pages/_document.tsx - Error fallback
src/pages/_error.tsx - Home feed
src/pages/index.tsx - Article route · Resolves article content from the slug.
src/pages/berita/[slug].tsx - Category route · Resolves category feed data from the slug.
src/pages/kategori/[slug].tsx - Not found
src/pages/404.tsx
Data & SEO
Content-access boundary and crawler metadata endpoints.
- Content API · Isolates upstream content-service access.
src/lib/api.ts - Domain constants
src/lib/constants.ts - Crawler endpoints
- Structured data
src/components/ui/JsonLd.tsx
Shared Presentation
Shell and reusable article rendering.
- Site shell · Header, navigation menu, and footer.
src/components/layout/Header.tsx - Article presentation · Header, body, and related-article composition.
src/components/article/ArticleContent.tsx - Article cards · Reusable cards for home and category feeds.
src/components/article/ArticleCard.tsx - Category presentation · Category heading and pagination.
src/components/category/CategoryHeader.tsx - Global styles
src/styles/globals.css
Client Integrations
Browser-only controls and third-party integrations.
- Article actions · Browser-only like and share controls.
src/components/article/LikeButton.client.tsx - Feed filtering · Client-side category refinement.
src/components/category/FilterBar.client.tsx - Mobile nav & search · Browser-only mobile navigation and search.
src/components/layout/MobileNav.client.tsx - Ad slots · Encapsulates third-party browser advertising.
src/components/ads/AdSlot.client.tsx - Comments · Server-rendered section with browser-only submission.
src/components/comment/CommentSection.tsx
Connections 19
- App initialization → Site shell: wraps
- App initialization → Global styles: loads
- Home feed → Content API: loads feed
- Home feed → Article cards: renders
- Article route → Content API: loads by slug
- Article route → Article presentation: renders
- Article route → Structured data: emits
- Article presentation → Article actions: uses
- Article presentation → Ad slots: embeds
- Article presentation → Comments: includes
- Category route → Content API: loads by slug
- Category route → Category presentation: renders
- Category route → Article cards: renders feed
- Category presentation → Feed filtering: enables
- Site shell → Mobile nav & search: uses
- Crawler endpoints → Content API: derives content metadata
- Content API → Domain constants: uses
- Error fallback → Site shell: uses
- Not found → Site shell: uses