feat: add 404 Not Found page with custom styling and translations#279
Conversation
d9b4abe to
180f494
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds a custom 404 Not Found page with internationalization support and comprehensive documentation for adding new pages to the Open Elements website.
Changes:
- New custom 404 page component with localized content, styled with Tailwind CSS and optimized images
- Added comprehensive "Adding New Pages" documentation covering page creation, markdown structure, layouts, images, and troubleshooting
- Updated README to reference the new documentation guide
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| src/app/[locale]/not-found.tsx | New 404 page component with custom styling, illustrations, and internationalized text using next-intl |
| ADDING_PAGES.md | Comprehensive 424-line guide documenting how to add new pages with EN/DE versions, markdown frontmatter, layouts, images, and troubleshooting |
| README.md | Added link to the new "Adding New Pages Guide" in the Documentation section |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| </div> | ||
| </div> | ||
| <div className="relative inline"> | ||
| <span>{t('404.notFound')}</span> |
There was a problem hiding this comment.
The translation key '404.notFound' is incorrect. According to the translation files (locales/en.json and locales/de.json), the key is just 'notFound' at the root level, not nested under '404'. This should be changed to t('notFound') to match the actual translation structure.
| <span>{t('404.notFound')}</span> | |
| <span>{t('notFound')}</span> |
| #### Notes on Page Components: | ||
| - Use the `locale` parameter to render different content for EN/DE | ||
| - Use `notFound()` if a locale isn't supported: `if (locale !== 'de') { notFound() }` | ||
| - Import and use shared components from `src/components/` | ||
| - Follow existing pages for styling patterns (Tailwind CSS) |
There was a problem hiding this comment.
The documentation should include guidance on when to use client components with the 'use client' directive, particularly for pages that need the useTranslations hook from next-intl. The template provided shows a server component pattern, but doesn't explain when a client component is needed. This is especially relevant since the 404 page added in this PR uses useTranslations and requires 'use client'. Consider adding a section or note explaining the difference between server and client component patterns for pages, including when to use useTranslations versus hardcoding localized strings.
| width={224} | ||
| height={100} | ||
| /> | ||
| <span className="relative">Ooops - </span> |
There was a problem hiding this comment.
The text "Ooops - " is hardcoded in English and not internationalized. While this might be intentional (as "Oops" is commonly used in German contexts), it's inconsistent with the page's approach of using translations for other text elements. Consider adding this to the translation files (e.g., as 'oops' key) to maintain consistency with the internationalization pattern used throughout the page.
| <span className="relative">Ooops - </span> | |
| <span className="relative">{t('oops')}</span> |
| @@ -0,0 +1,47 @@ | |||
| import Image from 'next/image' | |||
| import Link from 'next/link' | |||
There was a problem hiding this comment.
The component imports Link from 'next/link', but should use the localized Link from '@/i18n/routing' instead. The codebase convention (as seen in Navbar.tsx and Footer.tsx) is to use the localized Link which properly handles locale prefixes. Without this, the home link may not correctly navigate to the German homepage when the user is on the German 404 page.
| import Link from 'next/link' | |
| import Link from '@/i18n/routing' |
| import Image from 'next/image' | ||
| import Link from 'next/link' | ||
| import { useTranslations } from 'next-intl' |
There was a problem hiding this comment.
This component is missing the 'use client' directive at the top of the file. All pages that use the useTranslations hook from next-intl must be client components and include 'use client' at the very first line. Without this directive, the component will fail to render properly because hooks can only be used in client components.
Signed-off-by: Daniel Ntege <danientege785@gmail.com>
…rman Signed-off-by: Daniel Ntege <danientege785@gmail.com>
f41203e to
5496978
Compare
This pull request introduces a new custom 404 "Not Found" page with enhanced visuals and internationalization support, and adds documentation to guide contributors in adding new pages with localization.
User-facing feature:
not-found.tsxpage undersrc/app/[locale]/that displays a custom 404 page with illustrations, localized text, and a prominent link back to the homepage. The page supports both English and German vianext-intland usesnext/imagefor optimized images. (src/app/[locale]/not-found.tsxR1-R47)Documentation:
README.mdto include a link to an "Adding New Pages" guide (ADDING_PAGES.md), which explains how to add new pages with EN/DE versions, image handling, and layout options.