feat: dashboard v2, esm, upgrades (#211)
* esm * wip * wip * wip * wip * wip * wip * subscription notice * wip * wip * wip * fix envs * fix: update docker build * fix * esm/types * delete dashboard :D * add patches to dockerfiles * update packages + catalogs + ts * wip * remove native libs * ts * improvements * fix redirects and fetching session * try fix favicon * fixes * fix * order and resize reportds within a dashboard * improvements * wip * added userjot to dashboard * fix * add op * wip * different cache key * improve date picker * fix table * event details loading * redo onboarding completely * fix login * fix * fix * extend session, billing and improve bars * fix * reduce price on 10M
This commit is contained in:
committed by
GitHub
parent
436e81ecc9
commit
81a7e5d62e
@@ -5,12 +5,16 @@ function fallbackFavicon(url: string) {
|
||||
}
|
||||
|
||||
function findBestFavicon(favicons: UrlMetaData['favicons']) {
|
||||
const match = favicons.find(
|
||||
(favicon) =>
|
||||
favicon.rel === 'shortcut icon' ||
|
||||
favicon.rel === 'icon' ||
|
||||
favicon.rel === 'apple-touch-icon',
|
||||
);
|
||||
const match = favicons
|
||||
.sort((a, b) => {
|
||||
return a.rel.length - b.rel.length;
|
||||
})
|
||||
.find(
|
||||
(favicon) =>
|
||||
favicon.rel === 'shortcut icon' ||
|
||||
favicon.rel === 'icon' ||
|
||||
favicon.rel === 'apple-touch-icon',
|
||||
);
|
||||
|
||||
if (match) {
|
||||
return match.href;
|
||||
@@ -18,11 +22,32 @@ function findBestFavicon(favicons: UrlMetaData['favicons']) {
|
||||
return null;
|
||||
}
|
||||
|
||||
function findBestOgImage(data: UrlMetaData): string | null {
|
||||
// Priority order for OG images
|
||||
const candidates = [
|
||||
data['og:image:secure_url'],
|
||||
data['og:image:url'],
|
||||
data['og:image'],
|
||||
data['twitter:image:src'],
|
||||
data['twitter:image'],
|
||||
];
|
||||
|
||||
for (const candidate of candidates) {
|
||||
if (candidate?.trim()) {
|
||||
return candidate.trim();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function transform(data: UrlMetaData, url: string) {
|
||||
const favicon = findBestFavicon(data.favicons);
|
||||
const ogImage = findBestOgImage(data);
|
||||
|
||||
return {
|
||||
favicon: favicon ? new URL(favicon, url).toString() : fallbackFavicon(url),
|
||||
ogImage: ogImage ? new URL(ogImage, url).toString() : null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -32,6 +57,11 @@ interface UrlMetaData {
|
||||
href: string;
|
||||
sizes: string;
|
||||
}[];
|
||||
'og:image'?: string;
|
||||
'og:image:url'?: string;
|
||||
'og:image:secure_url'?: string;
|
||||
'twitter:image'?: string;
|
||||
'twitter:image:src'?: string;
|
||||
}
|
||||
|
||||
export async function parseUrlMeta(url: string) {
|
||||
@@ -42,6 +72,7 @@ export async function parseUrlMeta(url: string) {
|
||||
} catch (err) {
|
||||
return {
|
||||
favicon: fallbackFavicon(url),
|
||||
ogImage: null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user