aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils/helpers/strings.ts
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2023-11-29 18:07:20 +0100
committerArmand Philippot <git@armandphilippot.com>2023-11-29 18:07:20 +0100
commitd363306235f2a48f16e488f20f73e2233ddcf281 (patch)
tree5e86a7b5f38416d7ee56a9aff5ef972aa73d82b1 /src/utils/helpers/strings.ts
parentdfa894b76ee3584bf169710c78c57330c5d6ee67 (diff)
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
Diffstat (limited to 'src/utils/helpers/strings.ts')
-rw-r--r--src/utils/helpers/strings.ts13
1 files changed, 13 insertions, 0 deletions
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, '');
+};