Skip to content

Commit ab42da0

Browse files
authored
Run next/link codemod for Next.js 13 on examples (#41913)
1 parent 8ada894 commit ab42da0

File tree

273 files changed

+753
-1028
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

273 files changed

+753
-1028
lines changed

examples/active-class-name/components/ActiveLink.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const ActiveLink = ({
5252
])
5353

5454
return (
55-
<Link {...props}>
55+
<Link {...props} legacyBehavior>
5656
{React.cloneElement(child, {
5757
className: className || null,
5858
})}

examples/analyze-bundles/pages/index.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ const Index: NextPage<IndexProps> = ({ name }) => {
1212
<h1>Home Page</h1>
1313
<p>Welcome, {name}</p>
1414
<div>
15-
<Link href="/about">
16-
<a>About Page</a>
17-
</Link>
15+
<Link href="/about">About Page</Link>
1816
</div>
1917
</div>
2018
)

examples/api-routes-apollo-server-and-client-auth/pages/about.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@ import Link from 'next/link'
33
export default function About() {
44
return (
55
<div>
6-
Welcome to the about page. Go to the{' '}
7-
<Link href="/">
8-
<a>Home</a>
9-
</Link>{' '}
10-
page.
6+
Welcome to the about page. Go to the <Link href="/">Home</Link> page.
117
</div>
128
)
139
}

examples/api-routes-apollo-server-and-client-auth/pages/index.js

+2-8
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,8 @@ const Index = () => {
3232
if (viewer) {
3333
return (
3434
<div>
35-
You're signed in as {viewer.email} goto{' '}
36-
<Link href="/about">
37-
<a>about</a>
38-
</Link>{' '}
39-
page. or{' '}
40-
<Link href="/signout">
41-
<a>signout</a>
42-
</Link>
35+
You're signed in as {viewer.email} goto <Link href="/about">about</Link>{' '}
36+
page. or <Link href="/signout">signout</Link>
4337
</div>
4438
)
4539
}

examples/api-routes-apollo-server-and-client-auth/pages/signin.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@ function SignIn() {
6565
label="Password"
6666
/>
6767
<button type="submit">Sign in</button> or{' '}
68-
<Link href="/signup">
69-
<a>Sign up</a>
70-
</Link>
68+
<Link href="/signup">Sign up</Link>
7169
</form>
7270
</>
7371
)

examples/api-routes-apollo-server-and-client-auth/pages/signup.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ function SignUp() {
6060
label="Password"
6161
/>
6262
<button type="submit">Sign up</button> or{' '}
63-
<Link href="/signin">
64-
<a>Sign in</a>
65-
</Link>
63+
<Link href="/signin">Sign in</Link>
6664
</form>
6765
</>
6866
)

examples/api-routes-apollo-server-and-client/pages/about.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@ import Link from 'next/link'
33
export default function About() {
44
return (
55
<div>
6-
This is a static page goto{' '}
7-
<Link href="/">
8-
<a>dynamic</a>
9-
</Link>{' '}
10-
page.
6+
This is a static page goto <Link href="/">dynamic</Link> page.
117
</div>
128
)
139
}

examples/api-routes-apollo-server-and-client/pages/index.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ const Index = () => {
2121
return (
2222
<div>
2323
You're signed in as {viewer.name} and you're {viewer.status} goto{' '}
24-
<Link href="/about">
25-
<a>static</a>
26-
</Link>{' '}
27-
page.
24+
<Link href="/about">static</Link> page.
2825
</div>
2926
)
3027
}

examples/api-routes-apollo-server/pages/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default function UserListing({ users }) {
1010
{users.map((user) => (
1111
<li key={user.username}>
1212
<Link href="/[username]" as={`/${user.username}`}>
13-
<a>{user.name}</a>
13+
{user.name}
1414
</Link>
1515
</li>
1616
))}

examples/api-routes-rest/pages/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default function Index() {
1414
<ul>
1515
{data.map((user) => (
1616
<li key={user.id}>
17-
<Link href="/user/[id]" as={`/user/${user.id}`}>
17+
<Link href="/user/[id]" as={`/user/${user.id}`} legacyBehavior>
1818
{`User ${user.id}`}
1919
</Link>
2020
</li>

examples/api-routes/components/Person.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default function PersonComponent({ person }: PersonProps) {
99
return (
1010
<li>
1111
<Link href="/person/[id]" as={`/person/${person.id}`}>
12-
<a>{person.name}</a>
12+
{person.name}
1313
</Link>
1414
</li>
1515
)

examples/auth0/components/header.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,30 @@ const Header = ({ user, loading }: HeaderProps) => {
1111
<nav>
1212
<ul>
1313
<li>
14-
<Link href="/">
14+
<Link href="/" legacyBehavior>
1515
<a>Home</a>
1616
</Link>
1717
</li>
1818
<li>
19-
<Link href="/about">
19+
<Link href="/about" legacyBehavior>
2020
<a>About</a>
2121
</Link>
2222
</li>
2323
<li>
24-
<Link href="/advanced/api-profile">
24+
<Link href="/advanced/api-profile" legacyBehavior>
2525
<a>API rendered profile (advanced)</a>
2626
</Link>
2727
</li>
2828
{!loading &&
2929
(user ? (
3030
<>
3131
<li>
32-
<Link href="/profile">
32+
<Link href="/profile" legacyBehavior>
3333
<a>Client rendered profile</a>
3434
</Link>
3535
</li>
3636
<li>
37-
<Link href="/advanced/ssr-profile">
37+
<Link href="/advanced/ssr-profile" legacyBehavior>
3838
<a>Server rendered profile (advanced)</a>
3939
</Link>
4040
</li>

examples/basic-export/pages/index.tsx

+1-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ import Link from 'next/link'
33
const Home = () => {
44
return (
55
<div>
6-
Hello World.{' '}
7-
<Link href="/about">
8-
<a>About</a>
9-
</Link>
6+
Hello World. <Link href="/about">About</Link>
107
</div>
118
)
129
}

examples/blog-starter/components/cover-image.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ const CoverImage = ({ title, src, slug }: Props) => {
2020
return (
2121
<div className="sm:mx-0">
2222
{slug ? (
23-
<Link as={`/posts/${slug}`} href="/posts/[slug]">
24-
<a aria-label={title}>{image}</a>
23+
<Link as={`/posts/${slug}`} href="/posts/[slug]" aria-label={title}>
24+
{image}
2525
</Link>
2626
) : (
2727
image

examples/blog-starter/components/header.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import Link from 'next/link'
33
const Header = () => {
44
return (
55
<h2 className="text-2xl md:text-4xl font-bold tracking-tight md:tracking-tighter leading-tight mb-20 mt-8">
6-
<Link href="/">
7-
<a className="hover:underline">Blog</a>
6+
<Link href="/" className="hover:underline">
7+
Blog
88
</Link>
99
.
1010
</h2>

examples/blog-starter/components/hero-post.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@ const HeroPost = ({
2929
<div className="md:grid md:grid-cols-2 md:gap-x-16 lg:gap-x-8 mb-20 md:mb-28">
3030
<div>
3131
<h3 className="mb-4 text-4xl lg:text-5xl leading-tight">
32-
<Link as={`/posts/${slug}`} href="/posts/[slug]">
33-
<a className="hover:underline">{title}</a>
32+
<Link
33+
as={`/posts/${slug}`}
34+
href="/posts/[slug]"
35+
className="hover:underline"
36+
>
37+
{title}
3438
</Link>
3539
</h3>
3640
<div className="mb-4 md:mb-0 text-lg">

examples/blog-starter/components/post-preview.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,12 @@ const PostPreview = ({
2727
<CoverImage slug={slug} title={title} src={coverImage} />
2828
</div>
2929
<h3 className="text-3xl mb-3 leading-snug">
30-
<Link as={`/posts/${slug}`} href="/posts/[slug]">
31-
<a className="hover:underline">{title}</a>
30+
<Link
31+
as={`/posts/${slug}`}
32+
href="/posts/[slug]"
33+
className="hover:underline"
34+
>
35+
{title}
3236
</Link>
3337
</h3>
3438
<div className="text-lg mb-4">

examples/blog-with-comment/pages/posts/index.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@ export default function NotePage({
1212
{allPosts.length ? (
1313
allPosts.map((post) => (
1414
<article key={post.slug} className="mb-10">
15-
<Link as={`/posts/${post.slug}`} href="/posts/[slug]">
16-
<a className="text-lg leading-6 font-bold">{post.title}</a>
15+
<Link
16+
as={`/posts/${post.slug}`}
17+
href="/posts/[slug]"
18+
className="text-lg leading-6 font-bold"
19+
>
20+
{post.title}
1721
</Link>
1822
<p>{post.excerpt}</p>
1923
<div className="text-gray-400">

examples/cms-agilitycms/components/cover-image.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ export default function CoverImage({ title, responsiveImage, slug = null }) {
1616
return (
1717
<div className="sm:mx-0">
1818
{slug ? (
19-
<Link href={`/posts/${slug}`}>
20-
<a aria-label={title}>{image}</a>
19+
<Link href={`/posts/${slug}`} aria-label={title}>
20+
{image}
2121
</Link>
2222
) : (
2323
image

examples/cms-agilitycms/components/header.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import Link from 'next/link'
33
export default function Header() {
44
return (
55
<h2 className="text-2xl md:text-4xl font-bold tracking-tight md:tracking-tighter leading-tight mb-20 mt-8">
6-
<Link href="/">
7-
<a className="hover:underline">Blog</a>
6+
<Link href="/" className="hover:underline">
7+
Blog
88
</Link>
99
.
1010
</h2>

examples/cms-agilitycms/components/hero-post.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ export default function HeroPost({
2323
<div className="md:grid md:grid-cols-2 md:gap-x-16 lg:gap-x-8 mb-20 md:mb-28">
2424
<div>
2525
<h3 className="mb-4 text-4xl lg:text-6xl leading-tight">
26-
<Link href={`/posts/${slug}`}>
27-
<a className="hover:underline">{title}</a>
26+
<Link href={`/posts/${slug}`} className="hover:underline">
27+
{title}
2828
</Link>
2929
</h3>
3030
<div className="mb-4 md:mb-0 text-lg">

examples/cms-agilitycms/components/post-preview.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ export default function PostPreview({
2121
/>
2222
</div>
2323
<h3 className="text-3xl mb-3 leading-snug">
24-
<Link href={`/posts/${slug}`}>
25-
<a className="hover:underline">{title}</a>
24+
<Link href={`/posts/${slug}`} className="hover:underline">
25+
{title}
2626
</Link>
2727
</h3>
2828
<div className="text-lg mb-4">

examples/cms-builder-io/components/cover-image.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ export default function CoverImage({ title, url, slug }) {
1818
return (
1919
<div className="sm:mx-0">
2020
{slug ? (
21-
<Link href={`/posts/${slug}`}>
22-
<a aria-label={title}>{image}</a>
21+
<Link href={`/posts/${slug}`} aria-label={title}>
22+
{image}
2323
</Link>
2424
) : (
2525
image

examples/cms-builder-io/components/header.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import Link from 'next/link'
33
export default function Header() {
44
return (
55
<h2 className="text-2xl md:text-4xl font-bold tracking-tight md:tracking-tighter leading-tight mb-20 mt-8">
6-
<Link href="/">
7-
<a className="hover:underline">Blog</a>
6+
<Link href="/" className="hover:underline">
7+
Blog
88
</Link>
99
.
1010
</h2>

examples/cms-builder-io/components/hero-post.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ export default function HeroPost({
1919
<div className="md:grid md:grid-cols-2 md:gap-x-16 lg:gap-x-8 mb-20 md:mb-28">
2020
<div>
2121
<h3 className="mb-4 text-4xl lg:text-6xl leading-tight">
22-
<Link href={`/posts/${slug}`}>
23-
<a className="hover:underline">{title}</a>
22+
<Link href={`/posts/${slug}`} className="hover:underline">
23+
{title}
2424
</Link>
2525
</h3>
2626
<div className="mb-4 md:mb-0 text-lg">

examples/cms-builder-io/components/post-preview.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ export default function PostPreview({
1717
<CoverImage title={title} slug={slug} url={coverImage} />
1818
</div>
1919
<h3 className="text-3xl mb-3 leading-snug">
20-
<Link href={`/posts/${slug}`}>
21-
<a className="hover:underline">{title}</a>
20+
<Link href={`/posts/${slug}`} className="hover:underline">
21+
{title}
2222
</Link>
2323
</h3>
2424
<div className="text-lg mb-4">

examples/cms-buttercms/components/blog/blog.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ export default function Blog({ posts }) {
1515
simple to launch a new company blog.
1616
</p>
1717
<p>
18-
<Link href={`/blog`}>
19-
<a className="main-btn btn-hover mt-5">View All Blog Posts</a>
18+
<Link href={`/blog`} className="main-btn btn-hover mt-5">
19+
View All Blog Posts
2020
</Link>
2121
</p>
2222
</div>

examples/cms-buttercms/components/blog/categories-widget.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default function CategoriesWidget({ categories }) {
88
{categories.map((category) => (
99
<li key={category.slug}>
1010
<Link href={`/blog/category/${category.slug}`}>
11-
<a>{category.name}</a>
11+
{category.name}
1212
</Link>
1313
</li>
1414
))}

examples/cms-buttercms/components/blog/post-preview-condensed.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,13 @@ export default function PostPreviewCondensed({
2323
)}
2424
<div className="blog-body">
2525
<h5 className="package-name">
26-
<Link href={`/blog/${slug}`}>
27-
<a>{title}</a>
28-
</Link>
26+
<Link href={`/blog/${slug}`}>{title}</Link>
2927
</h5>
3028
<p>{excerpt}</p>
3129
</div>
3230
<div className="blog-footer">
33-
<Link href={`/blog/${slug}`}>
34-
<a className="main-btn btn-hover">Read More</a>
31+
<Link href={`/blog/${slug}`} className="main-btn btn-hover">
32+
Read More
3533
</Link>
3634
</div>
3735
</div>

examples/cms-buttercms/components/blog/post-preview.js

+4-8
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ export default function PostsPreview({
1919
<div className="blog-roll-card">
2020
<div className="blog-roll-card-meta">
2121
<h2 className="blog-roll-card-header">
22-
<Link href={`/blog/${slug}`}>
23-
<a>{title}</a>
24-
</Link>
22+
<Link href={`/blog/${slug}`}>{title}</Link>
2523
</h2>
2624
<ul className="blog-roll-card-meta-info">
2725
<li>
@@ -34,9 +32,7 @@ export default function PostsPreview({
3432
{tags.map((tag) => (
3533
<li key={tag.slug}>
3634
<Link href={`/blog/tag/${tag.slug}`}>
37-
<a>
38-
<i className="lni lni-tag"></i> {tag.name}
39-
</a>
35+
<i className="lni lni-tag"></i> {tag.name}
4036
</Link>
4137
</li>
4238
))}
@@ -57,8 +53,8 @@ export default function PostsPreview({
5753
dangerouslySetInnerHTML={{ __html: excerpt }}
5854
></div>
5955
<div className="blog-roll-card-footer text-center">
60-
<Link href={`/blog/${slug}`}>
61-
<a className="main-btn btn-hover">Read More</a>
56+
<Link href={`/blog/${slug}`} className="main-btn btn-hover">
57+
Read More
6258
</Link>
6359
</div>
6460
</div>

0 commit comments

Comments
 (0)