Skip to content

Commit

Permalink
feat(@tinacms/media): The media in the store can be listed
Browse files Browse the repository at this point in the history
closes #1451
  • Loading branch information
ncphillips committed Sep 10, 2020
1 parent d2a2d81 commit 8704c29
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions packages/@tinacms/media/src/media.ts
Expand Up @@ -63,6 +63,31 @@ export interface MediaStore {
* This is helpful in cases where the file may not be available in production yet.
*/
previewSrc(src: string): Promise<string>

/**
* Lists all media in a specific directory.
*/
list(options?: ListOptions): Promise<MediaList>
}

/**
* The options available when listing media.
*/
export interface ListOptions {
directory?: string
limit?: number
offset?: number
}

/**
* The response returned from listing media.
*/
export interface MediaList {
items: Media[]
limit?: number
offset?: number
nextOffset?: number
totalCount: number
}

/**
Expand Down Expand Up @@ -93,4 +118,8 @@ export class MediaManager implements MediaStore {
previewSrc(src: string): Promise<string> {
return this.store.previewSrc(src)
}

list(options: ListOptions): Promise<MediaList> {
return this.store.list(options)
}
}

0 comments on commit 8704c29

Please sign in to comment.