minor fix
This commit is contained in:
parent
5e6057f17b
commit
f4d9419bb0
|
@ -3,7 +3,7 @@ import {
|
||||||
LinkIncludingShortenedCollectionAndTags,
|
LinkIncludingShortenedCollectionAndTags,
|
||||||
} from "@/types/global";
|
} from "@/types/global";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
// import ColorThief, { RGBColor } from "colorthief";
|
import ColorThief, { RGBColor } from "colorthief";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
|
@ -53,47 +53,47 @@ export default function LinkDetails({ link }: Props) {
|
||||||
);
|
);
|
||||||
}, [collections]);
|
}, [collections]);
|
||||||
|
|
||||||
// const [colorPalette, setColorPalette] = useState<RGBColor[]>();
|
const [colorPalette, setColorPalette] = useState<RGBColor[]>();
|
||||||
|
|
||||||
// const colorThief = new ColorThief();
|
const colorThief = new ColorThief();
|
||||||
|
|
||||||
const url = isValidUrl(link.url) ? new URL(link.url) : undefined;
|
const url = isValidUrl(link.url) ? new URL(link.url) : undefined;
|
||||||
|
|
||||||
// const rgbToHex = (r: number, g: number, b: number): string =>
|
const rgbToHex = (r: number, g: number, b: number): string =>
|
||||||
// "#" +
|
"#" +
|
||||||
// [r, g, b]
|
[r, g, b]
|
||||||
// .map((x) => {
|
.map((x) => {
|
||||||
// const hex = x.toString(16);
|
const hex = x.toString(16);
|
||||||
// return hex.length === 1 ? "0" + hex : hex;
|
return hex.length === 1 ? "0" + hex : hex;
|
||||||
// })
|
})
|
||||||
// .join("");
|
.join("");
|
||||||
|
|
||||||
// useEffect(() => {
|
useEffect(() => {
|
||||||
// const banner = document.getElementById("link-banner");
|
const banner = document.getElementById("link-banner");
|
||||||
// const bannerInner = document.getElementById("link-banner-inner");
|
const bannerInner = document.getElementById("link-banner-inner");
|
||||||
|
|
||||||
// if (colorPalette && banner && bannerInner) {
|
if (colorPalette && banner && bannerInner) {
|
||||||
// banner.style.background = `linear-gradient(to right, ${rgbToHex(
|
banner.style.background = `linear-gradient(to right, ${rgbToHex(
|
||||||
// colorPalette[0][0],
|
colorPalette[0][0],
|
||||||
// colorPalette[0][1],
|
colorPalette[0][1],
|
||||||
// colorPalette[0][2]
|
colorPalette[0][2]
|
||||||
// )}, ${rgbToHex(
|
)}, ${rgbToHex(
|
||||||
// colorPalette[1][0],
|
colorPalette[1][0],
|
||||||
// colorPalette[1][1],
|
colorPalette[1][1],
|
||||||
// colorPalette[1][2]
|
colorPalette[1][2]
|
||||||
// )})`;
|
)})`;
|
||||||
|
|
||||||
// bannerInner.style.background = `linear-gradient(to right, ${rgbToHex(
|
bannerInner.style.background = `linear-gradient(to right, ${rgbToHex(
|
||||||
// colorPalette[2][0],
|
colorPalette[2][0],
|
||||||
// colorPalette[2][1],
|
colorPalette[2][1],
|
||||||
// colorPalette[2][2]
|
colorPalette[2][2]
|
||||||
// )}, ${rgbToHex(
|
)}, ${rgbToHex(
|
||||||
// colorPalette[3][0],
|
colorPalette[3][0],
|
||||||
// colorPalette[3][1],
|
colorPalette[3][1],
|
||||||
// colorPalette[3][2]
|
colorPalette[3][2]
|
||||||
// )})`;
|
)})`;
|
||||||
// }
|
}
|
||||||
// }, [colorPalette]);
|
}, [colorPalette]);
|
||||||
|
|
||||||
const handleDownload = (format: "png" | "pdf") => {
|
const handleDownload = (format: "png" | "pdf") => {
|
||||||
const path = `/api/archives/${link.collection.id}/${link.id}.${format}`;
|
const path = `/api/archives/${link.collection.id}/${link.id}.${format}`;
|
||||||
|
@ -133,19 +133,18 @@ export default function LinkDetails({ link }: Props) {
|
||||||
id={"favicon-" + link.id}
|
id={"favicon-" + link.id}
|
||||||
className="select-none mt-2 rounded-full shadow border-[3px] border-white bg-white aspect-square"
|
className="select-none mt-2 rounded-full shadow border-[3px] border-white bg-white aspect-square"
|
||||||
draggable="false"
|
draggable="false"
|
||||||
// onLoad={(e) => {
|
onLoad={(e) => {
|
||||||
// try {
|
try {
|
||||||
// const color = colorThief.getPalette(
|
const color = colorThief.getPalette(
|
||||||
// e.target as HTMLImageElement,
|
e.target as HTMLImageElement,
|
||||||
// 4,
|
4
|
||||||
// 20
|
);
|
||||||
// );
|
|
||||||
|
|
||||||
// setColorPalette(color);
|
setColorPalette(color);
|
||||||
// } catch (err) {
|
} catch (err) {
|
||||||
// console.log(err);
|
console.log(err);
|
||||||
// }
|
}
|
||||||
// }}
|
}}
|
||||||
onError={(e) => {
|
onError={(e) => {
|
||||||
setImageError(true);
|
setImageError(true);
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -44,10 +44,10 @@ export default async function archive(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// await browser.close();
|
await browser.close();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
// await browser.close();
|
await browser.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Ŝarĝante…
Reference in New Issue