diff --git a/www/config/site.ts b/www/config/site.ts index 0c060ba9..24c64df2 100644 --- a/www/config/site.ts +++ b/www/config/site.ts @@ -28,7 +28,7 @@ export const site: SiteConfig = { }, { title: "API", - href: "/api/modules.html", + href: "/api/modules", }, { title: "Blog", diff --git a/www/content/docs/authentication.mdx b/www/content/docs/authentication.mdx index 76b5c6f1..0dc7df01 100644 --- a/www/content/docs/authentication.mdx +++ b/www/content/docs/authentication.mdx @@ -53,7 +53,7 @@ To configure authentication, provide a `client_id` and `client_secret` as option -You need to enable the `simple_oauth` module on Drupal. +You need to enable the `simple_oauth` module in Drupal. @@ -105,7 +105,7 @@ You can also use the basic authorization using a `username` and `password`: -You need to enable the `basic_auth` module on Drupal. +You need to enable the `basic_auth` module in Drupal. diff --git a/www/content/docs/cache.mdx b/www/content/docs/cache.mdx index 9089eadd..ec7c5c41 100644 --- a/www/content/docs/cache.mdx +++ b/www/content/docs/cache.mdx @@ -15,12 +15,6 @@ You can provide your own cache implementation using the [`cache`](/docs/configur Here's an example on how you can use Redis to cache resources. - - -Note: as of `next-drupal 1.3.0`, only `getResource` and `getMenu` support caching. - - - ```ts title=lib/drupal.ts import { NextDrupal, DataCache } from "next-drupal" import Redis from "ioredis" diff --git a/www/content/docs/creating-resources.mdx b/www/content/docs/creating-resources.mdx index d3e56379..f17d3b6c 100644 --- a/www/content/docs/creating-resources.mdx +++ b/www/content/docs/creating-resources.mdx @@ -3,12 +3,6 @@ title: Creating Resources (POST) excerpt: How to create JSON:API resources using NextDrupal client. --- - - -The `createResource` and `createFileResource` helpers are available in `next-drupal ^1.4.0`. - - - If you're working with JSON:API, be mindful to select the option: @@ -71,7 +65,7 @@ const article = await drupal.createResource("node--article", { }) ``` -See the API reference for [createResource](/docs/reference/createresource). +See the API reference for [createResource](/api/classes/NextDrupal#createresource). --- @@ -116,7 +110,7 @@ const media = await drupal.createResource("media--image", { }) ``` -See the API reference for [createFileResource](/docs/reference/createfileresource). +See the API reference for [createFileResource](/api/classes/NextDrupal#createfileresource). --- diff --git a/www/content/docs/deleting-resources.mdx b/www/content/docs/deleting-resources.mdx index 473180f5..39b6bfb9 100644 --- a/www/content/docs/deleting-resources.mdx +++ b/www/content/docs/deleting-resources.mdx @@ -3,12 +3,6 @@ title: Deleting Resources (DELETE) excerpt: How to delete JSON:API resources using NextDrupal. --- - - -The `deleteResource` helper is available in `next-drupal ^1.4.0`. - - - If you're working with JSON:API, be mindful to select the option: @@ -34,7 +28,7 @@ const deleted = await drupal.deleteResource( ) ``` -See the API reference for [deleteResource](/docs/reference/deleteresource). +See the API reference for [deleteResource](/api/classes/NextDrupal#deleteresource). --- diff --git a/www/content/docs/fetching-resources.mdx b/www/content/docs/fetching-resources.mdx index 70cd6bb1..f5f82d2f 100644 --- a/www/content/docs/fetching-resources.mdx +++ b/www/content/docs/fetching-resources.mdx @@ -55,7 +55,7 @@ const block = await drupal.getResource( ) ``` -See the API reference for [getResource](/docs/reference/getresource). +See the API reference for [getResource](/api/classes/NextDrupal#getresource). --- @@ -67,7 +67,7 @@ Fetch an article by path. const article = await drupal.getResourceByPath("/blog/slug-for-article") ``` -See the API reference for [getResourceByPath](/docs/reference/getresourcebypath). +See the API reference for [getResourceByPath](/api/classes/NextDrupal#getresourcebypath). --- @@ -90,7 +90,7 @@ const articles = await drupal.getResourceCollection("node--article", { }) ``` -See the API reference for [getResourceCollection](/docs/reference/getresourcecollection). +See the API reference for [getResourceCollection](/api/classes/NextDrupal#getresourcecollection). --- @@ -108,7 +108,7 @@ Fetch a menu by name const menu = await drupal.getMenu("main") ``` -See the API reference for [getMenu](/docs/reference/getmenu). +See the API reference for [getMenu](/api/classes/NextDrupal#getmenu). --- @@ -126,7 +126,7 @@ Fetch a view by name and display_id. const view = await drupal.getView("promoted_items--block_1") ``` -See the API reference for [getView](/docs/reference/getview). +See the API reference for [getView](/api/classes/NextDrupal#getview). --- @@ -148,7 +148,7 @@ const results = await drupal.getSearchIndex(indexName, { }) ``` -See the API reference for [getSearchIndex](/docs/reference/getsearch). +See the API reference for [getSearchIndex](/api/classes/NextDrupal#getsearchindex). --- diff --git a/www/content/docs/index.mdx b/www/content/docs/index.mdx index 85ce2b7e..cee526ff 100644 --- a/www/content/docs/index.mdx +++ b/www/content/docs/index.mdx @@ -7,14 +7,6 @@ Welcome to the next-drupal documentation. This documentation covers `next-drupal 2.0`. - - If you're using an older version, you can find the documentation [here](https://v1.next-drupal.org). --- @@ -52,7 +44,7 @@ npx create-next-app -e https://github.com/chapter-three/next-drupal-basic-starte - + API Reference

API Reference for NextDrupal client.

diff --git a/www/content/docs/typescript.mdx b/www/content/docs/typescript.mdx index 12f29fe7..ddd1c612 100644 --- a/www/content/docs/typescript.mdx +++ b/www/content/docs/typescript.mdx @@ -7,6 +7,8 @@ Every helper method for the `NextDrupal` client has full TypeScript support. The `next-drupal` module ships with some default basic types you can use. +For a full list of all types, consult the [API Reference](/api/modules). + --- ## Built-in Types diff --git a/www/content/docs/updating-resources.mdx b/www/content/docs/updating-resources.mdx index 2032e232..6b32f6be 100644 --- a/www/content/docs/updating-resources.mdx +++ b/www/content/docs/updating-resources.mdx @@ -3,12 +3,6 @@ title: Updating Resources (PATCH) excerpt: How to update JSON:API resources using NextDrupal client. --- - - -The `updateResource` helper is available in `next-drupal ^1.4.0`. - - - If you're working with JSON:API, be mindful to select the option: @@ -65,7 +59,7 @@ const article = await drupal.updateResource( ) ``` -See the API reference for [updateResource](/docs/reference/updateresource). +See the API reference for [updateResource](/api/classes/NextDrupal#updateresource). --- diff --git a/www/content/guides/umami-demo.mdx b/www/content/guides/umami-demo.mdx index f7b8044c..ce4cdb72 100644 --- a/www/content/guides/umami-demo.mdx +++ b/www/content/guides/umami-demo.mdx @@ -17,7 +17,7 @@ composer create-project drupal/recommended-project umami "extra": { "patches": { "drupal/decoupled_router": { - "Unable to resolve path on node in other language than default": "https://www.drupal.org/files/issues/2024-10-22/decoupled_router-3111456-resolve-langcode-issue-78--external-redirects.patch" + "Unable to resolve path on node in other language than default": "https://www.drupal.org/files/issues/2024-08-05/decouple_router-3111456-resolve-language-issue-63--get-translation-re-rolled-and-good-redirect.patch" } }, } @@ -26,7 +26,7 @@ composer create-project drupal/recommended-project umami 3. Add dependencies ```bash -composer require drupal/next drupal/jsonapi_menu_items drupal/jsonapi_views drupal/jsonapi_resources +composer require drupal/next drupal/jsonapi_menu_items drupal/jsonapi_views drupal/jsonapi_resources cweagans/composer-patches ``` 4. Install Drupal. Make sure you select **Demo: Umami Food Magazine (Experimental)** as the installation profile. @@ -75,6 +75,8 @@ yarn dev 5. Visit `http://localhost:3000` to see the Next.js site. + diff --git a/www/content/tutorials/draft-mode/create-oauth-client.mdx b/www/content/tutorials/draft-mode/create-oauth-client.mdx index e9b983ba..ebd1165f 100644 --- a/www/content/tutorials/draft-mode/create-oauth-client.mdx +++ b/www/content/tutorials/draft-mode/create-oauth-client.mdx @@ -81,7 +81,7 @@ openssl rsa -in private.key -pubout > public.key --- -## 5. Create Scopes +## 5. Create Scope 1. Visit _/admin/config/people/simple_oauth/oauth2_scope/dynamic/add_ 2. Fill in the following values: @@ -102,7 +102,7 @@ openssl rsa -in private.key -pubout > public.key 2. Fill in the following values: - **Label**: `Next.js site` -- **Client ID**: `nextjs_site` (or generate a UUID is preferred) +- **Client ID**: `nextjs_site` (or generate a UUID if preferred) - **Secret**: `Your secret` - **Grant Types**: `Client Credentials` - **Scopes**: `nextjs_site` @@ -114,7 +114,7 @@ _Important: note the client id (uuid) and the secret. These are going to be used --- -## 6. Connect Drupal +## 7. Connect Drupal To connect the Next.js project to Drupal, we use [environment variables](https://nextjs.org/docs/basic-features/environment-variables). @@ -128,7 +128,7 @@ DRUPAL_CLIENT_SECRET= --- -## 7. Update NextDrupal client. +## 8. Update NextDrupal client. Update the `NextDrupal` client to use the **Bearer** authentication header. diff --git a/www/content/tutorials/graphql/apply-patches.mdx b/www/content/tutorials/graphql/apply-patches.mdx index e75f0d00..5318acea 100644 --- a/www/content/tutorials/graphql/apply-patches.mdx +++ b/www/content/tutorials/graphql/apply-patches.mdx @@ -21,7 +21,7 @@ At the time of this writing, a patch is required in order to use multilingual fe // highlight-start "patches": { "drupal/decoupled_router": { - "Unable to resolve path on node in other language than default": "https://www.drupal.org/files/issues/2024-10-22/decoupled_router-3111456-resolve-langcode-issue-78--external-redirects.patch" + "Unable to resolve path on node in other language than default": "https://www.drupal.org/files/issues/2024-08-05/decouple_router-3111456-resolve-language-issue-63--get-translation-re-rolled-and-good-redirect.patch" } }, // highlight-end diff --git a/www/content/tutorials/graphql/configure-authentication.mdx b/www/content/tutorials/graphql/configure-authentication.mdx index 5bca6e61..f07e2868 100644 --- a/www/content/tutorials/graphql/configure-authentication.mdx +++ b/www/content/tutorials/graphql/configure-authentication.mdx @@ -54,18 +54,33 @@ openssl rsa -in private.key -pubout > public.key --- -## 5. Create Consumer +## 5. Create Scope + +1. Visit _/admin/config/people/simple_oauth/oauth2_scope/dynamic/add_ +2. Fill in the following values: + +- **Machine-readable Name**: `nextjs_site` +- **Description**: `Next.js Site` +- **Grant Types**: `Client Credentials` +- **Granularity**: `Role` +- **Role**: `Next.js Site` + +3. Click **Save** + +--- + +## 6. Create Consumer 1. Visit _/admin/config/services/consumer/add_ 2. Fill in the following values: - **Label**: `Next.js site` -- **Client ID**: `nextjs_site` -- **User**: `Select the user we created` +- **Client ID**: `nextjs_site` (or generate a UUID if preferred) - **Secret**: `Your secret` -- **Grant Types**: `Select 'Client Credentials'` -- **Scopes**: `Select the role we created` +- **Grant Types**: `Client Credentials` +- **Scopes**: `nextjs_site` +- **User**: `Select the user we created` 3. Click **Save** -_Important: note the client id and the secret. These are going to be used as environment variables for the Next.js site._ +_Important: note the client id (uuid) and the secret. These are going to be used as environment variables for the Next.js site._ diff --git a/www/content/tutorials/graphql/enable-modules.mdx b/www/content/tutorials/graphql/enable-modules.mdx index 1997a8c0..64eb8d30 100644 --- a/www/content/tutorials/graphql/enable-modules.mdx +++ b/www/content/tutorials/graphql/enable-modules.mdx @@ -6,14 +6,15 @@ group: Quick Start (GraphQL) --- 1. Visit `/admin/modules`. -2. Enable the following modules: **Next.js**, **Next.js GraphQL**, **GraphQL Compose: Edges**, **GraphQL Compose: Routes**. +2. Enable the following modules: **Next.js**, **Next.js GraphQL**, **GraphQL Compose: Edges**, **GraphQL Compose: Routes**, **GraphQL Compose: Users**. ## Configure GraphQL Compose 1. Visit `/admin/config/graphql_compose`. -2. Enable "GraphQL", "Single Query", "Edge Query", & "Loading by Route" for the Article content type. +2. Under the Content tab, enable "GraphQL", "Single Query", "Edge Query", & "Loading by Route" for the Article content type. 3. Enable all of the fields for the Article content type. 4. Do the same for the Basic page content type. +5. Under the Users tab, do the same for the user entity. ## Try GraphQL diff --git a/www/content/tutorials/quick-start/apply-patches.mdx b/www/content/tutorials/quick-start/apply-patches.mdx index 727f2f92..695cdf86 100644 --- a/www/content/tutorials/quick-start/apply-patches.mdx +++ b/www/content/tutorials/quick-start/apply-patches.mdx @@ -21,7 +21,7 @@ At the time of this writing, a patch is required in order to use multilingual fe // highlight-start "patches": { "drupal/decoupled_router": { - "Unable to resolve path on node in other language than default": "https://www.drupal.org/files/issues/2024-10-22/decoupled_router-3111456-resolve-langcode-issue-78--external-redirects.patch" + "Unable to resolve path on node in other language than default": "https://www.drupal.org/files/issues/2024-08-05/decouple_router-3111456-resolve-language-issue-63--get-translation-re-rolled-and-good-redirect.patch" } }, // highlight-end diff --git a/www/next-env.d.ts b/www/next-env.d.ts index 4f11a03d..a4a7b3f5 100644 --- a/www/next-env.d.ts +++ b/www/next-env.d.ts @@ -2,4 +2,4 @@ /// // NOTE: This file should not be edited -// see https://nextjs.org/docs/basic-features/typescript for more information. +// see https://nextjs.org/docs/pages/building-your-application/configuring/typescript for more information. diff --git a/www/next.config.js b/www/next.config.js index 3d9e3363..5c102130 100644 --- a/www/next.config.js +++ b/www/next.config.js @@ -107,6 +107,19 @@ module.exports = { destination: "/docs/api/:path*", permanent: true, }, + { + source: "/api/:path*.html", + destination: "/api/:path*", + permanent: true, + }, + ] + }, + async rewrites() { + return [ + { + source: "/api/:slug*", + destination: "/api/:slug*.html", // Matched parameters can be used in the destination + }, ] }, }