From 20062b27d28f47580dbd5f40e9674da37788db18 Mon Sep 17 00:00:00 2001 From: Jason Varga Date: Wed, 31 Jul 2024 15:45:48 -0400 Subject: [PATCH 1/2] Remove parenthesis --- resources/js/components/slugs/Slug.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/resources/js/components/slugs/Slug.js b/resources/js/components/slugs/Slug.js index c8dd326a1f1..323d2294678 100644 --- a/resources/js/components/slugs/Slug.js +++ b/resources/js/components/slugs/Slug.js @@ -58,6 +58,8 @@ export default class Slug { custom["'"] = ""; // Remove apostrophes in all languages custom["’"] = ""; // Remove smart single quotes custom[" - "] = " "; // Prevent `Block - Hero` turning into `block_-_hero` + custom['('] = ''; // Remove parentheses + custom[')'] = ''; // Remove parentheses return speakingUrl(this.#string, { separator: this.#separator, From 52aec1f434e244c6195311899418cc8aadb846cc Mon Sep 17 00:00:00 2001 From: Jason Varga Date: Wed, 31 Jul 2024 15:47:01 -0400 Subject: [PATCH 2/2] replace currency symbols --- resources/js/components/slugs/Slug.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/resources/js/components/slugs/Slug.js b/resources/js/components/slugs/Slug.js index 323d2294678..3097fdeca4d 100644 --- a/resources/js/components/slugs/Slug.js +++ b/resources/js/components/slugs/Slug.js @@ -54,21 +54,38 @@ export default class Slug { } #createSynchronously() { - const custom = Statamic.$config.get(`charmap.${this.#language}`) ?? {}; + const symbols = Statamic.$config.get('asciiReplaceExtraSymbols'); + const charmap = Statamic.$config.get('charmap'); + let custom = charmap[this.#language] ?? {}; custom["'"] = ""; // Remove apostrophes in all languages custom["’"] = ""; // Remove smart single quotes custom[" - "] = " "; // Prevent `Block - Hero` turning into `block_-_hero` custom['('] = ''; // Remove parentheses custom[')'] = ''; // Remove parentheses + custom = symbols + ? this.#replaceCurrencySymbols(custom, charmap) + : this.#removeCurrencySymbols(custom, charmap); return speakingUrl(this.#string, { separator: this.#separator, lang: this.#language, custom, - symbols: Statamic.$config.get('asciiReplaceExtraSymbols') + symbols }); } + #replaceCurrencySymbols(custom, charmap) { + return { ...custom, ...charmap.currency }; + } + + #removeCurrencySymbols(custom, charmap) { + for (const key in charmap.currency_short) { + custom[key] = ''; + } + + return custom; + } + #createAsynchronously() { if (! this.#string) { this.#controller?.abort();