Commit Graph

4 Commits

Author SHA1 Message Date
Manoraj K 8669b07f19 fix(cms-contentful): await draftMode() and use Promise<> params type (#95631)
### What?
Fix the `cms-contentful` example to use the async APIs introduced in
Next.js 15:
- Await `draftMode()` in `app/page.tsx`, `app/posts/[slug]/page.tsx`,
and
  `app/api/disable-draft/route.ts`
  - Update `params` type to `Promise<{ slug: string }>` and await it in
  `app/posts/[slug]/page.tsx`

### Why?
In Next.js 15, `draftMode()` from `next/headers` became async and must
be awaited.
Page `params` are also now typed as a `Promise`. The example was using
the old
synchronous patterns, causing the build to fail and the app to not work
when running against the latest
version of Next.js -- this example project uses latest version of
next.js in the package.json.

### How?
Awaited `draftMode()` at each call site and updated the `params` type
signature to
  `Promise<{ slug: string }>` with a corresponding `await`.

Closes NEXT-
Fixes #
2026-07-20 18:18:38 +02:00
Joel Hooks 658ffe2e0e examples: inngest example for latest version (#68600)
Co-authored-by: malewis5 <matthew.a.lewis7@gmail.com>
Co-authored-by: Lee Robinson <me@leerob.io>
2024-08-15 10:45:36 -05:00
Steven 4466ba436b chore(examples): use default prettier for examples/templates (#60530)
## Description
This PR ensures that the default prettier config is used for examples
and templates.

This config is compatible with `prettier@3` as well (upgrading prettier
is bigger change that can be a future PR).

## Changes
- Updated `.prettierrc.json` in root with `"trailingComma": "es5"` (will
be needed upgrading to prettier@3)
- Added `examples/.prettierrc.json` with default config (this will
change every example)
- Added `packages/create-next-app/templates/.prettierrc.json` with
default config (this will change every template)

## Related

- Fixes #54402
- Closes #54409
2024-01-11 16:01:44 -07:00
Lee Robinson 0718aec93b Update Contentful example for App Router. (#54205)
This PR updates the `cms-contentful` example to use:

- App Router
- TypeScript
- Draft Mode (previously Preview Mode)
- ISR / Data Cache (revalidations through `revalidateTag`)

Further, it combines many separate files into more manageable single files, and tries to better bucket provider-specific logic into the `lib/` folder. I'm hoping this can be the foundation for re-writing the rest of the `cms-*` examples to use App Router.

Overall, the code is much easier to reason about IMO. Pretty happy with the change. I sprinkled some `any`'s throughout here, but if someone wants to make it better, go for it! 

https://app-router-contentful.vercel.app/
2023-08-21 13:21:37 +00:00