This directory contains all the page templates and routes for the CodeJoi website. The pages are built using Astro’s file-based routing system, where each .astro
file corresponds to a route on the site.
The site uses a combination of static and dynamic routes:
/404
or /join-our-team
/[lang]/
which capture the language codeThe site supports both English (en) and German (de) languages through the [lang]
parameter in routes. The root page (index.astro
) detects the user’s preferred language and redirects to the appropriate language version.
Most pages follow this general structure:
---
// Imports and frontmatter
import Layout from '../../components/Layout.astro';
import { content } from '../../contents/page-name';
import { getCurrentLang, getStaticLangPaths } from '../../utils/lang';
// Generate static paths for all supported languages
export const getStaticPaths = getStaticLangPaths;
// Get current language and content
const lang = getCurrentLang(Astro);
const { title, sections } = content[lang];
---
<Layout title={title}>
<!-- Page content -->
<Section1 />
<Section2 />
<!-- ... -->
</Layout>
<style lang="scss">
/* Page-specific styles */
</style>
The root index page detects the user’s preferred language from their browser settings and redirects them to the appropriate language version of the site.
The custom 404 error page is displayed when a user navigates to a URL that doesn’t exist. It provides a friendly error message and maintains the site’s navigation.
Some pages (like join-our-team.astro
) serve as redirects to their language-specific versions, following the same pattern as the root index page.
When adding new pages:
[lang]
directorygetStaticLangPaths
function to generate routes for all supported languagesgetCurrentLang(Astro)