From d363306235f2a48f16e488f20f73e2233ddcf281 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Wed, 29 Nov 2023 18:07:20 +0100 Subject: refactor(pages): improve Homepage * move custom homepage components that does not require props to the MDX file (links should not need to be translated here but where they are defined) * move SEO title and meta desc to MDX file * make Page component the wrapper instead of using a React fragment * fix MDX module types --- src/utils/helpers/strings.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/utils/helpers/strings.ts') diff --git a/src/utils/helpers/strings.ts b/src/utils/helpers/strings.ts index 8b0f923..b8af61d 100644 --- a/src/utils/helpers/strings.ts +++ b/src/utils/helpers/strings.ts @@ -45,3 +45,16 @@ export const getDataAttributeFrom = (str: string) => { if (str.startsWith('data-')) return str; return `data-${str}`; }; + +/** + * Remove the given character if present at the end of the given string. + * + * @param {string} str - A string to trim. + * @param {string} char - The character to remove. + * @returns {string} The trimmed string. + */ +export const trimTrailingChars = (str: string, char: string): string => { + const regExp = new RegExp(`${char}+$`); + + return str.replace(regExp, ''); +}; -- cgit v1.2.3