diff --git a/astro.config.mjs b/astro.config.mjs index 998c209..5f6799b 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -1,11 +1,15 @@ import { defineConfig } from "astro/config"; - +import node from "@astrojs/node"; import react from "@astrojs/react"; // https://astro.build/config export default defineConfig({ - integrations: [react()], - redirects: { - "/legal": "/legal/privacy", - }, + integrations: [react()], + redirects: { + "/legal": "/legal/privacy", + }, + output: "server", + adapter: node({ + mode: "standalone", + }), }); diff --git a/package.json b/package.json index 055b94f..58742c0 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "lint": "eslint . --ext .js,.ts,.astro" }, "dependencies": { + "@astrojs/node": "^7.0.0", "@astrojs/react": "^3.0.6", "@directus/sdk": "^13.0.2", "@types/react": "^18.2.42", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2041691..aa109d6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,6 +1,9 @@ lockfileVersion: '6.0' dependencies: + '@astrojs/node': + specifier: ^7.0.0 + version: 7.0.0(astro@4.0.3) '@astrojs/react': specifier: ^3.0.6 version: 3.0.6(@types/react-dom@18.2.17)(@types/react@18.2.42)(react-dom@18.2.0)(react@18.2.0)(vite@4.4.9) @@ -107,6 +110,18 @@ packages: - supports-color dev: false + /@astrojs/node@7.0.0(astro@4.0.3): + resolution: {integrity: sha512-G2NXEbinFqysOCa3mL8PqsyU4yot3I1lmF1WNPJaLGyW0LvG6pbz4iTa4Pk07O2oU+lE9J6JMC5GeNjaWQ0UFA==} + peerDependencies: + astro: ^4.0.0-beta.0 + dependencies: + astro: 4.0.3(sass@1.69.5)(typescript@5.1.3) + send: 0.18.0 + server-destroy: 1.0.1 + transitivePeerDependencies: + - supports-color + dev: false + /@astrojs/prism@3.0.0: resolution: {integrity: sha512-g61lZupWq1bYbcBnYZqdjndShr/J3l/oFobBKPA3+qMat146zce3nz2kdO4giGbhYDt4gYdhmoBz0vZJ4sIurQ==} engines: {node: '>=18.14.1'} @@ -3836,7 +3851,7 @@ packages: normalize-path: 3.0.0 readdirp: 3.6.0 optionalDependencies: - fsevents: 2.3.2 + fsevents: 2.3.3 /chownr@1.1.4: resolution: {integrity: sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==} @@ -4999,19 +5014,11 @@ packages: /fs.realpath@1.0.0: resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==} - /fsevents@2.3.2: - resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==} - engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} - os: [darwin] - requiresBuild: true - optional: true - /fsevents@2.3.3: resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} os: [darwin] requiresBuild: true - dev: false optional: true /function-bind@1.1.1: diff --git a/src/pages/[lang]/index.astro b/src/pages/[lang]/index.astro index 54e13be..b95c7d3 100644 --- a/src/pages/[lang]/index.astro +++ b/src/pages/[lang]/index.astro @@ -11,11 +11,10 @@ import Feedback from "../../views/Feedback/Feedback.astro"; import AboutUs from "../../views/AboutUs/AboutUs.astro"; export const getStaticPaths = (() => { - return [ - {params: {lang: "en"}}, - {params: {lang: "de"}}, - ]; + return [{ params: { lang: "en" } }, { params: { lang: "de" } }]; }) satisfies GetStaticPaths; + +export const prerender = true; --- diff --git a/src/pages/index.astro b/src/pages/index.astro index 5541eb1..4a37455 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -1,4 +1,15 @@ --- +const AVAILABLE_TRANSLATIONS = ["de", "en"]; + +const language = Astro.request.headers.get("accept-language"); +// Split the language string into an array of languages +const languages = language + ?.split(",") + .map((lang) => lang.split(";")[0].trim().split("-")[0]); + +// Find the first language in the header that matches one of the available languages +const pageLang = + languages?.find((lang) => AVAILABLE_TRANSLATIONS.includes(lang)) || "en"; --- - +