Skip to content

Commit

Permalink
Run next/link codemod for Next.js 13 on examples (#41913)
Browse files Browse the repository at this point in the history
  • Loading branch information
timneutkens authored Oct 30, 2022
1 parent 8ada894 commit ab42da0
Show file tree
Hide file tree
Showing 273 changed files with 753 additions and 1,028 deletions.
2 changes: 1 addition & 1 deletion examples/active-class-name/components/ActiveLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const ActiveLink = ({
])

return (
<Link {...props}>
<Link {...props} legacyBehavior>
{React.cloneElement(child, {
className: className || null,
})}
Expand Down
4 changes: 1 addition & 3 deletions examples/analyze-bundles/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ const Index: NextPage<IndexProps> = ({ name }) => {
<h1>Home Page</h1>
<p>Welcome, {name}</p>
<div>
<Link href="/about">
<a>About Page</a>
</Link>
<Link href="/about">About Page</Link>
</div>
</div>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ import Link from 'next/link'
export default function About() {
return (
<div>
Welcome to the about page. Go to the{' '}
<Link href="/">
<a>Home</a>
</Link>{' '}
page.
Welcome to the about page. Go to the <Link href="/">Home</Link> page.
</div>
)
}
10 changes: 2 additions & 8 deletions examples/api-routes-apollo-server-and-client-auth/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,8 @@ const Index = () => {
if (viewer) {
return (
<div>
You're signed in as {viewer.email} goto{' '}
<Link href="/about">
<a>about</a>
</Link>{' '}
page. or{' '}
<Link href="/signout">
<a>signout</a>
</Link>
You're signed in as {viewer.email} goto <Link href="/about">about</Link>{' '}
page. or <Link href="/signout">signout</Link>
</div>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ function SignIn() {
label="Password"
/>
<button type="submit">Sign in</button> or{' '}
<Link href="/signup">
<a>Sign up</a>
</Link>
<Link href="/signup">Sign up</Link>
</form>
</>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ function SignUp() {
label="Password"
/>
<button type="submit">Sign up</button> or{' '}
<Link href="/signin">
<a>Sign in</a>
</Link>
<Link href="/signin">Sign in</Link>
</form>
</>
)
Expand Down
6 changes: 1 addition & 5 deletions examples/api-routes-apollo-server-and-client/pages/about.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ import Link from 'next/link'
export default function About() {
return (
<div>
This is a static page goto{' '}
<Link href="/">
<a>dynamic</a>
</Link>{' '}
page.
This is a static page goto <Link href="/">dynamic</Link> page.
</div>
)
}
5 changes: 1 addition & 4 deletions examples/api-routes-apollo-server-and-client/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ const Index = () => {
return (
<div>
You're signed in as {viewer.name} and you're {viewer.status} goto{' '}
<Link href="/about">
<a>static</a>
</Link>{' '}
page.
<Link href="/about">static</Link> page.
</div>
)
}
Expand Down
2 changes: 1 addition & 1 deletion examples/api-routes-apollo-server/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function UserListing({ users }) {
{users.map((user) => (
<li key={user.username}>
<Link href="/[username]" as={`/${user.username}`}>
<a>{user.name}</a>
{user.name}
</Link>
</li>
))}
Expand Down
2 changes: 1 addition & 1 deletion examples/api-routes-rest/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function Index() {
<ul>
{data.map((user) => (
<li key={user.id}>
<Link href="/user/[id]" as={`/user/${user.id}`}>
<Link href="/user/[id]" as={`/user/${user.id}`} legacyBehavior>
{`User ${user.id}`}
</Link>
</li>
Expand Down
2 changes: 1 addition & 1 deletion examples/api-routes/components/Person.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function PersonComponent({ person }: PersonProps) {
return (
<li>
<Link href="/person/[id]" as={`/person/${person.id}`}>
<a>{person.name}</a>
{person.name}
</Link>
</li>
)
Expand Down
10 changes: 5 additions & 5 deletions examples/auth0/components/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,30 @@ const Header = ({ user, loading }: HeaderProps) => {
<nav>
<ul>
<li>
<Link href="/">
<Link href="/" legacyBehavior>
<a>Home</a>
</Link>
</li>
<li>
<Link href="/about">
<Link href="/about" legacyBehavior>
<a>About</a>
</Link>
</li>
<li>
<Link href="/advanced/api-profile">
<Link href="/advanced/api-profile" legacyBehavior>
<a>API rendered profile (advanced)</a>
</Link>
</li>
{!loading &&
(user ? (
<>
<li>
<Link href="/profile">
<Link href="/profile" legacyBehavior>
<a>Client rendered profile</a>
</Link>
</li>
<li>
<Link href="/advanced/ssr-profile">
<Link href="/advanced/ssr-profile" legacyBehavior>
<a>Server rendered profile (advanced)</a>
</Link>
</li>
Expand Down
5 changes: 1 addition & 4 deletions examples/basic-export/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ import Link from 'next/link'
const Home = () => {
return (
<div>
Hello World.{' '}
<Link href="/about">
<a>About</a>
</Link>
Hello World. <Link href="/about">About</Link>
</div>
)
}
Expand Down
4 changes: 2 additions & 2 deletions examples/blog-starter/components/cover-image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ const CoverImage = ({ title, src, slug }: Props) => {
return (
<div className="sm:mx-0">
{slug ? (
<Link as={`/posts/${slug}`} href="/posts/[slug]">
<a aria-label={title}>{image}</a>
<Link as={`/posts/${slug}`} href="/posts/[slug]" aria-label={title}>
{image}
</Link>
) : (
image
Expand Down
4 changes: 2 additions & 2 deletions examples/blog-starter/components/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import Link from 'next/link'
const Header = () => {
return (
<h2 className="text-2xl md:text-4xl font-bold tracking-tight md:tracking-tighter leading-tight mb-20 mt-8">
<Link href="/">
<a className="hover:underline">Blog</a>
<Link href="/" className="hover:underline">
Blog
</Link>
.
</h2>
Expand Down
8 changes: 6 additions & 2 deletions examples/blog-starter/components/hero-post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@ const HeroPost = ({
<div className="md:grid md:grid-cols-2 md:gap-x-16 lg:gap-x-8 mb-20 md:mb-28">
<div>
<h3 className="mb-4 text-4xl lg:text-5xl leading-tight">
<Link as={`/posts/${slug}`} href="/posts/[slug]">
<a className="hover:underline">{title}</a>
<Link
as={`/posts/${slug}`}
href="/posts/[slug]"
className="hover:underline"
>
{title}
</Link>
</h3>
<div className="mb-4 md:mb-0 text-lg">
Expand Down
8 changes: 6 additions & 2 deletions examples/blog-starter/components/post-preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ const PostPreview = ({
<CoverImage slug={slug} title={title} src={coverImage} />
</div>
<h3 className="text-3xl mb-3 leading-snug">
<Link as={`/posts/${slug}`} href="/posts/[slug]">
<a className="hover:underline">{title}</a>
<Link
as={`/posts/${slug}`}
href="/posts/[slug]"
className="hover:underline"
>
{title}
</Link>
</h3>
<div className="text-lg mb-4">
Expand Down
8 changes: 6 additions & 2 deletions examples/blog-with-comment/pages/posts/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ export default function NotePage({
{allPosts.length ? (
allPosts.map((post) => (
<article key={post.slug} className="mb-10">
<Link as={`/posts/${post.slug}`} href="/posts/[slug]">
<a className="text-lg leading-6 font-bold">{post.title}</a>
<Link
as={`/posts/${post.slug}`}
href="/posts/[slug]"
className="text-lg leading-6 font-bold"
>
{post.title}
</Link>
<p>{post.excerpt}</p>
<div className="text-gray-400">
Expand Down
4 changes: 2 additions & 2 deletions examples/cms-agilitycms/components/cover-image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export default function CoverImage({ title, responsiveImage, slug = null }) {
return (
<div className="sm:mx-0">
{slug ? (
<Link href={`/posts/${slug}`}>
<a aria-label={title}>{image}</a>
<Link href={`/posts/${slug}`} aria-label={title}>
{image}
</Link>
) : (
image
Expand Down
4 changes: 2 additions & 2 deletions examples/cms-agilitycms/components/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import Link from 'next/link'
export default function Header() {
return (
<h2 className="text-2xl md:text-4xl font-bold tracking-tight md:tracking-tighter leading-tight mb-20 mt-8">
<Link href="/">
<a className="hover:underline">Blog</a>
<Link href="/" className="hover:underline">
Blog
</Link>
.
</h2>
Expand Down
4 changes: 2 additions & 2 deletions examples/cms-agilitycms/components/hero-post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export default function HeroPost({
<div className="md:grid md:grid-cols-2 md:gap-x-16 lg:gap-x-8 mb-20 md:mb-28">
<div>
<h3 className="mb-4 text-4xl lg:text-6xl leading-tight">
<Link href={`/posts/${slug}`}>
<a className="hover:underline">{title}</a>
<Link href={`/posts/${slug}`} className="hover:underline">
{title}
</Link>
</h3>
<div className="mb-4 md:mb-0 text-lg">
Expand Down
4 changes: 2 additions & 2 deletions examples/cms-agilitycms/components/post-preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export default function PostPreview({
/>
</div>
<h3 className="text-3xl mb-3 leading-snug">
<Link href={`/posts/${slug}`}>
<a className="hover:underline">{title}</a>
<Link href={`/posts/${slug}`} className="hover:underline">
{title}
</Link>
</h3>
<div className="text-lg mb-4">
Expand Down
4 changes: 2 additions & 2 deletions examples/cms-builder-io/components/cover-image.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export default function CoverImage({ title, url, slug }) {
return (
<div className="sm:mx-0">
{slug ? (
<Link href={`/posts/${slug}`}>
<a aria-label={title}>{image}</a>
<Link href={`/posts/${slug}`} aria-label={title}>
{image}
</Link>
) : (
image
Expand Down
4 changes: 2 additions & 2 deletions examples/cms-builder-io/components/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import Link from 'next/link'
export default function Header() {
return (
<h2 className="text-2xl md:text-4xl font-bold tracking-tight md:tracking-tighter leading-tight mb-20 mt-8">
<Link href="/">
<a className="hover:underline">Blog</a>
<Link href="/" className="hover:underline">
Blog
</Link>
.
</h2>
Expand Down
4 changes: 2 additions & 2 deletions examples/cms-builder-io/components/hero-post.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export default function HeroPost({
<div className="md:grid md:grid-cols-2 md:gap-x-16 lg:gap-x-8 mb-20 md:mb-28">
<div>
<h3 className="mb-4 text-4xl lg:text-6xl leading-tight">
<Link href={`/posts/${slug}`}>
<a className="hover:underline">{title}</a>
<Link href={`/posts/${slug}`} className="hover:underline">
{title}
</Link>
</h3>
<div className="mb-4 md:mb-0 text-lg">
Expand Down
4 changes: 2 additions & 2 deletions examples/cms-builder-io/components/post-preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export default function PostPreview({
<CoverImage title={title} slug={slug} url={coverImage} />
</div>
<h3 className="text-3xl mb-3 leading-snug">
<Link href={`/posts/${slug}`}>
<a className="hover:underline">{title}</a>
<Link href={`/posts/${slug}`} className="hover:underline">
{title}
</Link>
</h3>
<div className="text-lg mb-4">
Expand Down
4 changes: 2 additions & 2 deletions examples/cms-buttercms/components/blog/blog.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export default function Blog({ posts }) {
simple to launch a new company blog.
</p>
<p>
<Link href={`/blog`}>
<a className="main-btn btn-hover mt-5">View All Blog Posts</a>
<Link href={`/blog`} className="main-btn btn-hover mt-5">
View All Blog Posts
</Link>
</p>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default function CategoriesWidget({ categories }) {
{categories.map((category) => (
<li key={category.slug}>
<Link href={`/blog/category/${category.slug}`}>
<a>{category.name}</a>
{category.name}
</Link>
</li>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,13 @@ export default function PostPreviewCondensed({
)}
<div className="blog-body">
<h5 className="package-name">
<Link href={`/blog/${slug}`}>
<a>{title}</a>
</Link>
<Link href={`/blog/${slug}`}>{title}</Link>
</h5>
<p>{excerpt}</p>
</div>
<div className="blog-footer">
<Link href={`/blog/${slug}`}>
<a className="main-btn btn-hover">Read More</a>
<Link href={`/blog/${slug}`} className="main-btn btn-hover">
Read More
</Link>
</div>
</div>
Expand Down
12 changes: 4 additions & 8 deletions examples/cms-buttercms/components/blog/post-preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ export default function PostsPreview({
<div className="blog-roll-card">
<div className="blog-roll-card-meta">
<h2 className="blog-roll-card-header">
<Link href={`/blog/${slug}`}>
<a>{title}</a>
</Link>
<Link href={`/blog/${slug}`}>{title}</Link>
</h2>
<ul className="blog-roll-card-meta-info">
<li>
Expand All @@ -34,9 +32,7 @@ export default function PostsPreview({
{tags.map((tag) => (
<li key={tag.slug}>
<Link href={`/blog/tag/${tag.slug}`}>
<a>
<i className="lni lni-tag"></i> {tag.name}
</a>
<i className="lni lni-tag"></i> {tag.name}
</Link>
</li>
))}
Expand All @@ -57,8 +53,8 @@ export default function PostsPreview({
dangerouslySetInnerHTML={{ __html: excerpt }}
></div>
<div className="blog-roll-card-footer text-center">
<Link href={`/blog/${slug}`}>
<a className="main-btn btn-hover">Read More</a>
<Link href={`/blog/${slug}`} className="main-btn btn-hover">
Read More
</Link>
</div>
</div>
Expand Down
Loading

0 comments on commit ab42da0

Please sign in to comment.