Skip to content

Commit

Permalink
Merge pull request #174 from Niels-IO/packageUpdate2
Browse files Browse the repository at this point in the history
Upgrade to latest Next version and move src files
  • Loading branch information
Niels-IO authored Oct 14, 2023
2 parents a6c9b9f + 0276160 commit f872be4
Show file tree
Hide file tree
Showing 24 changed files with 1,921 additions and 1,723 deletions.
4 changes: 2 additions & 2 deletions example/app/appdir/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import styles from "../../styles/Home.module.css";
import ExportedImage from "../../../src/ExportedImage";
import ExportedImageLegacy from "../../../src/legacy/ExportedImage";
import ExportedImage from "../../src/ExportedImage";
import ExportedImageLegacy from "../../src/legacy/ExportedImage";
import testPictureStatic from "../../public/chris-zhang-Jq8-3Bmh1pQ-unsplash_static.jpg";

export default function Home() {
Expand Down
4 changes: 1 addition & 3 deletions example/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports = {
imageSizes: [16, 32, 48, 64, 96, 128, 256, 384],
deviceSizes: [640, 750, 777, 828, 1080, 1200, 1920, 2048, 3840],
},
basePath: "/subsite",
output: "export",
transpilePackages: ["next-image-export-optimizer"],
env: {
Expand All @@ -14,7 +15,4 @@ module.exports = {
nextImageExportOptimizer_storePicturesInWEBP: true,
nextImageExportOptimizer_generateAndUseBlurImages: true,
},
experimental: {
appDir: true,
},
};
1,484 changes: 639 additions & 845 deletions example/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"dependencies": {
"next": "^13.3.1",
"next-image-export-optimizer": "^1.8.1-beta.0",
"next-image-export-optimizer": "^1.8.5",
"react": "^18.0.0",
"react-dom": "^18.0.0"
},
Expand Down
4 changes: 2 additions & 2 deletions example/pages/fixedImage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Head from "next/head";
import ExportedImageLegacy from "../../src/legacy/ExportedImage";
import ExportedImage from "../../src/ExportedImage";
import ExportedImageLegacy from "../src/legacy/ExportedImage";
import ExportedImage from "../src/ExportedImage";
// import ExportedImage from "next-image-export-optimizer";

import styles from "../styles/Home.module.css";
Expand Down
2 changes: 1 addition & 1 deletion example/pages/forwardRef.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Head from "next/head";
import ExportedImage from "../../src/ExportedImage";
import ExportedImage from "../src/ExportedImage";

import styles from "../styles/Home.module.css";
import { useEffect, useRef, useState } from "react";
Expand Down
2 changes: 1 addition & 1 deletion example/pages/gifs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Head from "next/head";
import ExportedImage from "../../src/ExportedImage";
import ExportedImage from "../src/ExportedImage";

import styles from "../styles/Home.module.css";
import animatedImage from "../public/animated.png";
Expand Down
4 changes: 2 additions & 2 deletions example/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Head from "next/head";
import ExportedImageLegacy from "../../src/legacy/ExportedImage";
import ExportedImageLegacy from "../src/legacy/ExportedImage";
// import ExportedImageLegacy from "next-image-export-optimizer/legacy/ExportedImage";
// import ExportedImage from "next-image-export-optimizer";
import ExportedImage from "../../src/ExportedImage";
import ExportedImage from "../src/ExportedImage";

import styles from "../styles/Home.module.css";
import testPictureStatic from "../public/chris-zhang-Jq8-3Bmh1pQ-unsplash_static.jpg";
Expand Down
4 changes: 2 additions & 2 deletions example/pages/nested/page.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import ExportedImage from "../../../src/ExportedImage";
import ExportedImageLegacy from "../../../src/legacy/ExportedImage";
import ExportedImage from "../../src/ExportedImage";
import ExportedImageLegacy from "../../src/legacy/ExportedImage";
import testPictureStatic from "../../public/chris-zhang-Jq8-3Bmh1pQ-unsplash_static.jpg";

function Page() {
Expand Down
4 changes: 2 additions & 2 deletions example/pages/nested/page_fixed.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import ExportedImage from "../../../src/ExportedImage";
import ExportedImageLegacy from "../../../src/legacy/ExportedImage";
import ExportedImage from "../../src/ExportedImage";
import ExportedImageLegacy from "../../src/legacy/ExportedImage";
import testPictureStatic from "../../public/chris-zhang-Jq8-3Bmh1pQ-unsplash_static.jpg";

function Page() {
Expand Down
4 changes: 2 additions & 2 deletions example/pages/nestedSlug/[slug].js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import ExportedImage from "../../../src/ExportedImage";
import ExportedImageLegacy from "../../../src/legacy/ExportedImage";
import ExportedImage from "../../src/ExportedImage";
import ExportedImageLegacy from "../../src/legacy/ExportedImage";
import testPictureStatic from "../../public/chris-zhang-Jq8-3Bmh1pQ-unsplash_static.jpg";

function Slug() {
Expand Down
2 changes: 1 addition & 1 deletion example/pages/remote.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Head from "next/head";
import ExportedImage from "../../src/ExportedImage";
import ExportedImage from "../src/ExportedImage";

import styles from "../styles/Home.module.css";

Expand Down
4 changes: 2 additions & 2 deletions example/pages/smallImage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Head from "next/head";
import ExportedImageLegacy from "../../src/legacy/ExportedImage";
import ExportedImage from "../../src/ExportedImage";
import ExportedImageLegacy from "../src/legacy/ExportedImage";
import ExportedImage from "../src/ExportedImage";

import smallImage from "../public/images/chris-zhang-Jq8-3Bmh1pQ-unsplash_small.jpg";

Expand Down
2 changes: 1 addition & 1 deletion example/pages/subfolder.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ExportedImageLegacy from "../../src/legacy/ExportedImage";
import ExportedImageLegacy from "../src/legacy/ExportedImage";
import Head from "next/head";
import React from "react";
import styles from "../styles/Home.module.css";
Expand Down
2 changes: 1 addition & 1 deletion example/pages/transparent.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Head from "next/head";
import ExportedImage from "../../src/ExportedImage";
import ExportedImage from "../src/ExportedImage";

import styles from "../styles/Home.module.css";

Expand Down
4 changes: 2 additions & 2 deletions example/pages/typescript.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Head from "next/head";
import ExportedImage_Local from "../../src/ExportedImage";
import ExportedImageLegacy_Local from "../../src/legacy/ExportedImage";
import ExportedImage_Local from "../src/ExportedImage";
import ExportedImageLegacy_Local from "../src/legacy/ExportedImage";
import ExportedImage from "next-image-export-optimizer";
import ExportedImageLegacy from "next-image-export-optimizer/legacy/ExportedImage";

Expand Down
7 changes: 5 additions & 2 deletions src/ExportedImage.tsx → example/src/ExportedImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ function urlToFilename(url: string) {
filename = filename.replace(/[/\\:*?"<>|#%]/g, "_");

// Remove control characters
// eslint-disable-next-line no-control-regex
filename = filename.replace(/[\x00-\x1F\x7F]/g, "");

// Trim any leading or trailing spaces
Expand Down Expand Up @@ -204,6 +205,7 @@ const ExportedImage = forwardRef<HTMLImageElement | null, ExportedImageProps>(
unoptimized,
placeholder = "blur",
basePath = "",
alt = "",
blurDataURL,
style,
onError,
Expand Down Expand Up @@ -232,7 +234,7 @@ const ExportedImage = forwardRef<HTMLImageElement | null, ExportedImageProps>(

// otherwise use the generated image of 10px width as a blurDataURL
return generateImageURL(_src, 10, basePath);
}, [blurDataURL, src, unoptimized]);
}, [blurDataURL, src, unoptimized, basePath]);

// check if the src is a SVG image -> then we should not use the blurDataURL and use unoptimized
const isSVG =
Expand Down Expand Up @@ -268,6 +270,7 @@ const ExportedImage = forwardRef<HTMLImageElement | null, ExportedImageProps>(
const ImageElement = (
<Image
ref={ref}
alt={alt}
{...rest}
{...(width && { width })}
{...(height && { height })}
Expand Down Expand Up @@ -358,5 +361,5 @@ const ExportedImage = forwardRef<HTMLImageElement | null, ExportedImageProps>(
);
}
);

ExportedImage.displayName = "ExportedImage";
export default ExportedImage;
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ function urlToFilename(url: string) {
filename = filename.replace(/[/\\:*?"<>|#%]/g, "_");

// Remove control characters
// eslint-disable-next-line no-control-regex
filename = filename.replace(/[\x00-\x1F\x7F]/g, "");

// Trim any leading or trailing spaces
Expand Down Expand Up @@ -199,6 +200,7 @@ function ExportedImage({
objectPosition,
onLoadingComplete,
unoptimized,
alt = "",
placeholder = "blur",
basePath = "",
blurDataURL,
Expand Down Expand Up @@ -235,7 +237,7 @@ function ExportedImage({

// otherwise use the generated image of 10px width as a blurDataURL
return generateImageURL(_src, 10, basePath);
}, [blurDataURL, src, unoptimized]);
}, [blurDataURL, src, unoptimized, basePath]);
const isStaticImage = typeof src === "object";
let _src = isStaticImage ? src.src : src;
if (!isStaticImage) {
Expand All @@ -250,6 +252,7 @@ function ExportedImage({
return (
<Image
{...rest}
alt={alt}
{...(typeof src === "object" && src.width && { width: src.width })}
{...(typeof src === "object" && src.height && { height: src.height })}
{...(width && { width })}
Expand Down
Loading

0 comments on commit f872be4

Please sign in to comment.