Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Final 2.0 Docs Updates #835

Merged
merged 5 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion www/config/site.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const site: SiteConfig = {
},
{
title: "API",
href: "/api/modules.html",
href: "/api/modules",
},
{
title: "Blog",
Expand Down
4 changes: 2 additions & 2 deletions www/content/docs/authentication.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ To configure authentication, provide a `client_id` and `client_secret` as option

<Callout icon="⚠️">

You need to enable the `simple_oauth` module on Drupal.
You need to enable the `simple_oauth` module in Drupal.

</Callout>

Expand Down Expand Up @@ -105,7 +105,7 @@ You can also use the basic authorization using a `username` and `password`:

<Callout icon="⚠️">

You need to enable the `basic_auth` module on Drupal.
You need to enable the `basic_auth` module in Drupal.

</Callout>

Expand Down
6 changes: 0 additions & 6 deletions www/content/docs/cache.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<Callout>

Note: as of `next-drupal 1.3.0`, only `getResource` and `getMenu` support caching.

</Callout>

```ts title=lib/drupal.ts
import { NextDrupal, DataCache } from "next-drupal"
import Redis from "ioredis"
Expand Down
10 changes: 2 additions & 8 deletions www/content/docs/creating-resources.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@ title: Creating Resources (POST)
excerpt: How to create JSON:API resources using NextDrupal client.
---

<Callout icon="⚠️">

The `createResource` and `createFileResource` helpers are available in `next-drupal ^1.4.0`.

</Callout>

<Callout>

If you're working with JSON:API, be mindful to select the option:
Expand Down Expand Up @@ -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).

---

Expand Down Expand Up @@ -116,7 +110,7 @@ const media = await drupal.createResource<DrupalMedia>("media--image", {
})
```

See the API reference for [createFileResource](/docs/reference/createfileresource).
See the API reference for [createFileResource](/api/classes/NextDrupal#createfileresource).

---

Expand Down
8 changes: 1 addition & 7 deletions www/content/docs/deleting-resources.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@ title: Deleting Resources (DELETE)
excerpt: How to delete JSON:API resources using NextDrupal.
---

<Callout icon="⚠️">

The `deleteResource` helper is available in `next-drupal ^1.4.0`.

</Callout>

<Callout>

If you're working with JSON:API, be mindful to select the option:
Expand All @@ -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).

---

Expand Down
12 changes: 6 additions & 6 deletions www/content/docs/fetching-resources.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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).

---

Expand All @@ -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).

---

Expand All @@ -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).

---

Expand All @@ -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).

---

Expand All @@ -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).

---

Expand All @@ -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).

---

Expand Down
10 changes: 1 addition & 9 deletions www/content/docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@ Welcome to the next-drupal documentation.

This documentation covers `next-drupal 2.0`.

<!--
************************************************************
* TODO: Remove this block before publishing.

* Comment: Modify url for older versions' documentation
************************************************************
-->

If you're using an older version, you can find the documentation [here](https://v1.next-drupal.org).

---
Expand Down Expand Up @@ -52,7 +44,7 @@ npx create-next-app -e https://github.com/chapter-three/next-drupal-basic-starte
</CardBody>
</Card>

<Card href="/docs/reference">
<Card href="/api/modules">
<CardHeading>API Reference</CardHeading>
<CardBody>
<p>API Reference for NextDrupal client.</p>
Expand Down
2 changes: 2 additions & 0 deletions www/content/docs/typescript.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 1 addition & 7 deletions www/content/docs/updating-resources.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@ title: Updating Resources (PATCH)
excerpt: How to update JSON:API resources using NextDrupal client.
---

<Callout icon="⚠️">

The `updateResource` helper is available in `next-drupal ^1.4.0`.

</Callout>

<Callout>

If you're working with JSON:API, be mindful to select the option:
Expand Down Expand Up @@ -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).

---

Expand Down
8 changes: 6 additions & 2 deletions www/content/guides/umami-demo.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
},
}
Expand All @@ -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.
Expand Down Expand Up @@ -75,6 +75,8 @@ yarn dev

5. Visit `http://localhost:3000` to see the Next.js site.

<!--

---

## How to enable authentication
Expand Down Expand Up @@ -112,3 +114,5 @@ NEXT_IMAGE_DOMAIN=localhost
3. **Save configuration**

You can now visit `http://localhost:3000/articles/new` to create a new article.

-->
8 changes: 4 additions & 4 deletions www/content/tutorials/draft-mode/create-oauth-client.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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`
Expand All @@ -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).

Expand All @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion www/content/tutorials/graphql/apply-patches.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 21 additions & 6 deletions www/content/tutorials/graphql/configure-authentication.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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._
5 changes: 3 additions & 2 deletions www/content/tutorials/graphql/enable-modules.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion www/content/tutorials/quick-start/apply-patches.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion www/next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// 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.
13 changes: 13 additions & 0 deletions www/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
]
},
}
Loading