Skip to content

Commit

Permalink
feat: make collection prefix public and allow configuring name property
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Apr 3, 2024
1 parent 218573f commit affb8a9
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions src/collection/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@ export class Collection {
*/
#db?: Db

/**
* The prefix to apply to all permalinks inside this collection.
*/
#urlPrefix?: string

/**
* A custom renderer to use when rendering the content file. If not
* defined, we will do a standard markdown to HTML conversion
Expand All @@ -67,6 +62,17 @@ export class Collection {
} = {
rendering: new Set(),
}

/**
* The display name for the collection
*/
declare name: string

/**
* The prefix to apply to all permalinks inside this collection.
*/
prefix?: string

/**
* Removes the sourrounded slashes from a uri
*/
Expand All @@ -78,7 +84,7 @@ export class Collection {
* Removes the sourrounded slashes from the permalink
*/
#applyPrefix(permalink: string) {
return this.#urlPrefix ? `${this.#normalizeUri(this.#urlPrefix)}${permalink}` : permalink
return this.prefix ? `${this.#normalizeUri(this.prefix)}${permalink}` : permalink
}

/**
Expand Down Expand Up @@ -156,7 +162,7 @@ export class Collection {
* get the given URL prefix.
*/
urlPrefix(urlPrefix: string): this {
this.#urlPrefix = urlPrefix
this.prefix = urlPrefix
return this
}

Expand Down Expand Up @@ -186,6 +192,14 @@ export class Collection {
return this
}

/**
* Set the collection name
*/
setName(name: string) {
this.name = name
return this
}

/**
* Returns an array of collection entries
*/
Expand Down

0 comments on commit affb8a9

Please sign in to comment.