Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
8777404
feat: move API docs outside of Next site
backlineint Jan 21, 2025
982e9c6
feat: port all examples from getResource docs to Typedoc version
backlineint Jan 21, 2025
02c22f9
feat: example of ignoring something from tsdoc docs
backlineint Jan 21, 2025
16c6e0b
feat: example of marking something as deprecated
backlineint Jan 21, 2025
61488cd
docs: add additional detail to getResource entry
backlineint Jan 22, 2025
27cd1b7
docs: initial revisions to getResourceFromContext typedoc
backlineint Jan 23, 2025
1509e09
docs: add remaining examples to getResourceFromContext typedoc
backlineint Jan 23, 2025
32d40b1
docs: add examples for getResourceByPath
backlineint Jan 24, 2025
d666e5f
docs: add reference examples to getResourceCollection
backlineint Jan 27, 2025
b06eb64
docs: add reference example for getResourceCollectionFromContext
backlineint Jan 27, 2025
af6086a
docs: add reference examples to next-drupal createResource
backlineint Jan 27, 2025
9000395
docs: add reference examples to createFileResource
backlineint Jan 29, 2025
a01008b
docs: add reference examples to updateResource
backlineint Jan 29, 2025
f763ddc
docs: add reference examples to deleteResource
backlineint Jan 29, 2025
2e8d778
docs: add reference examples to getStaticPathsFromContext
backlineint Jan 29, 2025
4c5f95a
docs: add reference examples to translatePath
backlineint Jan 29, 2025
cbe0eab
docs: add reference examples to translatePathFromContext
backlineint Jan 29, 2025
6162143
docs: add reference examples to getPathFromContext
backlineint Jan 29, 2025
92d936e
docs: add reference examples for getEntryForResourceType
backlineint Jan 29, 2025
e16c976
docs: add reference examples for preview method
backlineint Jan 29, 2025
26582a5
docs: add reference examples to getAccessToken
backlineint Jan 29, 2025
a7c852d
docs: add reference examples to getMenu
backlineint Jan 29, 2025
7a61575
docs: add reference examples to getView
backlineint Jan 29, 2025
2015920
docs: add reference examples to getSearchIndex
backlineint Jan 29, 2025
63d1e3b
docs: add reference examples to buildUrl
backlineint Jan 29, 2025
ace7dac
docs: add reference examples to fetch
backlineint Jan 29, 2025
4d27b15
docs: add reference examples for deserialize
backlineint Jan 29, 2025
8a8d762
docs: update 2.0 announcement, including contributors
backlineint Jan 30, 2025
b0633e4
docs: correctly filter list of contributors in 2.x announcement
backlineint Jan 30, 2025
0e3158f
docs: update to umami demo guide
backlineint Jan 31, 2025
e267f77
docs: minor updates to GraphQL auth entry
backlineint Feb 3, 2025
2ca5e46
docs: remove todo
backlineint Feb 4, 2025
3da32e4
docs: updates to draft mode quick start
backlineint Feb 5, 2025
35c5f6e
docs: tweaks to oauth client docs to allow for revisions
backlineint Feb 6, 2025
6783a36
docs: updates to on-demand validation quick start
backlineint Feb 7, 2025
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
1 change: 1 addition & 0 deletions packages/next-drupal/src/deprecated/get-access-token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { AccessToken } from "../types"

const CACHE_KEY = "NEXT_DRUPAL_ACCESS_TOKEN"

/** @deprecated */
export async function getAccessToken(): Promise<AccessToken> {
if (!process.env.DRUPAL_CLIENT_ID || !process.env.DRUPAL_CLIENT_SECRET) {
return null
Expand Down
1 change: 1 addition & 0 deletions packages/next-drupal/src/jsonapi-errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface JsonApiLinks {
[key: string]: string | Record<string, string>
}

/** @hidden */
export class JsonApiErrors extends Error {
errors: JsonApiError[] | string
statusCode: number
Expand Down
56 changes: 56 additions & 0 deletions packages/next-drupal/src/next-drupal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,62 @@ export class NextDrupal extends NextDrupalBase {
* @param {string} uuid The UUID of the resource.
* @param {JsonApiOptions & JsonApiWithCacheOptions & JsonApiWithNextFetchOptions} options Options for the request.
* @returns {Promise<T>} The fetched resource.
* @examples
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This examples diff was made by feeding the markdown from the old reference section to Copilot, which made this waaaay less tedious.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! This looks really good.

* Get a page by uuid.
* ```ts
* const node = await drupal.getResource(
* "node--page",
* "07464e9f-9221-4a4f-b7f2-01389408e6c8"
* )
* ```
* Get the es translation for a page by uuid.
* ```ts
* const node = await drupal.getResource(
* "node--page",
* "07464e9f-9221-4a4f-b7f2-01389408e6c8",
* {
* locale: "es",
* defaultLocale: "en",
* }
* )
* ```
* Get the raw JSON:API response.
* ```ts
* const { data, meta, links } = await drupal.getResource(
* "node--page",
* "07464e9f-9221-4a4f-b7f2-01389408e6c8",
* {
* deserialize: false,
* }
* )
* ```
* Get a node--article resource using cache.
* ```ts
* const id = "07464e9f-9221-4a4f-b7f2-01389408e6c8"
*
* const article = await drupal.getResource("node--article", id, {
* withCache: true,
* cacheKey: `node--article:${id}`,
* })
* ```
* Using DrupalNode for a node entity type.
* ```ts
* import { DrupalNode } from "next-drupal"
*
* const node = await drupal.getResource<DrupalNode>(
* "node--page",
* "07464e9f-9221-4a4f-b7f2-01389408e6c8"
* )
* ```
* Using DrupalTaxonomyTerm for a taxonomy term entity type.
* ```ts
* import { DrupalTaxonomyTerm } from "next-drupal"
*
* const term = await drupal.getResource<DrupalTaxonomyTerm>(
* "taxonomy_term--tags",
* "7b47d7cc-9b1b-4867-a909-75dc1d61dfd3"
* )
* ```
*/
async getResource<T extends JsonApiResource>(
type: string,
Expand Down
2 changes: 1 addition & 1 deletion www/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
/cypress/videos

# Files generated automatically by typedoc
/content/docs/api
/public/api

# next.js
/.next/
Expand Down
9 changes: 0 additions & 9 deletions www/config/docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,6 @@ export const docsConfig: DocsConfig = {
},
],
},
{
title: "API",
items: [
{
title: "API Reference",
href: "/docs/api/globals",
},
],
},
{
title: "Drupal",
items: [
Expand Down
4 changes: 4 additions & 0 deletions www/config/site.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ export const site: SiteConfig = {
href: "/guides",
activePathNames: ["/guides/[...slug]"],
},
{
title: "API",
href: "/api/modules.html",
},
{
title: "Blog",
href: "/blog",
Expand Down
8 changes: 4 additions & 4 deletions www/typedoc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"plugin": ["typedoc-plugin-markdown"],
"entryPoints": ["../packages/next-drupal/src/index.ts"],
"out": "content/docs/api",
"fileExtension": ".mdx",
"hidePageHeader": true
"out": "public/api",
"navigationLinks": {
"Back to Docs": "/docs"
}
}
Loading