@@ -40,7 +40,7 @@ export default function PostsPage() {
Let's also update the `Post` component to accept a `post` prop:
```tsx title=components/post.tsx {1,4,8}
-import { Post as PostType } from "../client";
+import { Post as PostType } from '../client';
export interface PostProps {
post: PostType;
@@ -63,18 +63,18 @@ A couple of things to note here: The schema generated in the previous tutorial e
Additionally, notice the `title` and `content` properties are functions. This is because you are able to specify if you want the rendered content or raw content. For example:
```tsx
-post.title({format: PostObjectFieldFormatEnum.RAW})
+post.title({ format: PostObjectFieldFormatEnum.RAW });
```
Let's go back to the `pages/posts.tsx` component and hook up the data we're fetching to the `Post` component:
```tsx title=pages/posts.tsx {12}
-import { client } from '../client'
-import Post from "../components/post";
+import { client } from '../client';
+import Post from '../components/post';
export default function PostsPage() {
- const {usePosts} = client
- const posts = usePosts()?.nodes
+ const { usePosts } = client;
+ const posts = usePosts()?.nodes;
return (
@@ -89,19 +89,22 @@ export default function PostsPage() {
Once those changes are made, navigate to [http://localhost:3000/posts](http://localhost:3000/posts) in your browser and you should see your posts.
-
+
### Get Data Using The `useQuery` Hook
-While Faust.js provides [custom hooks](../next/reference/custom-hooks) for fetching data like posts, pages, etc, sometimes you need to fetch data outside of the scope of the custom hooks.
+While Faust.js provides [custom hooks](../next/reference/hooks) for fetching data like posts, pages, etc, sometimes you need to fetch data outside of the scope of the custom hooks.
-That is where the [`useQuery`](../next/reference/custom-hooks#custom-queries-and-mutations) hook comes in. This is a GQty hook that gives access to your entire schema.
+That is where the [`useQuery`](../next/reference/hooks/gqty-hooks) hook comes in. This is a GQty hook that gives access to your entire schema.
Let's display the site title and description using the `useQuery` hook.
```tsx title=pages/posts.tsx {5,10,11}
-import { client } from "../client";
-import Post from "../components/post";
+import { client } from '../client';
+import Post from '../components/post';
export default function PostsPage() {
const { usePosts, useQuery } = client;
diff --git a/internal/website/sidebars.js b/internal/website/sidebars.js
index 4da1ad067..977877944 100644
--- a/internal/website/sidebars.js
+++ b/internal/website/sidebars.js
@@ -85,6 +85,11 @@ module.exports = {
label: 'Authentication',
id: 'next/guides/authentication',
},
+ {
+ type: 'doc',
+ label: 'Logging Queries',
+ id: 'next/guides/logging-queries',
+ },
{
type: 'doc',
label: '404s',
@@ -97,9 +102,55 @@ module.exports = {
label: 'Reference',
items: [
{
- type: 'doc',
- label: 'Custom Hooks',
- id: 'next/reference/custom-hooks',
+ type: 'category',
+ label: 'Hooks',
+ items: [
+ {
+ type: 'doc',
+ label: 'Hooks Intro',
+ id: 'next/reference/hooks/hooks',
+ },
+ {
+ type: 'doc',
+ label: 'usePost Hook',
+ id: 'next/reference/hooks/usePost',
+ },
+ {
+ type: 'doc',
+ label: 'usePosts Hook',
+ id: 'next/reference/hooks/usePosts',
+ },
+ {
+ type: 'doc',
+ label: 'usePage Hook',
+ id: 'next/reference/hooks/usePage',
+ },
+ {
+ type: 'doc',
+ label: 'usePreview Hook',
+ id: 'next/reference/hooks/usePreview',
+ },
+ {
+ type: 'doc',
+ label: 'useAuth Hook',
+ id: 'next/reference/hooks/useAuth',
+ },
+ {
+ type: 'doc',
+ label: 'useLogin Hook',
+ id: 'next/reference/hooks/useLogin',
+ },
+ {
+ type: 'doc',
+ label: 'useLogout Hook',
+ id: 'next/reference/hooks/useLogout',
+ },
+ {
+ type: 'doc',
+ label: 'GQty Hooks',
+ id: 'next/reference/hooks/gqty-hooks',
+ },
+ ],
},
{
type: 'doc',
diff --git a/internal/website/src/components/Features/HomepageFeatures.js b/internal/website/src/components/Features/HomepageFeatures.js
index 5cac15034..9408ba405 100644
--- a/internal/website/src/components/Features/HomepageFeatures.js
+++ b/internal/website/src/components/Features/HomepageFeatures.js
@@ -49,7 +49,7 @@ const FeatureList = [
description: (
<>Fetch posts, categories, pages, and more using standard URL params.>
),
- link: '/docs/next/reference/custom-hooks',
+ link: '/docs/next/reference/hooks',
},
{
title: 'Custom Post Types',
diff --git a/packages/next/CHANGELOG.md b/packages/next/CHANGELOG.md
index 47a074ad8..c6cc8b280 100644
--- a/packages/next/CHANGELOG.md
+++ b/packages/next/CHANGELOG.md
@@ -21,7 +21,7 @@
- 068f3c3: Introduced the `useLogout` hook to facilitate logging out a user
- See https://faustjs.org/docs/next/reference/custom-hooks#uselogout for more details.
+ See https://faustjs.org/docs/next/reference/hooks/useLogout for more details.
- Updated dependencies [068f3c3]
- @faustjs/core@0.12.3
diff --git a/packages/next/src/gqty/hooks/index.ts b/packages/next/src/gqty/hooks/index.ts
index 9a304c7c7..9bc57de02 100644
--- a/packages/next/src/gqty/hooks/index.ts
+++ b/packages/next/src/gqty/hooks/index.ts
@@ -35,14 +35,14 @@ interface WithAuthHooks
{
/**
* Faust.js hook to get preview data for a page or post.
*
- * @see https://faustjs.org/docs/next/reference/custom-hooks#usepreview
+ * @see https://faustjs.org/docs/next/reference/hooks/usePreview
*/
usePreview(): UsePreviewResponse;
/**
* Faust.js hook to ensure a user is authenticated.
*
- * @see https://faustjs.org/docs/next/reference/custom-hooks#useauth
+ * @see https://faustjs.org/docs/next/reference/hooks/useAuth
*/
useAuth(options?: UseAuthOptions): {
isLoading: boolean;
@@ -57,7 +57,7 @@ interface WithAuthHooks {
* Faust.js hook to facilitate a login request.
*
* @param {UseLoginOptions} [options]
- * @see https://faustjs.org/docs/next/reference/custom-hooks#uselogin
+ * @see https://faustjs.org/docs/next/reference/hooks/useLogin
*/
useLogin(options?: UseLoginOptions): {
login: (usernameEmail: string, password: string) => Promise;
@@ -80,7 +80,7 @@ interface WithAuthHooks {
/**
* Faust.js hook to facilitate a logout request.
*
- * @see https://faustjs.org/docs/next/reference/custom-hooks#uselogout
+ * @see https://faustjs.org/docs/next/reference/hooks/useLogout
*/
useLogout(): {
isLoading: boolean;
@@ -103,7 +103,7 @@ export interface NextClientHooks
/**
* GQty hook to make any query request to the Headless Wordpress API.
*
- * @see https://faustjs.org/docs/next/reference/custom-hooks#custom-queries-and-mutations
+ * @see https://faustjs.org/docs/next/reference/hooks/gqty-hooks
*/
useQuery: ReactClient['useQuery'];
@@ -119,7 +119,7 @@ export interface NextClientHooks
/**
* Faust.js hook to get a list of posts.
*
- * @see https://faustjs.org/docs/next/reference/custom-hooks#useposts
+ * @see https://faustjs.org/docs/next/reference/hooks/usePosts
*/
usePosts(
args?: Parameters[0],
@@ -128,7 +128,7 @@ export interface NextClientHooks
/**
* Faust.js hook to get a single post.
*
- * @see https://faustjs.org/docs/next/reference/custom-hooks#usepost
+ * @see https://faustjs.org/docs/next/reference/hooks/usePost
*/
usePost(
args?: Parameters[0],
@@ -137,7 +137,7 @@ export interface NextClientHooks
/**
* Faust.js hook to get a single page.
*
- * @see https://faustjs.org/docs/next/reference/custom-hooks#usepage
+ * @see https://faustjs.org/docs/next/reference/hooks/usePage
*/
usePage(
args?: Parameters[0],