@learnpack/learnpack 5.0.350 → 5.0.352

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,26 @@
1
+ const SLUG_PATTERN = /^\d+(?:\.\d+)?-/
2
+
3
+ export function titlefy(str: string): string {
4
+ const arr = str.split("-")
5
+ arr.shift()
6
+ const result = arr.join(" ")
7
+ if (!result) {
8
+ return ""
9
+ }
10
+
11
+ return result.charAt(0).toUpperCase() + result.slice(1)
12
+ }
13
+
14
+ export function formatSidebarTitle(value: string): string | null {
15
+ const trimmed = value.trim()
16
+ if (!trimmed) {
17
+ return null
18
+ }
19
+
20
+ if (/^\d+(?:\.\d+)?$/.test(trimmed)) {
21
+ return null
22
+ }
23
+
24
+ const formatted = SLUG_PATTERN.test(trimmed) ? titlefy(trimmed) : trimmed
25
+ return formatted.trim() || null
26
+ }