Compare commits
2
Commits
facc5db641
...
8dd8208d18
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8dd8208d18 | ||
|
|
2fd5c9bc8b |
@@ -54,6 +54,12 @@ A projekt egy **Next.js 15 alapú marketing weboldal** a mozdIT Bt. számára, A
|
||||
- Animációk: `globals.css`-ben definiált utility osztályok (`.card`, `.btn`, `.icon-container`)
|
||||
- Reszponzivitás: mobile-first, breakpoint-ok: 360px, 640px, 768px, 1024px, 1280px+
|
||||
|
||||
## SEO (MITHOME-116)
|
||||
|
||||
- Minden publikus oldal `generateMetadata`-ja `alternates: pageAlternates(locale, pageKey)`-t ad: saját canonical + hreflang `hu`/`en`/`x-default` (a magyar oldal). Új oldal felvételekor a `PAGE_SLUGS`-ba kell tenni, így a sitemapbe és a hreflang-párokba is automatikusan bekerül (`proto/src/lib/seo.ts`).
|
||||
- `/sitemap.xml` és `/robots.txt` a `proto/src/app/sitemap.ts` és `robots.ts` fájlból jön. Felhasználói döntés: minden oldal mindkét nyelve szerepel, az angol jóváhagyási állapottól (MITHOME-113) függetlenül.
|
||||
- A staging (`NEXT_PUBLIC_DEPLOY_ENV=staging`) sosem indexelhető: a `robots.txt` mindent tilt, a sitemap üres, és minden oldal `noindex` metát kap. A `NEXT_PUBLIC_*` értékek build időben égnek be, ezért a site URL-nek és a deploy-környezetnek build-argumentumként is meg kell lennie (Dockerfile).
|
||||
|
||||
## Content Management
|
||||
|
||||
```typescript
|
||||
|
||||
@@ -142,7 +142,7 @@ Cél: a weboldal magyar (alapértelmezett, prefix nélkül, pl. `/rolunk`) és a
|
||||
| MITHOME-113 | AI-draft angol tartalom + migrációs script bővítése (en locale seed) | ✅ |
|
||||
| MITHOME-114 | Next.js /hu/ + /en/ szimmetrikus prefix routing (egy menetben MITHOME-91-gyel) | ✅ |
|
||||
| MITHOME-115 | Nyelvválasztó UI komponens (Header) | ✅ |
|
||||
| MITHOME-116 | SEO: hreflang tagek és kétnyelvű sitemap | 📋 |
|
||||
| MITHOME-116 | SEO: hreflang tagek és kétnyelvű sitemap | ✅ |
|
||||
|
||||
### EPIC: Hermes Agent — kapcsolatfelvételi triázs pilot (MITHOME-99) — **LEZÁRVA, duplikátum**
|
||||
|
||||
@@ -212,6 +212,7 @@ docker-compose -f docker-compose.dev.yml down
|
||||
---
|
||||
|
||||
## Frissítési Napló
|
||||
- **2026-09-29**: MITHOME-116 (hreflang + sitemap) kész (main, staging deploy még nem történt). A sitemap.xml és a robots.txt eddig nem létezett; most mindkettő generált (`src/app/sitemap.ts`, `robots.ts`, közös logika: `src/lib/seo.ts`). Minden oldal saját canonicalt és `hu`/`en`/`x-default` hreflangot kap. Felhasználói döntések: minden oldal mindkét nyelve szerepel, az angol jóváhagyástól függetlenül; a staging nem indexelhető (a robots.txt mindent tilt, a sitemap üres, `noindex` meta). A főoldal `og:url` értéke nyelvhelyes lett. Új staging smoke: SMOKE-09.
|
||||
- **2026-09-29**: MITHOME-115 kiadva stagingre (`af45b23`). Mentés deploy előtt: `~/backups/mozdit-staging-20260929-122308-pre-mithome-115.archive`. 9/9 staging smoke zöld (SMOKE-08 is); a váltó a `/hu/szolgaltatasok` oldalról az `/en/services` oldalra visz.
|
||||
- **2026-09-29**: MITHOME-115 (nyelvválasztó) kész (main, staging deploy még nem történt). „HU | EN” szöveges kapcsoló a fejlécben (asztalon a témaváltó, mobilon a menügomb mellett), megőrzi az aktuális oldalt a fordított sluggal. Felhasználói döntés: az EN mindig látszik, jóváhagyás előtt az angol oldal a MITHOME-113 kapu miatt magyar tartalmat mutat. `lang`/`hrefLang`/`aria-current`, nyelvenkénti csoportcímke; új staging smoke: SMOKE-08. A `jest-axe` nincs telepítve (új függőség lenne), az a11y-attribútumokat explicit tesztek fedik.
|
||||
- **2026-09-29**: MITHOME-126 (bug: `write after end` a build alatt) kész. Gyökérok: a `logger.ts` SIGTERM/SIGINT kezelője minden modul-kiértékeléskor újra regisztrálódott, és ha egy build worker mindkét jelet megkapta, a második hívás a már lezárt (`logger.end()`) Winston streamre logolt. A `logger.writableEnded` guardként nem működik, mert a winston Logger `readable-stream@3` Transform, amiben ez a property nincs. Javítás: saját `hasShutdownStarted` flag, a kezelők processzenként egyszer, `process.once`-szal regisztrálódnak. Felfedező + megőrző tesztek a `logger.test.ts`-ben (fix-bug workflow); `npm test`, lint, `tsc --noEmit` zöld, 3 egymás utáni buildben nincs `write after end`.
|
||||
|
||||
@@ -85,6 +85,21 @@ test('SMOKE-08: language switcher opens the same page in the other language', as
|
||||
await expect(page.getByRole('group', { name: 'Choose language' }).first().getByRole('link', { name: 'Magyar' })).toHaveAttribute('href', '/hu/szolgaltatasok')
|
||||
})
|
||||
|
||||
// MITHOME-116: pages announce both languages (hreflang), and staging is
|
||||
// never indexed (disallow-all robots.txt, empty sitemap, noindex meta).
|
||||
test('SMOKE-09: hreflang alternates and staging noindex', async ({ page, request }) => {
|
||||
await page.goto('/hu/szolgaltatasok')
|
||||
const origin = new URL(page.url()).origin
|
||||
await expect(page.locator('link[rel="alternate"][hreflang="en"]')).toHaveAttribute('href', `${origin}/en/services`)
|
||||
await expect(page.locator('link[rel="alternate"][hreflang="x-default"]')).toHaveAttribute('href', `${origin}/hu/szolgaltatasok`)
|
||||
await expect(page.locator('link[rel="canonical"]')).toHaveAttribute('href', `${origin}/hu/szolgaltatasok`)
|
||||
await expect(page.locator('meta[name="robots"]')).toHaveAttribute('content', /noindex/)
|
||||
|
||||
const robots = await (await request.get('/robots.txt')).text()
|
||||
expect(robots).toMatch(/Disallow: \/\s*$/m)
|
||||
expect(robots).not.toContain('Sitemap:')
|
||||
})
|
||||
|
||||
test('SMOKE-05: empty contact form is blocked client-side without API submission', async ({ page }) => {
|
||||
let contactPostCount = 0
|
||||
page.on('request', request => {
|
||||
|
||||
@@ -4,7 +4,8 @@ import AboutView from '@/components/views/AboutView'
|
||||
import ServicesView from '@/components/views/ServicesView'
|
||||
import ContactView from '@/components/views/ContactView'
|
||||
import LegalPageView from '@/components/views/LegalPageView'
|
||||
import { resolvePageKey, isLocale, type Locale } from '@/lib/i18n'
|
||||
import { resolvePageKey, isLocale, localePath, type Locale } from '@/lib/i18n'
|
||||
import { absoluteUrl, pageAlternates } from '@/lib/seo'
|
||||
import {
|
||||
getAboutContent,
|
||||
getServicesContent,
|
||||
@@ -45,9 +46,11 @@ export async function generateMetadata({ params }: { params: Promise<Params> }):
|
||||
openGraph: {
|
||||
title: `${title} | ${siteConfig.general.name}`,
|
||||
description: ogDescription,
|
||||
url: `${siteConfig.general.url}${'/' + locale}/${slug}`,
|
||||
url: absoluteUrl(localePath(locale, key)),
|
||||
locale: getOgLocale(locale),
|
||||
},
|
||||
// MITHOME-116: self canonical + hreflang pairs (hu, en, x-default).
|
||||
alternates: pageAlternates(locale, key),
|
||||
})
|
||||
|
||||
if (key === 'about') {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { Metadata } from 'next'
|
||||
import HomeView from '@/components/views/HomeView'
|
||||
import { isLocale, type Locale } from '@/lib/i18n'
|
||||
import { isLocale, localePath, type Locale } from '@/lib/i18n'
|
||||
import { absoluteUrl, pageAlternates } from '@/lib/seo'
|
||||
import { getHomeContent, getPartners } from '@/lib/payload-content'
|
||||
import { siteConfig, getSiteDescription, getOgLocale } from '@/config/site'
|
||||
import { notFound } from 'next/navigation'
|
||||
@@ -21,12 +22,14 @@ export async function generateMetadata({ params }: { params: Promise<Params> }):
|
||||
openGraph: {
|
||||
title: siteConfig.general.name,
|
||||
description,
|
||||
url: siteConfig.general.url,
|
||||
url: absoluteUrl(localePath(locale)),
|
||||
siteName: siteConfig.general.name,
|
||||
images: [{ url: siteConfig.general.ogImage, width: 1200, height: 630, alt: siteConfig.general.name }],
|
||||
locale: getOgLocale(locale),
|
||||
type: 'website',
|
||||
},
|
||||
// MITHOME-116: self canonical + hreflang pairs (hu, en, x-default).
|
||||
alternates: pageAlternates(locale, undefined),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import "./globals.css";
|
||||
|
||||
import { ThemeProvider } from "../../components/ThemeProvider";
|
||||
import { siteConfig, getSiteDescription } from "../../config/site";
|
||||
import { isIndexingDisabled } from "../../lib/seo";
|
||||
|
||||
const geistSans = Geist({
|
||||
variable: "--font-geist-sans",
|
||||
@@ -27,6 +28,9 @@ export const metadata: Metadata = {
|
||||
title: siteConfig.general.name,
|
||||
description: getSiteDescription("hu"),
|
||||
authors: [{ name: siteConfig.general.name }],
|
||||
// MITHOME-116 (user decision): staging must never be indexed — noindex on
|
||||
// every page, on top of the disallow-all robots.txt.
|
||||
...(isIndexingDisabled() ? { robots: { index: false, follow: false } } : {}),
|
||||
};
|
||||
|
||||
// Keep Safari's browser chrome neutral; only the in-page staging strip is amber.
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
import type { MetadataRoute } from 'next'
|
||||
import { robotsRules } from '@/lib/seo'
|
||||
|
||||
// MITHOME-116: /robots.txt — production allows crawling (except admin/API)
|
||||
// and points to the sitemap; staging disallows everything.
|
||||
export default function robots(): MetadataRoute.Robots {
|
||||
return robotsRules()
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import type { MetadataRoute } from 'next'
|
||||
import { isIndexingDisabled, sitemapEntries } from '@/lib/seo'
|
||||
|
||||
// MITHOME-116: /sitemap.xml — every page in hu + en with hreflang alternates.
|
||||
// Staging publishes no sitemap (DECISION: staging is never indexed).
|
||||
export default function sitemap(): MetadataRoute.Sitemap {
|
||||
return isIndexingDisabled() ? [] : sitemapEntries()
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
import { absoluteUrl, isIndexingDisabled, pageAlternates, robotsRules, sitemapEntries } from './seo'
|
||||
|
||||
const SITE = 'https://mozdit.hu/'
|
||||
|
||||
describe('SEO helpers (MITHOME-116)', () => {
|
||||
it('should build absolute URLs without double slashes', () => {
|
||||
expect(absoluteUrl('/hu/rolunk', SITE)).toBe('https://mozdit.hu/hu/rolunk')
|
||||
})
|
||||
|
||||
it('should give each page a self canonical and hreflang pairs with x-default', () => {
|
||||
expect(pageAlternates('en', 'services', SITE)).toEqual({
|
||||
canonical: 'https://mozdit.hu/en/services',
|
||||
languages: {
|
||||
hu: 'https://mozdit.hu/hu/szolgaltatasok',
|
||||
en: 'https://mozdit.hu/en/services',
|
||||
'x-default': 'https://mozdit.hu/hu/szolgaltatasok',
|
||||
},
|
||||
})
|
||||
expect(pageAlternates('hu', undefined, SITE).languages).toEqual({
|
||||
hu: 'https://mozdit.hu/hu',
|
||||
en: 'https://mozdit.hu/en',
|
||||
'x-default': 'https://mozdit.hu/hu',
|
||||
})
|
||||
})
|
||||
|
||||
it('should list every page in both languages in the sitemap', () => {
|
||||
const entries = sitemapEntries(SITE)
|
||||
expect(entries).toHaveLength(12)
|
||||
expect(entries.map((e) => e.url)).toEqual(
|
||||
expect.arrayContaining(['https://mozdit.hu/hu', 'https://mozdit.hu/en', 'https://mozdit.hu/en/privacy-policy', 'https://mozdit.hu/hu/felhasznalasi-feltetelek']),
|
||||
)
|
||||
const privacy = entries.find((e) => e.url.endsWith('/en/privacy-policy'))!
|
||||
expect(privacy.alternates?.languages).toMatchObject({ hu: 'https://mozdit.hu/hu/adatvedelem' })
|
||||
})
|
||||
|
||||
it('should block all crawling on staging and publish the sitemap elsewhere', () => {
|
||||
expect(isIndexingDisabled('staging')).toBe(true)
|
||||
expect(isIndexingDisabled(undefined)).toBe(false)
|
||||
expect(robotsRules('staging', SITE)).toEqual({ rules: { userAgent: '*', disallow: '/' } })
|
||||
expect(robotsRules(undefined, SITE)).toEqual({
|
||||
rules: { userAgent: '*', allow: '/', disallow: ['/admin', '/api/'] },
|
||||
sitemap: 'https://mozdit.hu/sitemap.xml',
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* MITHOME-116: hreflang alternates, sitemap entries and the staging
|
||||
* indexing switch — one place so the page metadata, sitemap.xml and
|
||||
* robots.txt can never disagree.
|
||||
*
|
||||
* DECISION (user): every page is announced in BOTH languages, regardless of
|
||||
* the MITHOME-113 English approval status.
|
||||
* DECISION (user): staging is never indexed (robots.txt disallows all, no
|
||||
* sitemap, every page carries noindex).
|
||||
*/
|
||||
import type { MetadataRoute } from 'next'
|
||||
import { siteConfig } from '@/config/site'
|
||||
import { DEFAULT_LOCALE, LOCALES, PAGE_SLUGS, localePath, type Locale, type PageKey } from './i18n'
|
||||
|
||||
type SitePage = PageKey | undefined // undefined = home
|
||||
|
||||
const PAGES: readonly SitePage[] = [undefined, ...(Object.keys(PAGE_SLUGS) as PageKey[])]
|
||||
|
||||
function siteOrigin(siteUrl: string = siteConfig.general.url): string {
|
||||
return siteUrl.replace(/\/+$/, '')
|
||||
}
|
||||
|
||||
export function absoluteUrl(path: string, siteUrl?: string): string {
|
||||
return `${siteOrigin(siteUrl)}${path}`
|
||||
}
|
||||
|
||||
/** hreflang map for one page: every locale + x-default (the Hungarian page). */
|
||||
export function languageAlternates(page: SitePage, siteUrl?: string): Record<string, string> {
|
||||
const languages: Record<string, string> = Object.fromEntries(
|
||||
LOCALES.map((locale) => [locale, absoluteUrl(localePath(locale, page), siteUrl)]),
|
||||
)
|
||||
return { ...languages, 'x-default': languages[DEFAULT_LOCALE] }
|
||||
}
|
||||
|
||||
/** `alternates` for Next.js page metadata: self canonical + hreflang links. */
|
||||
export function pageAlternates(locale: Locale, page: SitePage, siteUrl?: string) {
|
||||
return {
|
||||
canonical: absoluteUrl(localePath(locale, page), siteUrl),
|
||||
languages: languageAlternates(page, siteUrl),
|
||||
}
|
||||
}
|
||||
|
||||
export function isIndexingDisabled(deployEnv: string | undefined = process.env.NEXT_PUBLIC_DEPLOY_ENV): boolean {
|
||||
return deployEnv === 'staging'
|
||||
}
|
||||
|
||||
export function sitemapEntries(siteUrl?: string): MetadataRoute.Sitemap {
|
||||
return PAGES.flatMap((page) =>
|
||||
LOCALES.map((locale) => ({
|
||||
url: absoluteUrl(localePath(locale, page), siteUrl),
|
||||
changeFrequency: 'monthly' as const,
|
||||
priority: page === undefined ? 1 : page === 'privacy' || page === 'terms' ? 0.3 : 0.8,
|
||||
alternates: { languages: languageAlternates(page, siteUrl) },
|
||||
})),
|
||||
)
|
||||
}
|
||||
|
||||
export function robotsRules(deployEnv?: string, siteUrl?: string): MetadataRoute.Robots {
|
||||
if (isIndexingDisabled(deployEnv)) {
|
||||
return { rules: { userAgent: '*', disallow: '/' } }
|
||||
}
|
||||
return {
|
||||
rules: { userAgent: '*', allow: '/', disallow: ['/admin', '/api/'] },
|
||||
sitemap: absoluteUrl('/sitemap.xml', siteUrl),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user