diff --git a/components/Checkbox.tsx b/components/Checkbox.tsx index d54c08b..feb351c 100644 --- a/components/Checkbox.tsx +++ b/components/Checkbox.tsx @@ -28,9 +28,7 @@ export default function Checkbox({ label, state, className, onClick }: Props) { icon={faSquare} className="w-5 h-5 text-sky-500 dark:text-sky-500 peer-checked:hidden block" /> - - {label} - + {label} ); } diff --git a/components/LinkCard.tsx b/components/LinkCard.tsx index 5cc8a1b..26982bf 100644 --- a/components/LinkCard.tsx +++ b/components/LinkCard.tsx @@ -165,13 +165,15 @@ export default function LinkCard({ link, count, className }: Props) { onClick={() => router.push("/links/" + link.id)} className="flex items-start cursor-pointer gap-5 sm:gap-10 h-full w-full p-5" > - {url && account.blurredFavicons && ( + {url && account.displayLinkIcons && ( { const target = e.target as HTMLElement; diff --git a/components/LinkPreview.tsx b/components/LinkPreview.tsx new file mode 100644 index 0000000..c81e46e --- /dev/null +++ b/components/LinkPreview.tsx @@ -0,0 +1,112 @@ +import { faFolder, faLink } from "@fortawesome/free-solid-svg-icons"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import Image from "next/image"; +import { faCalendarDays } from "@fortawesome/free-regular-svg-icons"; +import isValidUrl from "@/lib/client/isValidUrl"; +import A from "next/link"; +import unescapeString from "@/lib/client/unescapeString"; +import { Link } from "@prisma/client"; + +type Props = { + link?: Partial; + className?: string; + settings: { + blurredFavicons: boolean; + displayLinkIcons: boolean; + }; +}; + +export default function LinkPreview({ link, className, settings }: Props) { + if (!link) { + link = { + name: "Linkwarden", + url: "https://linkwarden.app", + createdAt: Date.now() as unknown as Date, + }; + } + + let shortendURL; + + try { + shortendURL = new URL(link.url as string).host.toLowerCase(); + } catch (error) { + console.log(error); + } + + const url = isValidUrl(link.url as string) + ? new URL(link.url as string) + : undefined; + + const formattedDate = new Date(link.createdAt as Date).toLocaleString( + "en-US", + { + year: "numeric", + month: "short", + day: "numeric", + } + ); + + return ( + <> +
+
+ {url && settings?.displayLinkIcons && ( + { + const target = e.target as HTMLElement; + target.style.display = "none"; + }} + /> + )} + +
+
+
+

{1}

+

+ {unescapeString(link.name as string)} +

+
+
+ +

+ Landing Pages ⚡️ +

+
+ { + e.stopPropagation(); + }} + className="flex items-center gap-1 max-w-full w-fit text-gray-500 dark:text-gray-300 hover:opacity-70 duration-100" + > + +

{shortendURL}

+
+
+ +

{formattedDate}

+
+
+
+
+
+ + ); +} diff --git a/lib/api/controllers/users/userId/updateUserById.ts b/lib/api/controllers/users/userId/updateUserById.ts index b8af062..3c4e03e 100644 --- a/lib/api/controllers/users/userId/updateUserById.ts +++ b/lib/api/controllers/users/userId/updateUserById.ts @@ -132,6 +132,7 @@ export default async function updateUserById( archiveAsScreenshot: data.archiveAsScreenshot, archiveAsPDF: data.archiveAsPDF, archiveAsWaybackMachine: data.archiveAsWaybackMachine, + displayLinkIcons: data.displayLinkIcons, blurredFavicons: data.blurredFavicons, password: data.newPassword && data.newPassword !== "" diff --git a/pages/dashboard.tsx b/pages/dashboard.tsx index 67823c0..79a2e5c 100644 --- a/pages/dashboard.tsx +++ b/pages/dashboard.tsx @@ -338,7 +338,7 @@ export default function Dashboard() {
{links diff --git a/pages/settings/account.tsx b/pages/settings/account.tsx index 525df84..45770c3 100644 --- a/pages/settings/account.tsx +++ b/pages/settings/account.tsx @@ -334,7 +334,7 @@ export default function Account() {

{user.isPrivate && ( -
+

Whitelisted Users

diff --git a/pages/settings/appearance.tsx b/pages/settings/appearance.tsx index 32d7473..6986b85 100644 --- a/pages/settings/appearance.tsx +++ b/pages/settings/appearance.tsx @@ -13,6 +13,7 @@ import ProfilePhoto from "@/components/ProfilePhoto"; import SubmitButton from "@/components/SubmitButton"; import React from "react"; import Checkbox from "@/components/Checkbox"; +import LinkPreview from "@/components/LinkPreview"; export default function Appearance() { const { theme, setTheme } = useTheme(); @@ -67,7 +68,7 @@ export default function Appearance() { return ( -
+

Select Theme

@@ -100,13 +101,37 @@ export default function Appearance() {
+
+

+ Link Card +

+
+
- setUser({ ...user, blurredFavicons: !user.blurredFavicons }) + setUser({ ...user, displayLinkIcons: !user.displayLinkIcons }) } /> + {user.displayLinkIcons ? ( + + setUser({ ...user, blurredFavicons: !user.blurredFavicons }) + } + /> + ) : undefined} +

Preview:

+ +
setArchiveAsScreenshot(!archiveAsScreenshot)} /> +