usePagesPublic
Hook to fetch the list of published pages.
It won't return pages with status "DRAFT".
Arguments
The usePagesPublic
hook accepts an optional configuration object with the following props:
{ type?: string types?: string[] tag?: string language?: string usePagination?: boolean page?: number pageSize?: number sort?: string}
Property | Definition |
---|---|
type | Optional string to return only the pages with the specified page type. |
types | Optional array of strings to return only the pages with one of the specified page types. |
tag | Optional string to return only the pages with the specified tag. |
language | Optional language for the page. If not specified, the default language will be used. |
usePagination | If true, it will consider the page and pageSize parameters and it will return paginated results |
page | The page number, in case of pagination |
pageSize | The page size, in case of pagination |
sort | Sort parameter: currently it accepts only createdAt ,-createdAt ,publishedAt ,-publishedAt |
Return value
The hook returns an object with { data, error, isFetching }
and other properties.
data
contains:
- When
usePagination
isfalse
, an array of type PageFromList - When
usePagination
istrue
, an object of type PagesFromListWithPagination
Usage example
const { data, error, isFetching } = usePages()
const { data, error, isFetching } = usePages({ type: 'products', usePagination: true, pageSize: 20, page: 1,})