Update components/image-with-basepath.tsx

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
十八亩地
2026-01-28 23:33:44 +08:00
committed by dayuan.jiang
parent 8a93d4ea9f
commit 7662b00bb3

View File

@@ -1,11 +1,11 @@
import NextImage from "next/image"
import type * as React from "react"
import { getAssetUrl } from "../lib/base-path"
export default function Image(props: React.ComponentProps<typeof NextImage>) {
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || ""
const src =
typeof props.src === "string" && !props.src.startsWith("http")
? `${basePath}${props.src}`
? getAssetUrl(props.src)
: props.src
return <NextImage {...props} src={src} />