You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
519 B
17 lines
519 B
import { TWebMetadata } from '@/types' |
|
import { useEffect, useState } from 'react' |
|
import webService from '@/services/web.service' |
|
|
|
export function useFetchWebMetadata(url: string) { |
|
const [metadata, setMetadata] = useState<TWebMetadata>({}) |
|
const proxyServer = import.meta.env.VITE_PROXY_SERVER |
|
if (proxyServer) { |
|
url = `${proxyServer}/sites/${encodeURIComponent(url)}` |
|
} |
|
|
|
useEffect(() => { |
|
webService.fetchWebMetadata(url).then((metadata) => setMetadata(metadata)) |
|
}, [url]) |
|
|
|
return metadata |
|
}
|
|
|