15 lines
392 B
JavaScript
15 lines
392 B
JavaScript
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}`)
|
|
}
|