Better temrms explainantion

This commit is contained in:
garronej 2023-05-02 02:52:24 +02:00
parent 18507a2e61
commit e7fc558031

View File

@ -26,21 +26,25 @@ export default function Terms(props: PageProps<Extract<KcContext, { pageId: "ter
kcContext, kcContext,
"downloadTermMarkdown": async ({currentLanguageTag}) => { "downloadTermMarkdown": async ({currentLanguageTag}) => {
const resource = (() => { const tos_url = (() => {
switch (currentLanguageTag) { switch (currentLanguageTag) {
case "fr": case "fr": return tos_fr_url;
return tos_fr_url; default: return tos_en_url;
default:
return tos_en_url;
} }
})(); })();
// webpack5 (used via storybook) loads markdown as string, not url
if (resource.includes("\n")) return resource
const response = await fetch(resource); if ("__STORYBOOK_ADDONS" in window) {
return response.text(); // NOTE: In storybook, when you import a .md file you get the content of the file.
}, // In Create React App on the other hand you get an url to the file.
return tos_url;
}
const tosRawMarkdown = fetch(tos_url).then(response => response.text());
return tosRawMarkdown;
}
}); });
useRerenderOnStateChange(evtTermMarkdown); useRerenderOnStateChange(evtTermMarkdown);