Skip to content

Commit affb8a9

Browse files
committed
feat: make collection prefix public and allow configuring name property
1 parent 218573f commit affb8a9

1 file changed

Lines changed: 21 additions & 7 deletions

File tree

src/collection/main.ts

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,6 @@ export class Collection {
4343
*/
4444
#db?: Db
4545

46-
/**
47-
* The prefix to apply to all permalinks inside this collection.
48-
*/
49-
#urlPrefix?: string
50-
5146
/**
5247
* A custom renderer to use when rendering the content file. If not
5348
* defined, we will do a standard markdown to HTML conversion
@@ -67,6 +62,17 @@ export class Collection {
6762
} = {
6863
rendering: new Set(),
6964
}
65+
66+
/**
67+
* The display name for the collection
68+
*/
69+
declare name: string
70+
71+
/**
72+
* The prefix to apply to all permalinks inside this collection.
73+
*/
74+
prefix?: string
75+
7076
/**
7177
* Removes the sourrounded slashes from a uri
7278
*/
@@ -78,7 +84,7 @@ export class Collection {
7884
* Removes the sourrounded slashes from the permalink
7985
*/
8086
#applyPrefix(permalink: string) {
81-
return this.#urlPrefix ? `${this.#normalizeUri(this.#urlPrefix)}${permalink}` : permalink
87+
return this.prefix ? `${this.#normalizeUri(this.prefix)}${permalink}` : permalink
8288
}
8389

8490
/**
@@ -156,7 +162,7 @@ export class Collection {
156162
* get the given URL prefix.
157163
*/
158164
urlPrefix(urlPrefix: string): this {
159-
this.#urlPrefix = urlPrefix
165+
this.prefix = urlPrefix
160166
return this
161167
}
162168

@@ -186,6 +192,14 @@ export class Collection {
186192
return this
187193
}
188194

195+
/**
196+
* Set the collection name
197+
*/
198+
setName(name: string) {
199+
this.name = name
200+
return this
201+
}
202+
189203
/**
190204
* Returns an array of collection entries
191205
*/

0 commit comments

Comments
 (0)