Unverified Commit b14d9a42 authored by Stanislav Kozachenko's avatar Stanislav Kozachenko Committed by GitHub

docs: fix code examples in getting-started guides (#93273)

### What?

Fix three broken code examples in the Getting Started section.

### Why?

Per the contribution guide, code blocks should contain a minimum working
example that can be copied and pasted. These examples have bugs that
would cause runtime errors or incorrect behavior:

1. `02-project-structure.mdx`: Extra comma in App Icons table —
`apple-icon` row has `.jpg` `.jpeg`, `.png` while all other rows use
space-separated extensions without commas.
2. `03-layouts-and-pages.mdx`: `Post` component has an unused `post`
prop — the component fetches and renders all posts internally via
`getPosts()`, so the prop is never referenced. Removed the unused prop,
renamed to `Posts` to match its actual behavior, and added the missing
`import { getPosts } from '@/lib/posts'`.
3. `04-linking-and-navigating.mdx`: JSX `Layout` function is missing `{
children }` in its parameter list, causing `ReferenceError: children is
not defined` at runtime. The TSX version is correct.

### How?

- Remove stray comma from App Icons table
- Remove unused `post` prop from `Post` component, rename to `Posts`,
add missing import
- Add `{ children }` destructuring to JSX `Layout` function signature

Closes #93272

---------
Co-authored-by: 's avatarJoseph <joseph.chamochumbi@vercel.com>
parent 5edf4823
......@@ -122,7 +122,7 @@ Use `@slot` for named slots rendered by a parent layout. Use intercept patterns
| [`favicon`](/docs/app/api-reference/file-conventions/metadata/app-icons#favicon) | `.ico` | Favicon file |
| [`icon`](/docs/app/api-reference/file-conventions/metadata/app-icons#icon) | `.ico` `.jpg` `.jpeg` `.png` `.svg` | App Icon file |
| [`icon`](/docs/app/api-reference/file-conventions/metadata/app-icons#generate-icons-using-code-js-ts-tsx) | `.js` `.ts` `.tsx` | Generated App Icon |
| [`apple-icon`](/docs/app/api-reference/file-conventions/metadata/app-icons#apple-icon) | `.jpg` `.jpeg`, `.png` | Apple App Icon file |
| [`apple-icon`](/docs/app/api-reference/file-conventions/metadata/app-icons#apple-icon) | `.jpg` `.jpeg` `.png` | Apple App Icon file |
| [`apple-icon`](/docs/app/api-reference/file-conventions/metadata/app-icons#generate-icons-using-code-js-ts-tsx) | `.js` `.ts` `.tsx` | Generated Apple App Icon |
#### Open Graph and Twitter images
......
......@@ -287,10 +287,11 @@ You can use the [`<Link>` component](/docs/app/api-reference/components/link) to
For example, to generate a list of blog posts, import `<Link>` from `next/link` and pass a `href` prop to the component:
```tsx filename="app/ui/post.tsx" highlight={1,10} switcher
```tsx filename="app/ui/post.tsx" highlight={1,2,11} switcher
import Link from 'next/link'
import { getPosts } from '@/lib/posts'
export default async function Post({ post }) {
export default async function Posts() {
const posts = await getPosts()
return (
......@@ -305,10 +306,11 @@ export default async function Post({ post }) {
}
```
```jsx filename="app/ui/post.js" highlight={1,10} switcher
```jsx filename="app/ui/post.js" highlight={1,2,11} switcher
import Link from 'next/link'
import { getPosts } from '@/lib/posts'
export default async function Post({ post }) {
export default async function Posts() {
const posts = await getPosts()
return (
......
......@@ -65,7 +65,7 @@ export default function Layout({ children }: { children: React.ReactNode }) {
```jsx filename="app/layout.js" switcher
import Link from 'next/link'
export default function Layout() {
export default function Layout({ children }) {
return (
<html>
<body>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment