diff --git a/astro-i18n.adapter.ts b/astro-i18n.adapter.ts index 9cf8791..d496c5e 100644 --- a/astro-i18n.adapter.ts +++ b/astro-i18n.adapter.ts @@ -1,6 +1,5 @@ import type { AstroIntegration } from "astro"; -import { mkdir, rename, access, constants } from 'node:fs/promises' -import {rm} from "fs/promises"; +import { mkdir, access, constants, copyFile } from 'node:fs/promises' const locales = ["de"]; @@ -21,14 +20,10 @@ export default function configureI18n(): AstroIntegration { await mkdir(cutPrefix(newPath), {recursive: true}); } - await rename(`${cutPrefix(oldPath)}index.html`, `${cutPrefix(newPath)}index.${locale}.html`) - logger.info(`Renamed ${oldPath} to ${newPath}`) + await copyFile(`${cutPrefix(oldPath)}index.html`, `${cutPrefix(newPath)}index.${locale}.html`) + logger.info(`Copied ${oldPath}index.html to ${newPath}index.${locale}.html`) } } - - for (let locale of locales) { - await rm(`${cutPrefix(dir.pathname)}${locale}`, {recursive: true, force: true}) - } } } } diff --git a/astro.config.mjs b/astro.config.mjs index 07896dc..b0badc4 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -2,14 +2,31 @@ import { defineConfig, sharpImageService } from 'astro/config'; import svelte from "@astrojs/svelte"; import tailwind from "@astrojs/tailwind"; import configureI18n from "./astro-i18n.adapter"; +import sitemap from "@astrojs/sitemap"; + +import robotsTxt from "astro-robots-txt"; // https://astro.build/config export default defineConfig({ output: "static", image: { - service: sharpImageService(), + service: sharpImageService() }, compressHTML: true, - integrations: [svelte(), tailwind(), configureI18n()], + site: "https://steamwar.de", + integrations: [svelte(), tailwind(), configureI18n(), sitemap({ + i18n: { + defaultLocale: "en", + locales: { + en: "en-US", + de: "de-DE" + } + } + }), robotsTxt({ + policy: [{ + userAgent: "*", + disallow: ["/admin", "/login", "/dashboard", "/de", "/_astro"] + }] + })], vite: {} }); \ No newline at end of file diff --git a/package.json b/package.json index 75c3213..0bdbcf6 100644 --- a/package.json +++ b/package.json @@ -30,10 +30,13 @@ "typescript": "^5.3.3" }, "dependencies": { + "@astrojs/sitemap": "^3.0.3", "@codemirror/lang-json": "^6.0.1", "@ddietr/codemirror-themes": "^1.4.2", "astro": "^4.0.3", "astro-i18n": "^2.1.18", + "astro-robots-txt": "^1.0.0", + "astro-seo": "^0.8.0", "chart.js": "^4.4.1", "chartjs-adapter-dayjs-4": "^1.0.4", "chartjs-adapter-moment": "^1.0.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c453752..96f0238 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5,6 +5,9 @@ settings: excludeLinksFromLockfile: false dependencies: + '@astrojs/sitemap': + specifier: ^3.0.3 + version: 3.0.3 '@codemirror/lang-json': specifier: ^6.0.1 version: 6.0.1 @@ -17,6 +20,12 @@ dependencies: astro-i18n: specifier: ^2.1.18 version: 2.1.18(esbuild@0.19.8) + astro-robots-txt: + specifier: ^1.0.0 + version: 1.0.0 + astro-seo: + specifier: ^0.8.0 + version: 0.8.0 chart.js: specifier: ^4.4.1 version: 4.4.1 @@ -155,6 +164,13 @@ packages: dependencies: prismjs: 1.29.0 + /@astrojs/sitemap@3.0.3: + resolution: {integrity: sha512-+GRKp1yho9dpHBcMcU6JpbL41k0yYZghOkNsMRb8QIRflbGHvd787tdv9oIZ5NJj0SqAuOlqp2UpqLkJXuAe2A==} + dependencies: + sitemap: 7.1.1 + zod: 3.22.4 + dev: false + /@astrojs/svelte@5.0.0(astro@4.0.3)(svelte@4.2.8)(typescript@5.3.3)(vite@5.0.7): resolution: {integrity: sha512-v8AZU9hSP4JuESDv5pev8S4eZQXulIoS/gBJbhAEBWfkANptsc7CP/qjWk83KWidNXX8hfVLI4VNlShWo3ADRw==} engines: {node: '>=18.14.1'} @@ -984,11 +1000,21 @@ packages: dependencies: '@types/unist': 2.0.10 + /@types/node@17.0.45: + resolution: {integrity: sha512-w+tIMs3rq2afQdsPJlODhoUEKzFP1ayaoyl1CcnwtIlsVe7K7bA1NGm4s3PraqTLlXnbIN84zuBlxBWo1u9BLw==} + dev: false + /@types/node@20.10.4: resolution: {integrity: sha512-D08YG6rr8X90YB56tSIuBaddy/UXAA9RKJoFvrsnogAum/0pmjkgi4+2nx96A330FmioegBWmEYQ+syqCFaveg==} dependencies: undici-types: 5.26.5 + /@types/sax@1.2.7: + resolution: {integrity: sha512-rO73L89PJxeYM3s3pPPjiPgVVcymqU490g0YO5n5By0k2Erzj6tay/4lr1CHAAU4JyOWd1rpQ8bCf6cZfHU96A==} + dependencies: + '@types/node': 20.10.4 + dev: false + /@types/tern@0.23.9: resolution: {integrity: sha512-ypzHFE/wBzh+BlH6rrBgS5I/Z7RD21pGhZ2rltb/+ZrVM1awdZwjx7hE5XfuYgHWk9uvV5HLZN3SloevCAp3Bw==} dependencies: @@ -1086,6 +1112,17 @@ packages: esbuild: 0.19.8 dev: false + /astro-robots-txt@1.0.0: + resolution: {integrity: sha512-6JQSLid4gMhoWjOm85UHLkgrw0+hHIjnJVIUqxjU2D6feKlVyYukMNYjH44ZDZBK1P8hNxd33PgWlHzCASvedA==} + dependencies: + valid-filename: 4.0.0 + zod: 3.22.4 + dev: false + + /astro-seo@0.8.0: + resolution: {integrity: sha512-7gq6lhibCM8FuzZIJlbLLWP5EJ9KL2/4XqeFrAg9O6ZK2xMFxJ5ubKf+a0VJwwTu8W8Xr421CmpiXu6Hq7n/7Q==} + dev: false + /astro@4.0.3(@types/node@20.10.4)(sass@1.69.5)(typescript@5.3.3): resolution: {integrity: sha512-hrwe7CIVhSKW8/iibDs1hpqzZAtvx6Qu8TFFxjaGbooEWF720M9L+ZZtyTgrcy6K/ZHJ0xwFvZV3/X2Vvbf/LQ==} engines: {node: '>=18.14.1', npm: '>=6.14.0'} @@ -1860,6 +1897,11 @@ packages: dependencies: reusify: 1.0.4 + /filename-reserved-regex@3.0.0: + resolution: {integrity: sha512-hn4cQfU6GOT/7cFHXBqeBg2TbrMBgdD0kcjLhvSQYYwm3s4B6cjvBfb7nBALJLAXqmU5xajSa7X2NnUud/VCdw==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dev: false + /fill-range@7.0.1: resolution: {integrity: sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==} engines: {node: '>=8'} @@ -3694,6 +3736,17 @@ packages: /sisteransi@1.0.5: resolution: {integrity: sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==} + /sitemap@7.1.1: + resolution: {integrity: sha512-mK3aFtjz4VdJN0igpIJrinf3EO8U8mxOPsTBzSsy06UtjZQJ3YY3o3Xa7zSc5nMqcMrRwlChHZ18Kxg0caiPBg==} + engines: {node: '>=12.0.0', npm: '>=5.6.0'} + hasBin: true + dependencies: + '@types/node': 17.0.45 + '@types/sax': 1.2.7 + arg: 5.0.2 + sax: 1.3.0 + dev: false + /source-map-js@1.0.2: resolution: {integrity: sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==} engines: {node: '>=0.10.0'} @@ -4197,6 +4250,13 @@ packages: /util-deprecate@1.0.2: resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} + /valid-filename@4.0.0: + resolution: {integrity: sha512-VEYTpTVPMgO799f2wI7zWf0x2C54bPX6NAfbZ2Z8kZn76p+3rEYCTYVYzMUcVSMvakxMQTriBf24s3+WeXJtEg==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dependencies: + filename-reserved-regex: 3.0.0 + dev: false + /vfile-location@5.0.2: resolution: {integrity: sha512-NXPYyxyBSH7zB5U6+3uDdd6Nybz6o6/od9rk8bp9H8GR3L+cm/fC0uUTbqBmUTnMCUDslAGBOIKNfvvb+gGlDg==} dependencies: diff --git a/src/components/LanguageWarning.astro b/src/components/LanguageWarning.astro new file mode 100644 index 0000000..be1a135 --- /dev/null +++ b/src/components/LanguageWarning.astro @@ -0,0 +1,8 @@ +--- +import {t} from "astro-i18n"; +--- + +
{t("warning.title")}
+{t("warning.text")}
+
+
{Intl.DateTimeFormat(astroI18n.locale, { day: "numeric", month: "long", year: "numeric" - }).format(post.data.created)}
{post.data.description}