diff --git a/.changeset/shiny-gifts-juggle.md b/.changeset/shiny-gifts-juggle.md new file mode 100644 index 0000000000..b1d2895686 --- /dev/null +++ b/.changeset/shiny-gifts-juggle.md @@ -0,0 +1,5 @@ +--- +'nextra': patch +--- + +always use `next/image`, since in next 12.3.2 `next/future/image` was renamed to `next/image` diff --git a/packages/nextra/src/compile.ts b/packages/nextra/src/compile.ts index ee52ff1261..091fb963ec 100644 --- a/packages/nextra/src/compile.ts +++ b/packages/nextra/src/compile.ts @@ -48,7 +48,6 @@ export async function compileMdx( | 'unstable_flexsearch' | 'unstable_defaultShowCopyCode' | 'unstable_readingTime' - | 'allowFutureImage' > & { mdxOptions?: LoaderOptions['mdxOptions'] & Pick @@ -67,10 +66,8 @@ export async function compileMdx( ...(mdxOptions.remarkPlugins || []), remarkGfm, remarkHeadings, - loaderOptions.unstable_staticImage && [ - remarkStaticImage, - { allowFutureImage: loaderOptions.allowFutureImage, filePath } - ] as any, + loaderOptions.unstable_staticImage && + ([remarkStaticImage, { filePath }] as any), loaderOptions.unstable_flexsearch && structurize(structurizedData, loaderOptions.unstable_flexsearch), loaderOptions.unstable_readingTime && readingTime diff --git a/packages/nextra/src/index.js b/packages/nextra/src/index.js index a972ab6dd5..33a5f57b05 100644 --- a/packages/nextra/src/index.js +++ b/packages/nextra/src/index.js @@ -1,4 +1,3 @@ -import next from 'next/package.json' import { NextraPlugin, pageMapCache } from './plugin' import { DEFAULT_LOCALE, @@ -8,10 +7,6 @@ import { const DEFAULT_EXTENSIONS = ['js', 'jsx', 'ts', 'tsx'] -const [major, minor] = next.version.split('.').map(Number) -const nextVersion = major + (0.1 * minor) -const hasFutureImage = nextVersion >= 12.3 - const nextra = (...config) => function withNextra(nextConfig = {}) { const nextraConfig = @@ -46,7 +41,6 @@ const nextra = (...config) => defaultLocale: nextConfig.i18n?.defaultLocale || DEFAULT_LOCALE, pageMapCache, newNextLinkBehavior: nextConfig.experimental?.newNextLinkBehavior, - allowFutureImage: hasFutureImage } config.module.rules.push( diff --git a/packages/nextra/src/loader.ts b/packages/nextra/src/loader.ts index e8b4297215..b39d6f6877 100644 --- a/packages/nextra/src/loader.ts +++ b/packages/nextra/src/loader.ts @@ -72,7 +72,6 @@ async function loader( mdxOptions, pageMapCache, newNextLinkBehavior, - allowFutureImage } = context.getOptions() context.cacheable(true) @@ -128,7 +127,6 @@ async function loader( unstable_defaultShowCopyCode, unstable_staticImage, unstable_flexsearch, - allowFutureImage }, mdxPath ) diff --git a/packages/nextra/src/mdx-plugins/static-image.ts b/packages/nextra/src/mdx-plugins/static-image.ts index 0e3d84123f..2c03409e46 100644 --- a/packages/nextra/src/mdx-plugins/static-image.ts +++ b/packages/nextra/src/mdx-plugins/static-image.ts @@ -35,11 +35,8 @@ const getASTNodeImport = (name: string, from: string) => ({ // Based on the remark-embed-images project // https://github.com/remarkjs/remark-embed-images -export const remarkStaticImage: Plugin< - [{ allowFutureImage?: boolean; filePath: string }], - Root -> = - ({ allowFutureImage, filePath }) => +export const remarkStaticImage: Plugin<[{ filePath: string }], Root> = + ({ filePath }) => (tree, _file, done) => { const importsToInject: any[] = [] @@ -118,10 +115,7 @@ export const remarkStaticImage: Plugin< }) tree.children.unshift( - getASTNodeImport( - '$NextImageNextra', - allowFutureImage ? 'next/future/image' : 'next/image' - ) as any, + getASTNodeImport('$NextImageNextra', 'next/image') as any, ...importsToInject ) done() diff --git a/packages/nextra/src/types.ts b/packages/nextra/src/types.ts index 3e1c5c140e..e930d20373 100644 --- a/packages/nextra/src/types.ts +++ b/packages/nextra/src/types.ts @@ -15,7 +15,6 @@ export interface LoaderOptions extends NextraConfig { defaultLocale: string pageMapCache: PageMapCache newNextLinkBehavior?: boolean - allowFutureImage?: boolean } export interface Folder {