Skip to content

Commit

Permalink
Patch 2 (#62147)
Browse files Browse the repository at this point in the history
<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change
-->
### What?
Updating Example for Storyblok

### Why?
While setting up the Storyblok example to do create quick poc I noticed
some documentation missing and some code not working as expected.

### How?
- Updates documentation about Storyblok example in README
- Code change in HeroPost to make Storyblok example work as expected
  • Loading branch information
mnjongerius authored Feb 16, 2024
1 parent ef1fb15 commit 895e7df
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
41 changes: 38 additions & 3 deletions examples/cms-storyblok/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ In the `Posts` folder, create a new entry.

- **Name** can be anything.

After creating the entry, click **Define schema**.

- Add a key called `title`. Then click `title` and set the **Type** as **Text**
- Add a key called `image`. Then click `title` and set the **Type** as **Text**
- Add a key called `intro`. Then click `title` and set the **Type** as **Text**
- Add a key called `long_text`. Then click `title` and set the **Type** as **Richtext**
- Add a key called `author`. Then click `title` and set the **Type** as **Single-Option** and set **Source** as **Stories** and **Restrict to content type** as **author**

Now, populate each field.

- **Title** can be any text.
Expand Down Expand Up @@ -128,7 +136,34 @@ Then set each variable on `.env.local`:
- `STORYBLOK_API_KEY` should be the API key you just copied.
- `STORYBLOK_PREVIEW_SECRET` can be any random string (but avoid spaces), like `MY_SECRET` - this is used for [the Preview Mode](https://nextjs.org/docs/advanced-features/preview-mode).

### Step 7. Run Next.js in development mode
### Step 9. Configure Image Optimization

To safely allow optimizing images, define a list of supported URL patterns in `next.config.js`. Use the following configuration to allow Storyblok assets and Unspash image URL's

```
module.exports = {
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'a.storyblok.com',
port: '',
pathname: '**',
},
{
protocol: 'https',
hostname: 'images.unsplash.com',
port: '',
pathname: '**',
},
],
},
}
```

Read more about image optimization in the [Documentation](https://nextjs.org/docs/pages/building-your-application/optimizing/images)

### Step 8. Run Next.js in development mode

```bash
npm install
Expand All @@ -142,7 +177,7 @@ yarn dev

Your blog should be up and running on [http://localhost:3000](http://localhost:3000)! If it doesn't work, you can post on [GitHub discussions](https://github.com/vercel/next.js/discussions).

### Step 8. Try preview mode
### Step 9. Try preview mode

To try preview mode, create another post like before (you can try duplicating), but **do not publish it - just save it**:

Expand All @@ -159,7 +194,7 @@ http://localhost:3000/api/preview?secret=<secret>&slug=<slug>

You should now be able to see the draft post. To exit the preview mode, you can click **Click here to exit preview mode** at the top.

### Step 9. Deploy on Vercel
### Step 10. Deploy on Vercel

You can deploy this app to the cloud with [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)).

Expand Down
2 changes: 1 addition & 1 deletion examples/cms-storyblok/components/hero-post.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function HeroPost({
return (
<section>
<div className="mb-8 md:mb-16">
<CoverImage title={title} url={coverImage} slug={slug} />
<CoverImage title={title} url={coverImage} slug={`/posts/${slug}`} />
</div>
<div className="md:grid md:grid-cols-2 md:gap-x-16 lg:gap-x-8 mb-20 md:mb-28">
<div>
Expand Down

0 comments on commit 895e7df

Please sign in to comment.