Skip to content
Open
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
21 changes: 9 additions & 12 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -59,25 +59,22 @@ module.exports = {
"@next/next/no-img-element": "off", // straight up upsell, small `img`s actually don't need optimization

"tailwindcss/classnames-order": "off",
"@typescript-eslint/no-restricted-imports": [
"error",
{
paths: [
{
name: "next/image",
message: "Please use `next-image-export-optimizer` instead",
allowTypeImports: true,
},
],
},
],
"prefer-const": ["error", { destructuring: "all" }],
"prefer-rest-params": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/ban-types": "off",
"no-restricted-syntax": [
"error",
{
selector:
"JSXElement[openingElement.name.name=/^(Image|NextImage)$/]:not(:has(JSXAttribute[name.name='placeholder']))",
message:
"Pass `placeholder: 'empty' | 'blur'` when calling <Image> or <NextImage>.",
},
],
},
settings: {
tailwindcss: {
Expand Down
29 changes: 10 additions & 19 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import withLess from "next-with-less"
import nextBundleAnalyzer from "@next/bundle-analyzer"
import fs from "fs"
import rehypeMermaid from "rehype-mermaid"
import withPlaiceholder from "@plaiceholder/next"

import { remarkGraphiQLComment } from "./src/remark-graphiql-comment.js"
import { syntaxHighlightingThemes } from "./src/_design-system/syntax/index.js"
Expand Down Expand Up @@ -109,27 +110,15 @@ const config = {

return config
},
// Comment this out if you're working on OG images.
output: "export",
images: {
loader: "custom",
imageSizes: [16, 32, 48, 64, 96, 128, 256, 384],
deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
remotePatterns: [
{
hostname: "avatars.sched.co",
pathname: "**",
},
],
},
transpilePackages: ["next-image-export-optimizer"],
env: {
nextImageExportOptimizer_imageFolderPath: "public/images",
nextImageExportOptimizer_exportFolderPath: "out",
nextImageExportOptimizer_quality: "75",
nextImageExportOptimizer_storePicturesInWEBP: "true",
nextImageExportOptimizer_exportFolderName: "nextImageExportOptimizer",
// If you do not want to use blurry placeholder images, then you can set
// nextImageExportOptimizer_generateAndUseBlurImages to false and pass
// `placeholder="empty"` to all <ExportedImage> components.
nextImageExportOptimizer_generateAndUseBlurImages: "true",
// If you want to cache the remote images, you can set the time to live of the cache in seconds.
// The default value is 0 seconds.
nextImageExportOptimizer_remoteImageCacheTTL: "0",
NEXT_PUBLIC_GA_ID:
process.env.NODE_ENV === "production" ? "UA-44373548-16" : "",
},
Expand Down Expand Up @@ -179,7 +168,9 @@ const withBundleAnalyzer = nextBundleAnalyzer({
enabled: process.env.ANALYZE === "true",
})

export default withBundleAnalyzer(withLess(withNextra(config)))
export default withBundleAnalyzer(
withLess(withNextra(withPlaiceholder(config))),
)

function mermaidConfig() {
return [
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"packageManager": "[email protected]+sha512.0e155aa2629db8672b49e8475da6226aa4bdea85fdcdfdc15350874946d4f3c91faaf64cbdc4a5d1ab8002f473d5c3fcedcd197989cf0390f9badd3c04678706",
"scripts": {
"analyze": "ANALYZE=true next build",
"build": "next build && next-image-export-optimizer",
"build": "next build",
"check:links": "lychee --verbose --no-progress './src/pages/**/*.mdx' --base https://graphql.org",
"dev": "next",
"format": "pnpm format:check --write",
Expand All @@ -16,7 +16,7 @@
"lint:docs:ci": "eslint --ignore-path .gitignore src/pages/learn --format eslint-formatter-github",
"postbuild": "next-sitemap",
"prebuild": "tsx scripts/get-github-info",
"serve": "pnpx serve out",
"start": "next start",
"test": "playwright test && pnpm test:unit",
"test:e2e": "playwright test",
"test:ui": "playwright test --ui",
Expand All @@ -36,6 +36,7 @@
"@igorkowalczyk/is-browser": "^5.1.0",
"@lezer/highlight": "^1.2.1",
"@next/bundle-analyzer": "^15.4.5",
"@plaiceholder/next": "^3.0.0",
"@radix-ui/react-radio-group": "^1.2.2",
"@sparticuz/chromium": "^138.0.2",
"@tailwindcss/container-queries": "^0.1.1",
Expand All @@ -57,7 +58,6 @@
"markdown-to-jsx": "^7.7.2",
"motion": "^12.11.0",
"next": "^14.2.32",
"next-image-export-optimizer": "^1.18.0",
"next-query-params": "^5.0.1",
"next-sitemap": "^4.2.3",
"next-with-less": "^3.0.1",
Expand All @@ -66,6 +66,7 @@
"numbro": "2.5.0",
"p-limit": "^4.0.0",
"parser-front-matter": "1.6.4",
"plaiceholder": "^3.0.0",
"playwright-core": "^1.54.2",
"postcss": "^8.4.49",
"postcss-import": "^16.1.1",
Expand Down
2 changes: 1 addition & 1 deletion patches/nextra.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ index 239d72f5921e2d1b7359e569ae5b74c12d7c9d8a..ebeb619da1e3ccb7722e9388c92c1e21
@@ -1,5 +1,5 @@
import { jsx } from "react/jsx-runtime";
-import NextImage from "next/image";
+import NextImage from "next-image-export-optimizer";
+import NextImage from "next/image"; // :)
import { forwardRef } from "react";
const Image = forwardRef((props, ref) => {
const ComponentToUse = typeof props.src === "object" ? NextImage : "img";
Expand Down
Loading