import { PostEntity, PostsArchiveParams, FetchResponse } from '@10up/headless-core'; import { FetchHookOptions } from '@10up/headless-core/react'; /** * The usePost hook. Returns a collection of post entities * * In order to automatically map URL params create a catch-all route named `[[...path]].js`. * You can create the catch-all at any level e.g: `pages/[[...path]].js`, `pages/blog/[[...path]].js`, etc. * * The `pages/blog/[[...path]].js` route for instance would yield a URL like this: `/blog`, `/blog/page/2`, `/blog/category/category-name/page/3`, etc. * * The following URL params are supported: * - Category (/category/category-name) * - Tag (/tag/tag-name) * - Author (/author/author-name) * - Pagination (/page/2) * - Date (/YYYY/MM/DD) * - Custom Taxonomy (/taxonomy/term-name) * * ### Handling multiple WordPress routes in a single next.js route * * The `usePosts` hook is very flexible and can handle multiple WordPress routes in a single next.js route when using the optional-catch-all route (`[[...path]].js`). * Alongisde with the actual data, `usePosts` also returns information about the current route so you can conditionally load different components. * * ```jsx * const params = { postType: 'post' }; * const Posts = () => { * const { data, pageType } = usePosts(params); * * if (pageType.isAuthorArchive) { * return * } * * if (pageType.isCategoryArchive) { * return * } * * if (pageType.isTaxonomyArchive && pageType.taxonomy === 'my-custom-taxonomy' ) { * return * } * * return ( *
*
    * {data.posts.map((post) => ( *
  • * {post.title.rendered} *
  • * ))} *
*
* ); * }; * ``` * * @param params The parameters accepted by the hook * @param options Options for the SWR configuration * * @category Data Fetching Hooks */ export declare function usePosts(params?: Partial

, options?: FetchHookOptions>): import("@10up/headless-core/react").usePostsResponse; /** * @internal */ export declare namespace usePosts { const fetcher: (sourceUrl?: string | undefined, defaultParams?: P | undefined) => import("@10up/headless-core").PostsArchiveFetchStrategy; }