feat: get url favicon from google s2

This commit is contained in:
Steven
2023-09-29 19:37:44 +08:00
parent 010271c668
commit 8cd976791e
12 changed files with 84 additions and 258 deletions

View File

@@ -71,7 +71,3 @@ export function patchShortcut(shortcutPatch: ShortcutPatch) {
export function deleteShortcutById(shortcutId: ShortcutId) {
return axios.delete(`/api/v1/shortcut/${shortcutId}`);
}
export function getUrlFavicon(url: string) {
return axios.get<string>(`/api/v1/url/favicon?url=${url}`);
}

View File

@@ -13,3 +13,12 @@ export const absolutifyLink = (rel: string): string => {
export const releaseGuard = () => {
return import.meta.env.MODE === "development";
};
export const getFaviconWithGoogleS2 = (url: string) => {
try {
const urlObject = new URL(url);
return `https://www.google.com/s2/favicons?sz=128&domain=${urlObject.hostname}`;
} catch (error) {
return undefined;
}
};