depot/web/lukegbcom/lib/images.js

16 lines
392 B
JavaScript
Raw Normal View History

2022-04-05 02:18:57 +00:00
import { useRouter } from 'next/router'
export function resolveImageURL(specifiedURL, currentURL) {
if (!currentURL) {
const router = useRouter()
currentURL = router.asPath
}
if (specifiedURL.length > 0 && (specifiedURL.charAt(0) === '/' || specifiedURL.indexOf('//') !== -1)) {
return specifiedURL
}
return require(`../public/assets${currentURL}${specifiedURL}`)
}