diff --git a/docusaurus.config.ts b/docusaurus.config.ts index 6b16864..31134e7 100644 --- a/docusaurus.config.ts +++ b/docusaurus.config.ts @@ -8,11 +8,13 @@ function getLastUpdate() { const date = execSync("git log -1 --pretty=%cd --date=format:%Y-%m-%d") .toString() .trim(); - return new Date(date).toLocaleDateString(undefined, { - year: "numeric", - month: "2-digit", - day: "2-digit", - }); + return new Date(date) + .toLocaleDateString(undefined, { + year: "numeric", + month: "2-digit", + day: "2-digit", + }) + .replace(/\//g, "."); } const config: Config = { @@ -142,7 +144,7 @@ const config: Config = { footer: { style: "dark", copyright: `Version ${version} (last update ${getLastUpdate()})
+ target="_blank" rel="noreferrer">${version} (Letztes Update ${getLastUpdate()})
Copyright © ${new Date().getFullYear()} Felix Schlegel, Moritz Wieland. Built with Docusaurus.`, }, prism: { diff --git a/i18n/en/docusaurus-theme-classic/footer.json b/i18n/en/docusaurus-theme-classic/footer.json index 0cbd87e..4a77443 100644 --- a/i18n/en/docusaurus-theme-classic/footer.json +++ b/i18n/en/docusaurus-theme-classic/footer.json @@ -1,6 +1,6 @@ { "copyright": { - "message": "Version 2.9.0 (last update 01.12.2024)
\n Copyright © 2024 Felix Schlegel, Moritz Wieland. Built with Docusaurus.", + "message": "Version 2.9.0 (Last Update 10.12.2024)
\n Copyright © 2024 Felix Schlegel, Moritz Wieland. Built with Docusaurus.", "description": "The footer copyright" } } diff --git a/package-lock.json b/package-lock.json index 2beed7f..7c3fac2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "bierpongregeln", - "version": "2.9.0", + "version": "2.9.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "bierpongregeln", - "version": "2.9.0", + "version": "2.9.2", "dependencies": { "@docusaurus/preset-classic": "^3.6.3", "@mdx-js/react": "^3.1.0", diff --git a/package.json b/package.json index cddf6f6..d40d9b9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "bierpongregeln", "description": "This is a collection of rulesets for beer pong that is built using Docusaurus 2 and served with GitHub Pages.", - "version": "2.9.0", + "version": "2.9.2", "private": true, "scripts": { "docusaurus": "docusaurus", @@ -11,7 +11,7 @@ "deploy": "docusaurus deploy", "clear": "docusaurus clear", "serve": "docusaurus serve", - "write-translations": "rm -f i18n/en/docusaurus-theme-classic/footer.json && docusaurus write-translations", + "write-translations": "python3 update-footer-en.py", "write-heading-ids": "docusaurus write-heading-ids", "validate-json": "ajv -s tournaments.schema.json -d tournaments.json", "lint": "eslint .", diff --git a/scripts/update-footer-en.py b/scripts/update-footer-en.py new file mode 100644 index 0000000..5eee321 --- /dev/null +++ b/scripts/update-footer-en.py @@ -0,0 +1,56 @@ +import os +import subprocess +import sys + + +# Step 1: Parse the locale from command-line arguments +def get_locale_from_args(): + locale = "en" # Default locale + if "--locale" in sys.argv: + locale_index = sys.argv.index("--locale") + 1 + if locale_index < len(sys.argv): + locale = sys.argv[locale_index] + return locale + + +locale = get_locale_from_args() +print(f"Using locale: {locale}") + +# Define the file path +file_path = f"i18n/{locale}/docusaurus-theme-classic/footer.json" + +# Step 2: Remove the file +if os.path.exists(file_path): + os.remove(file_path) + print(f"Removed file: {file_path}") +else: + print(f"File does not exist: {file_path}") + +# Step 3: Run the 'docusaurus write-translations' command with the locale +try: + subprocess.run(["docusaurus", "write-translations", "--locale", locale], check=True) + print("Executed 'docusaurus write-translations' successfully.") +except subprocess.CalledProcessError as e: + print(f"Error running 'docusaurus write-translations': {e}") + exit(1) + + +# Step 4: Replace the string in the file +def replace_string_in_file(file_path, old_string, new_string): + if not os.path.exists(file_path): + print(f"File not found for replacement: {file_path}") + return + + with open(file_path, "r", encoding="utf-8") as file: + content = file.read() + + content = content.replace(old_string, new_string) + + with open(file_path, "w", encoding="utf-8") as file: + file.write(content) + + print(f"Replaced '{old_string}' with '{new_string}' in {file_path}") + + +# Replace 'Letztes Update' with 'Last Update' +replace_string_in_file(file_path, "Letztes Update", "Last Update") diff --git a/updateversion.py b/scripts/updateversion.py similarity index 100% rename from updateversion.py rename to scripts/updateversion.py