@molecule/api-slug 1.0.3 → 1.0.4
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.
- package/README.md +24 -1
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
|
3
3
|
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
4
|
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
5
|
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
-
Generated: 2026-
|
|
6
|
+
Generated: 2026-11-19T03:20:25.316Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/api-slug
|
|
@@ -14,6 +14,29 @@ URL slugs for titles and names.
|
|
|
14
14
|
`uniqueSlug` finds one your store does not have yet; `uniqueSlugInTable`
|
|
15
15
|
does that against a table column through the bonded DataStore.
|
|
16
16
|
|
|
17
|
+
**Custom storage and routes can use the same collision policy.**
|
|
18
|
+
Pass the table and the column you already own. Set `fallback`, `maxLength`
|
|
19
|
+
and `maxNumbered` to match your naming policy. On update, pass the current
|
|
20
|
+
row's id as `excludeId` so it can retain its own slug.
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { uniqueSlugInTable } from '@molecule/api-slug'
|
|
24
|
+
|
|
25
|
+
export function noteSlug(title: string, excludeId?: string): Promise<string> {
|
|
26
|
+
return uniqueSlugInTable('notes', 'slug', title, {
|
|
27
|
+
fallback: 'note',
|
|
28
|
+
maxLength: 180,
|
|
29
|
+
maxNumbered: 100,
|
|
30
|
+
excludeId,
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
For a custom lookup, pass `uniqueSlug(title, isTaken, options)` a callback that
|
|
36
|
+
checks a candidate against your store. Both helpers normalize the base before
|
|
37
|
+
checking availability. An externally assigned, case-sensitive identifier needs
|
|
38
|
+
its own availability policy.
|
|
39
|
+
|
|
17
40
|
> **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
|
|
18
41
|
> It is written to be read by coding agents as much as by people, and is generated from this
|
|
19
42
|
> package's source — edit `src/index.ts` JSDoc, not this file.
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,29 @@
|
|
|
5
5
|
* `uniqueSlug` finds one your store does not have yet; `uniqueSlugInTable`
|
|
6
6
|
* does that against a table column through the bonded DataStore.
|
|
7
7
|
*
|
|
8
|
+
* **Custom storage and routes can use the same collision policy.**
|
|
9
|
+
* Pass the table and the column you already own. Set `fallback`, `maxLength`
|
|
10
|
+
* and `maxNumbered` to match your naming policy. On update, pass the current
|
|
11
|
+
* row's id as `excludeId` so it can retain its own slug.
|
|
12
|
+
*
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { uniqueSlugInTable } from '@molecule/api-slug'
|
|
15
|
+
*
|
|
16
|
+
* export function noteSlug(title: string, excludeId?: string): Promise<string> {
|
|
17
|
+
* return uniqueSlugInTable('notes', 'slug', title, {
|
|
18
|
+
* fallback: 'note',
|
|
19
|
+
* maxLength: 180,
|
|
20
|
+
* maxNumbered: 100,
|
|
21
|
+
* excludeId,
|
|
22
|
+
* })
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* For a custom lookup, pass `uniqueSlug(title, isTaken, options)` a callback that
|
|
27
|
+
* checks a candidate against your store. Both helpers normalize the base before
|
|
28
|
+
* checking availability. An externally assigned, case-sensitive identifier needs
|
|
29
|
+
* its own availability policy.
|
|
30
|
+
*
|
|
8
31
|
* @module
|
|
9
32
|
* @example
|
|
10
33
|
* ```typescript
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AAEH,cAAc,oBAAoB,CAAA;AAClC,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,29 @@
|
|
|
5
5
|
* `uniqueSlug` finds one your store does not have yet; `uniqueSlugInTable`
|
|
6
6
|
* does that against a table column through the bonded DataStore.
|
|
7
7
|
*
|
|
8
|
+
* **Custom storage and routes can use the same collision policy.**
|
|
9
|
+
* Pass the table and the column you already own. Set `fallback`, `maxLength`
|
|
10
|
+
* and `maxNumbered` to match your naming policy. On update, pass the current
|
|
11
|
+
* row's id as `excludeId` so it can retain its own slug.
|
|
12
|
+
*
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { uniqueSlugInTable } from '@molecule/api-slug'
|
|
15
|
+
*
|
|
16
|
+
* export function noteSlug(title: string, excludeId?: string): Promise<string> {
|
|
17
|
+
* return uniqueSlugInTable('notes', 'slug', title, {
|
|
18
|
+
* fallback: 'note',
|
|
19
|
+
* maxLength: 180,
|
|
20
|
+
* maxNumbered: 100,
|
|
21
|
+
* excludeId,
|
|
22
|
+
* })
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* For a custom lookup, pass `uniqueSlug(title, isTaken, options)` a callback that
|
|
27
|
+
* checks a candidate against your store. Both helpers normalize the base before
|
|
28
|
+
* checking availability. An externally assigned, case-sensitive identifier needs
|
|
29
|
+
* its own availability policy.
|
|
30
|
+
*
|
|
8
31
|
* @module
|
|
9
32
|
* @example
|
|
10
33
|
* ```typescript
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/api-slug",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "URL slugs from titles and names: accent-folding slugify, and unique slugs checked against your store (a table column or any lookup).",
|
|
5
5
|
"homepage": "https://www.molecule.dev/packages/api-slug",
|
|
6
6
|
"type": "module",
|