summaryrefslogtreecommitdiff
path: root/src/content/en/pastebin/2021/04
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2025-04-30 06:23:27 -0300
committerEuAndreh <eu@euandre.org>2025-04-30 06:33:36 -0300
commit61ffa8466bbfa4ca8b13b442a3bd63ef9504a6da (patch)
treefc3c799bece509682b712f6e42e2816059c83c7a /src/content/en/pastebin/2021/04
parentMakefile: No need to remove non-generated *.mo files (diff)
downloadeuandre.org-61ffa8466bbfa4ca8b13b442a3bd63ef9504a6da.tar.gz
euandre.org-61ffa8466bbfa4ca8b13b442a3bd63ef9504a6da.tar.xz
src/content/en/: Unpluralize collection names
Diffstat (limited to 'src/content/en/pastebin/2021/04')
-rw-r--r--src/content/en/pastebin/2021/04/03/naive-slugify-js.adoc28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/content/en/pastebin/2021/04/03/naive-slugify-js.adoc b/src/content/en/pastebin/2021/04/03/naive-slugify-js.adoc
new file mode 100644
index 0000000..184ce97
--- /dev/null
+++ b/src/content/en/pastebin/2021/04/03/naive-slugify-js.adoc
@@ -0,0 +1,28 @@
+= JavaScript naive slugify
+:updatedat: 2021-08-15
+
+[source,javascript]
+----
+const s = "Pézão: açaí, saci-pererê.";
+
+const slugify = s =>
+ s
+ .toLowerCase()
+ .replaceAll(":", "")
+ .replaceAll(".", "")
+ .replaceAll(",", "")
+ .replaceAll("-", "")
+ .replaceAll("á", "a")
+ .replaceAll("ã", "a")
+ .replaceAll("à", "a")
+ .replaceAll("é", "e")
+ .replaceAll("ê", "e")
+ .replaceAll("í", "i")
+ .replaceAll("ó", "o")
+ .replaceAll("ô", "o")
+ .replaceAll("ú", "u")
+ .replaceAll("ü", "u")
+ .replaceAll("ç", "c");
+
+console.log(slugify(s));
+----