index page update; rest module
This commit is contained in:
1 parent
5e8ee6eec9
commit
087a4b6172
2 files changed
+36
-31
No files matched your search
+26
@@ -0,0 +1,26 @@
|
||||
import { createApiUrl, requestGet, IResponseItems } from './next-lib'
|
||||
import { IPage } from './types'
|
||||
|
||||
export type QuerySlice = {
|
||||
skip: number
|
||||
limit: number
|
||||
sortBy: string
|
||||
}
|
||||
|
||||
export async function getPagesByTags(tags: string[], { skip, limit, sortBy }: QuerySlice) {
|
||||
const tagQuery = tags
|
||||
.map(x => `tag=${x}`)
|
||||
.join('&')
|
||||
|
||||
const url = `/api/pages/tags?${tagQuery}&skip=${skip}&limit=${limit}&sortBy=${sortBy}`
|
||||
const res = await requestGet<IResponseItems<IPage>>(createApiUrl(url), null)
|
||||
|
||||
return res?.items
|
||||
}
|
||||
|
||||
export async function getPagesCardsByTags(tags: string[]) {
|
||||
const skip = 0
|
||||
const limit = 1000
|
||||
|
||||
return getPagesByTags(tags, { skip, limit, sortBy: '-date' })
|
||||
}
|
||||
Reference in new issue
Block a user