Update how terms

This commit is contained in:
Joseph Garrone 2024-06-21 02:31:13 +02:00
parent 5c71c15c6d
commit 3e8981c7eb
4 changed files with 624 additions and 251 deletions

View file

@ -25,6 +25,7 @@ yarn install # Or use an other package manager, just be sure to delete the yarn.
# Building the theme
You need to have Maven installed to build the theme (The `mvn` command must be in the PATH).
- On macOS: `brew install maven`
- On Debian/Ubuntu: `sudo apt-get install maven`
- On Windows: `choco install openjdk` and `choco install maven` (Or download from [here](https://maven.apache.org/download.cgi))
@ -44,4 +45,3 @@ To release a new version **just update the `package.json` version and push**.
To enable the workflow go to your fork of this repository on GitHub then navigate to:
`Settings` > `Actions` > `Workflow permissions`, select `Read and write permissions`.

View file

@ -18,7 +18,7 @@
"license": "MIT",
"keywords": [],
"dependencies": {
"keycloakify": "10.0.0-rc.77",
"keycloakify": "10.0.0-rc.78",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},

View file

@ -17,27 +17,25 @@ export default function KcPage(props: { kcContext: KcContext }) {
useDownloadTerms({
kcContext,
downloadTermsMarkdown: async ({ currentLanguageTag }) => {
let termsLanguageTag = currentLanguageTag;
let termsFileName: string;
for (const languageTag of [currentLanguageTag, "en"]) {
const response = await fetch(
`${import.meta.env.BASE_URL}terms/${languageTag}.md`
);
switch (currentLanguageTag) {
case "fr":
termsFileName = "fr.md";
break;
case "es":
termsFileName = "es.md";
break;
default:
termsFileName = "en.md";
termsLanguageTag = "en";
break;
if (!response.ok) {
continue;
}
const termsMarkdown = await fetch(
`${import.meta.env.BASE_URL}terms/${termsFileName}`
).then(r => r.text());
return {
termsMarkdown: await response.text(),
termsLanguageTag: languageTag
};
}
return { termsMarkdown, termsLanguageTag };
return {
termsMarkdown: "No terms found",
termsLanguageTag: "en"
};
}
});

825
yarn.lock

File diff suppressed because it is too large Load diff