这是indexloc提供的服务,不要输入任何密码
Skip to content

Use new future next image component and priority prop #1588

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cli/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
/turbo-new.exe
/turbo.exe

/scripts/turbo-*
4 changes: 1 addition & 3 deletions cli/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# turbo

turbo, a monorepo build system
# `turbo` CLI

Visit https://turborepo.org to view the full documentation.
10 changes: 6 additions & 4 deletions docs/components/clients/Client.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
import React from "react";
import Image from "next/image";
import Image from "next/future/image";

interface ClientProps {
name: string;
image: string;
className?: string;
theme: string;
priority: boolean;
style?: React.CSSProperties;
}

export const Client = React.memo<ClientProps>(
({ name, image, style, theme, ...rest }) => (
({ name, image, style, theme, priority, ...rest }) => (
<span title={name} {...rest}>
<Image
src={image.replace(
"/logos",
theme == "dark" ? "/logos/white" : "/logos/color"
)}
alt={name}
width={style?.width ?? style?.maxWidth ?? 100}
width={style?.width ?? 100}
height={style?.height ?? 75}
loading="lazy"
className="inline"
priority={priority}
style={{ width: "auto" }}
/>
</span>
)
Expand Down
24 changes: 13 additions & 11 deletions docs/components/pages/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,32 +82,34 @@ export default function Home() {
Trusted by teams from around the world
</p>

{prefersReducedMotion ? (
<div className="container grid grid-cols-4 gap-12 mx-auto sm:grid-cols-5 md:grid-cols-8">
{pinnedLogos.slice(0, 8).map(({ caption, image, style }) => (
{!prefersReducedMotion ? (
<Marquee>
{pinnedLogos.map(({ caption, infoLink, image, style }, index) => (
<Client
className="mx-auto text-center align-middle "
className="mx-8 align-middle opacity-75"
key={caption}
style={style}
name={caption}
theme={theme}
name={caption}
image={image}
priority={index < 9}
/>
))}
</div>
</Marquee>
) : (
<Marquee>
{pinnedLogos.map(({ caption, infoLink, image, style }) => (
<div className="container grid grid-cols-4 gap-12 mx-auto sm:grid-cols-5 md:grid-cols-8">
{pinnedLogos.slice(0, 8).map(({ caption, image, style }) => (
<Client
className="mx-8 align-middle opacity-75"
className="mx-auto text-center align-middle "
key={caption}
style={style}
theme={theme}
name={caption}
theme={theme}
image={image}
priority={true}
/>
))}
</Marquee>
</div>
)}
</div>
</div>
Expand Down
8 changes: 4 additions & 4 deletions docs/components/pages/showcase.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/* eslint-disable react/no-unescaped-entities */
import { useTheme } from "next-themes";
import Head from "next/head";
import Image from "next/image";
import Image from "next/future/image";
import { users } from "../clients/users";
import { Container } from "../Container";

export default function Showcase() {
const { theme } = useTheme();
const showcase = users.map((user) => (
const showcase = users.map((user, index) => (
<a
href={user.infoLink}
key={user.infoLink}
Expand All @@ -23,8 +23,8 @@ export default function Showcase() {
alt={user.caption}
width={user.style?.width ?? 100}
height={user.style?.height ?? 75}
loading="lazy"
className="inline"
priority={index < 24}
className="inline w-auto"
/>
</a>
));
Expand Down
5 changes: 3 additions & 2 deletions docs/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ const withNextra = require("nextra")({

module.exports = withNextra({
reactStrictMode: true,
experiments: {
esmExternals: true,
experimental: {
legacyBrowsers: false,
images: { allowFutureImage: true },
},
async redirects() {
return [
Expand Down
114 changes: 57 additions & 57 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.