⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.
TypeScript bookmarkbookmark-managercollaborationnextjsreact-nativeread-it-laterself-hostedtypescript
wip
daniel31x13b84840e12ca5
diff --git a/components/LinkDetails.tsx b/components/LinkDetails.tsxindex dfccb8e7..ab0955dd 100644--- a/components/LinkDetails.tsx+++ b/components/LinkDetails.tsx@@ -4,7 +4,10 @@ import {ArchivedFormat,} from "@/types/global";import Link from "next/link";-import { formatAvailable } from "@/lib/shared/formatStats";+import {+ atLeastOneFormatAvailable,+ formatAvailable,+} from "@/lib/shared/formatStats";import getPublicUserData from "@/lib/client/getPublicUserData";import { useTranslation } from "next-i18next";import { useUser } from "@/hooks/store/user";@@ -26,6 +29,8 @@ import usePermissions from "@/hooks/usePermissions";import oklchVariableToHex from "@/lib/client/oklchVariableToHex";import Preservation from "./Preservation";import useWindowDimensions from "@/hooks/useWindowDimensions";+import PreservedFormatRow from "./PreserverdFormatRow";+import { BeatLoader } from "react-spinners";type Props = {className?: string;@@ -356,42 +361,6 @@ export default function LinkDetails({</div>)}- {mode === "view" && width < 640 && (- <div>- <br />-- <div className="flex gap-1 items-center mb-2">- <p- className="text-sm text-neutral"- title={t("available_formats")}- >- {link.url ? t("preserved_formats") : t("content")}- </p>-- {onUpdateArchive &&- link.type === "url" &&- (permissions === true || permissions?.canUpdate) &&- !isPublicRoute && (- <div- className="tooltip tooltip-bottom"- data-tip={t("refresh_preserved_formats")}- >- <button- className="btn btn-xs btn-ghost btn-square text-neutral"- onClick={() => onUpdateArchive()}- >- <i className="bi-arrow-clockwise text-sm" />- </button>- </div>- )}- </div>-- {link.id && (- <Preservation link={link} standalone={standalone} />- )}- </div>- )}-{mode === "edit" && (<><br />@@ -574,6 +543,148 @@ export default function LinkDetails({)}</div>+ {mode === "view" && (+ <div>+ <br />++ <div className="flex gap-1 items-center mb-2">+ <p+ className="text-sm text-neutral"+ title={t("available_formats")}+ >+ {link.url ? t("preserved_formats") : t("file")}+ </p>++ {onUpdateArchive &&+ link.type === "url" &&+ (permissions === true || permissions?.canUpdate) &&+ !isPublicRoute && (+ <div+ className="tooltip tooltip-bottom"+ data-tip={t("refresh_preserved_formats")}+ >+ <button+ className="btn btn-xs btn-ghost btn-square text-neutral"+ onClick={() => onUpdateArchive()}+ >+ <i className="bi-arrow-clockwise text-sm" />+ </button>+ </div>+ )}+ </div>++ <div className={`flex flex-col rounded-md p-3 bg-base-200`}>+ {formatAvailable(link, "monolith") ? (+ <>+ <PreservedFormatRow+ name={t("webpage")}+ icon={"bi-filetype-html"}+ format={ArchivedFormat.monolith}+ link={link}+ downloadable={true}+ />+ <hr className="m-3 border-t border-neutral-content" />+ </>+ ) : undefined}++ {formatAvailable(link, "image") ? (+ <>+ <PreservedFormatRow+ name={t("screenshot")}+ icon={"bi-file-earmark-image"}+ format={+ link?.image?.endsWith("png")+ ? ArchivedFormat.png+ : ArchivedFormat.jpeg+ }+ link={link}+ downloadable={true}+ />+ <hr className="m-3 border-t border-neutral-content" />+ </>+ ) : undefined}++ {formatAvailable(link, "pdf") ? (+ <>+ <PreservedFormatRow+ name={t("pdf")}+ icon={"bi-file-earmark-pdf"}+ format={ArchivedFormat.pdf}+ link={link}+ downloadable={true}+ />+ <hr className="m-3 border-t border-neutral-content" />+ </>+ ) : undefined}++ {formatAvailable(link, "readable") ? (+ <>+ <PreservedFormatRow+ name={t("readable")}+ icon={"bi-file-earmark-text"}+ format={ArchivedFormat.readability}+ link={link}+ />+ <hr className="m-3 border-t border-neutral-content" />+ </>+ ) : undefined}++ {!isReady() && !atLeastOneFormatAvailable(link) ? (+ <div+ className={`w-full h-full flex flex-col justify-center p-10`}+ >+ <BeatLoader+ color="oklch(var(--p))"+ className="mx-auto mb-3"+ size={30}+ />++ <p className="text-center text-2xl">+ {t("preservation_in_queue")}+ </p>+ <p className="text-center text-lg">+ {t("check_back_later")}+ </p>+ </div>+ ) : link.url &&+ !isReady() &&+ atLeastOneFormatAvailable(link) ? (+ <div+ className={`w-full h-full flex flex-col justify-center p-5`}+ >+ <BeatLoader+ color="oklch(var(--p))"+ className="mx-auto mb-3"+ size={20}+ />+ <p className="text-center">+ {t("there_are_more_formats")}+ </p>+ <p className="text-center text-sm">+ {t("check_back_later")}+ </p>+ </div>+ ) : undefined}++ {link.url && (+ <Link+ href={`https://web.archive.org/web/${link?.url?.replace(+ /(^\w+:|^)\/\//,+ ""+ )}`}+ target="_blank"+ className="text-neutral mx-auto duration-100 hover:opacity-60 flex gap-2 w-1/2 justify-center items-center text-sm"+ >+ <p className="whitespace-nowrap">+ {t("view_latest_snapshot")}+ </p>+ <i className="bi-box-arrow-up-right" />+ </Link>+ )}+ </div>+ </div>+ )}+{mode === "view" ? (<><br />diff --git a/components/PreservationMobile.tsx b/components/PreservationMobile.tsxdeleted file mode 100644index b4ca6947..00000000--- a/components/PreservationMobile.tsx+++ /dev/null@@ -1,429 +0,0 @@-import React, { useEffect, useMemo, useRef, useState } from "react";-import ReactDOM from "react-dom";-import {- ArchivedFormat,- LinkIncludingShortenedCollectionAndTags,-} from "@/types/global";-import { useTranslation } from "next-i18next";-import { useRouter } from "next/router";-import ReadableView from "@/components/ReadableView";-import clsx from "clsx";-import { formatAvailable } from "@/lib/shared/formatStats";-import { PreservationSkeleton } from "./Skeletons";-import remToPixels from "@/lib/client/remToPixels";-import { useReducedMotion } from "framer-motion";-import useWindowDimensions from "@/hooks/useWindowDimensions";--export default function Preservation({- link,- standalone,-}: {- link: LinkIncludingShortenedCollectionAndTags;- standalone?: boolean;-}) {- const { t } = useTranslation();- const router = useRouter();-- const [format, setFormat] = useState<ArchivedFormat>();- const [pdfLoaded, setPdfLoaded] = useState(false);- const [monolithLoaded, setMonolithLoaded] = useState(false);- const [imageLoaded, setImageLoaded] = useState(false);- const [isExpanded, setIsExpanded] = useState(false);-- const [delayPassed, setDelayPassed] = useState(false); // for the modal animation-- useEffect(() => {- const delay = setTimeout(() => {- setDelayPassed(true);- }, 250);-- return () => {- clearTimeout(delay);- };- }, []);-- const containerRef = useRef<HTMLDivElement>(null);-- const determineDefaultFormat = () => {- if (formatAvailable(link, "readable")) return ArchivedFormat.readability;- if (formatAvailable(link, "monolith")) return ArchivedFormat.monolith;- if (formatAvailable(link, "image")) {- return link?.image?.endsWith("png")- ? ArchivedFormat.png- : ArchivedFormat.jpeg;- }- if (formatAvailable(link, "pdf")) return ArchivedFormat.pdf;- return undefined;- };-- const defaultFormat = useMemo(() => determineDefaultFormat(), [link]);-- useEffect(() => {- const { format: routeFormat, expanded: routeIsExpanded } = router.query;-- const formatNumber = Number(routeFormat);-- if (routeFormat && Object.values(ArchivedFormat).includes(formatNumber)) {- setFormat(formatNumber);- } else {- setFormat(defaultFormat);- }-- if (routeIsExpanded === "true") {- setIsExpanded(true);- }- }, [router.query, link]);-- const prevFormatRef = useRef<ArchivedFormat | undefined>(undefined);-- useEffect(() => {- if (prevFormatRef.current !== format) {- setPdfLoaded(false);- setMonolithLoaded(false);- setImageLoaded(false);-- prevFormatRef.current = format;- }- }, [format]);-- useEffect(() => {- if (router.pathname.includes("links")) {- const query = {- ...router.query,- format,- expanded: isExpanded,- };- router.push({ pathname: router.pathname, query }, undefined, {- shallow: true,- });- }- }, [format, isExpanded]);-- const handleDownload = () => {- const path = `/api/v1/archives/${link?.id}?format=${format}`;- fetch(path)- .then((response) => {- if (response.ok) {- const anchorElement = document.createElement("a");- anchorElement.href = path;- anchorElement.download =- format === ArchivedFormat.monolith- ? "Webpage"- : format === ArchivedFormat.pdf- ? "PDF"- : format === ArchivedFormat.readability- ? "Readable"- : "Screenshot";- anchorElement.click();- } else {- console.error("Failed to download file");- }- })- .catch((error) => {- console.error("Error:", error);- });- };-- return (- <div- ref={containerRef}- className={clsx(- "bg-base-200",- !isExpanded &&- `mx-auto relative p-2 h-full overflow-auto rounded-md sm:rounded-none`,- isExpanded && "fixed inset-0 w-screen h-screen z-[9999]"- )}- style={{- pointerEvents: "auto",- }}- >- {!isExpanded && link?.id && (- <div className="text-sm text-neutral mb-3 flex justify-between items-center w-full gap-2">- <div className="flex gap-1 h-8 rounded-xl bg-neutral-content bg-opacity-50 text-base-content p-1 text-xs duration-100 select-none z-10">- {formatAvailable(link, "readable") && (- <div- className={clsx(- "py-1 px-2 cursor-pointer duration-100 rounded-lg font-semibold text-center flex justify-between items-center w-6",- format === ArchivedFormat.readability &&- "bg-primary bg-opacity-50"- )}- onClick={() => setFormat(ArchivedFormat.readability)}- >- <div title={t("readable")}>- <i className={`bi-file-earmark-text text-lg -ml-[0.3rem]`} />- </div>- </div>- )}- {formatAvailable(link, "monolith") && (- <div- className={clsx(- "py-1 px-2 cursor-pointer duration-100 rounded-lg font-semibold text-center flex justify-between items-center w-6",- format === ArchivedFormat.monolith &&- "bg-primary bg-opacity-50"- )}- onClick={() => setFormat(ArchivedFormat.monolith)}- >- <div title={t("webpage")}>- <i className={`bi-filetype-html text-lg -ml-[0.3rem]`} />- </div>- </div>- )}- {formatAvailable(link, "image") && (- <div- className={clsx(- "py-1 px-2 cursor-pointer duration-100 rounded-lg font-semibold text-center flex justify-between items-center w-6",- format ===- (link?.image?.endsWith("png")- ? ArchivedFormat.png- : ArchivedFormat.jpeg) && "bg-primary bg-opacity-50"- )}- onClick={() =>- setFormat(- link?.image?.endsWith("png")- ? ArchivedFormat.png- : ArchivedFormat.jpeg- )- }- >- <div title={t("image")}>- <i className={`bi-file-earmark-image text-lg -ml-[0.3rem]`} />- </div>- </div>- )}- {formatAvailable(link, "pdf") && (- <div- className={clsx(- "py-1 px-2 cursor-pointer duration-100 rounded-lg font-semibold text-center flex justify-between items-center w-6",- format === ArchivedFormat.pdf && "bg-primary bg-opacity-50"- )}- onClick={() => setFormat(ArchivedFormat.pdf)}- >- <div title={t("pdf")}>- <i className={`bi-file-earmark-pdf text-lg -ml-[0.3rem]`} />- </div>- </div>- )}- </div>-- {format !== undefined && (- <div className="flex gap-2">- <div- onClick={handleDownload}- className="btn btn-sm btn-square btn-ghost"- >- <i className="bi-cloud-arrow-down text-xl" />- </div>- <div- className="btn btn-square btn-ghost btn-sm"- onClick={() => setIsExpanded(true)}- >- <i className="bi-arrows-angle-expand" />- </div>- </div>- )}- </div>- )}-- <div className={clsx("w-full", isExpanded ? "h-full" : "h-auto")}>- {format !== undefined && link.id && delayPassed ? (- <RenderFormat- link={link}- format={format}- isExpanded={isExpanded}- setMonolithLoaded={setMonolithLoaded}- setPdfLoaded={setPdfLoaded}- setImageLoaded={setImageLoaded}- monolithLoaded={monolithLoaded}- pdfLoaded={pdfLoaded}- imageLoaded={imageLoaded}- standalone={standalone}- containerRef={containerRef}- setIsExpanded={setIsExpanded}- />- ) : (- <PreservationSkeleton />- )}- </div>- </div>- );-}--const RenderFormat = ({- link,- format,- isExpanded,- setMonolithLoaded,- setPdfLoaded,- setImageLoaded,- monolithLoaded,- pdfLoaded,- imageLoaded,- standalone,- containerRef,- setIsExpanded,-}: {- link: LinkIncludingShortenedCollectionAndTags;- format: ArchivedFormat;- isExpanded: boolean;- setMonolithLoaded: (loaded: boolean) => void;- setPdfLoaded: (loaded: boolean) => void;- setImageLoaded: (loaded: boolean) => void;- monolithLoaded: boolean;- pdfLoaded: boolean;- imageLoaded: boolean;- standalone?: boolean;- containerRef: React.RefObject<HTMLDivElement>;- setIsExpanded: (expanded: boolean) => void;-}) => {- if (!link?.id) return <></>;-- const [containerRect, setContainerRect] = useState<DOMRect | null>(null);-- const [delayPassed, setDelayPassed] = useState(false); // to get the content in place before animating-- useEffect(() => {- const delay = setTimeout(() => {- setDelayPassed(true);- }, 50);-- return () => {- clearTimeout(delay);- };- }, []);-- const { width } = useWindowDimensions();-- useEffect(() => {- if (!isExpanded) {- const measure = () => {- if (containerRef.current) {- setContainerRect(containerRef.current.getBoundingClientRect());- }- };-- measure();- window.addEventListener("resize", measure);- if (width < 640 && !isExpanded)- window.addEventListener("scroll", measure, true);- return () => {- window.removeEventListener("resize", measure);- if (width < 640 && !isExpanded)- window.removeEventListener("scroll", measure, true);- };- }- }, [containerRef, isExpanded]);-- const topPadding = remToPixels(3.75);-- const shouldReduceMotion = useReducedMotion();-- const style = isExpanded- ? {- position: "fixed" as const,- top: 0,- left: 0,- width: "100vw",- height: "100vh",- zIndex: 9999,- transitionProperty:- delayPassed && !shouldReduceMotion- ? "width, height, top, left"- : "none",- }- : {- zIndex: 40,- position: "absolute" as const,- top: (containerRect?.top ?? 0) + window.scrollY + topPadding,- left: (containerRect?.left ?? 0) + window.scrollX,- width: containerRect?.width ?? 0,- height: containerRect?.height ? containerRect.height - topPadding : 0,- transitionProperty:- delayPassed && !shouldReduceMotion- ? "width, height, top, left"- : "none",- };-- const content = () => {- switch (format) {- case ArchivedFormat.readability:- return (- <div className="overflow-auto w-full h-full">- <ReadableView- link={link}- isExpanded={isExpanded}- standalone={standalone}- />- </div>- );- case ArchivedFormat.monolith:- return (- <>- {!monolithLoaded && <PreservationSkeleton />}- <iframe- src={`/api/v1/archives/${link.id}?format=${ArchivedFormat.monolith}&_=${link.updatedAt}`}- className={clsx(- "w-full border-none",- monolithLoaded ? "block" : "hidden",- isExpanded ? "h-full" : "h-[calc(80vh-3.75rem)]"- )}- onLoad={() => setMonolithLoaded(true)}- />- </>- );- case ArchivedFormat.pdf:- return (- <>- {!pdfLoaded && <PreservationSkeleton />}- <iframe- src={`/api/v1/archives/${link.id}?format=${ArchivedFormat.pdf}&_=${link.updatedAt}`}- className={clsx(- "w-full border-none",- pdfLoaded ? "block" : "hidden",- isExpanded ? "h-full" : "h-[calc(80vh-3.75rem)]"- )}- onLoad={() => setPdfLoaded(true)}- />- </>- );- case ArchivedFormat.png:- case ArchivedFormat.jpeg:- return (- <>- {!imageLoaded && <PreservationSkeleton />}- <div className="overflow-auto w-fit mx-auto h-full">- <img- alt=""- src={`/api/v1/archives/${link.id}?format=${format}&_=${link.updatedAt}`}- className={clsx("w-fit mx-auto", !imageLoaded && "hidden")}- onLoad={() => setImageLoaded(true)}- />- </div>- </>- );- default:- return <></>;- }- };-- return ReactDOM.createPortal(- <div- style={style}- className={clsx(- "z-[40] overflow-hidden ease-in-out duration-100 pointer-events-auto",- !isExpanded && "rounded-bl-2xl"- )}- data-ignore-click-away- >- {content()}- {isExpanded && (- <div- className="absolute top-3 right-3 btn btn-circle btn-primary btn-sm"- onClick={() => setIsExpanded(false)}- >- <i className="bi-arrows-angle-contract text-lg" />- </div>- )}- </div>,- document.body- );-};diff --git a/components/PreservationStandalone.tsx b/components/PreservationStandalone.tsxnew file mode 100644index 00000000..d358613a--- /dev/null+++ b/components/PreservationStandalone.tsx@@ -0,0 +1,282 @@+import React, { useEffect, useState } from "react";+import { useRouter } from "next/router";+import { ArchivedFormat } from "@/types/global";+import { useTranslation } from "next-i18next";+import ReadableView from "@/components/ReadableView";+import { useGetLink } from "@/hooks/store/links";+import clsx from "clsx";+import { formatAvailable } from "@/lib/shared/formatStats";++export default function Preservation() {+ const router = useRouter();+ const isPublicRoute = router.pathname.startsWith("/public");++ const { data: link, mutateAsync: fetchLink, error } = useGetLink();+ const { t } = useTranslation();++ const [format, setFormat] = useState<ArchivedFormat>(+ Number(router.query.format)+ );++ const [pdfLoaded, setPdfLoaded] = useState(false);+ const [monolithLoaded, setMonolithLoaded] = useState(false);+ const [imageLoaded, setImageLoaded] = useState(false);++ const [isExpanded, setIsExpanded] = useState(false);++ useEffect(() => {+ router.push(+ {+ query: { id: router.query.id, format },+ },+ undefined,+ { shallow: true }+ );++ setPdfLoaded(false);+ setMonolithLoaded(false);+ setImageLoaded(false);+ }, [format]);++ useEffect(() => {+ fetchLink({+ id: Number(router.query.id),+ isPublicRoute,+ });++ let interval: NodeJS.Timeout | null = null;+ if (+ link &&+ (!link?.image || !link?.pdf || !link?.readable || !link?.monolith)+ ) {+ interval = setInterval(() => {+ fetchLink({ id: link.id as number });+ }, 5000);+ } else if (interval) {+ clearInterval(interval);+ }++ return () => {+ if (interval) clearInterval(interval);+ };+ }, []);++ const Skeleton = () => (+ <div className="p-5 m-auto w-full flex flex-col items-center gap-5">+ <div className="w-full mr-auto h-4 skeleton rounded-md"></div>+ <div className="w-full mr-auto h-4 skeleton rounded-md"></div>+ <div className="w-full mr-auto h-4 skeleton rounded-md"></div>+ <div className="w-3/4 mr-auto h-4 skeleton rounded-md"></div>+ <div className="w-5/6 mr-auto h-4 skeleton rounded-md"></div>+ <div className="w-3/4 mr-auto h-4 skeleton rounded-md"></div>+ <div className="w-full mr-auto h-4 skeleton rounded-md"></div>+ <div className="w-full mr-auto h-4 skeleton rounded-md"></div>+ <div className="w-5/6 mr-auto h-4 skeleton rounded-md"></div>+ </div>+ );++ const renderFormat = () => {+ if (!link?.id) return null;++ switch (Number(router.query.format)) {+ case ArchivedFormat.readability:+ return (+ <div className="overflow-auto w-full h-full">+ <ReadableView isExpanded={isExpanded} link={link} />+ </div>+ );++ case ArchivedFormat.monolith:+ return (+ <>+ {!monolithLoaded && <Skeleton />}+ <iframe+ src={`/api/v1/archives/${link.id}?format=${ArchivedFormat.monolith}`}+ className={clsx(+ "w-full border-none",+ monolithLoaded ? "block" : "hidden",+ isExpanded ? "h-full" : "h-[calc(100vh-4.5rem)]"+ )}+ onLoad={() => setMonolithLoaded(true)}+ />+ </>+ );++ case ArchivedFormat.pdf:+ return (+ <>+ {!pdfLoaded && <Skeleton />}+ <iframe+ src={`/api/v1/archives/${link.id}?format=${ArchivedFormat.pdf}`}+ className={clsx(+ "w-full border-none",+ pdfLoaded ? "block" : "hidden",+ isExpanded ? "h-full" : "h-[calc(100vh-4.5rem)]"+ )}+ onLoad={() => setPdfLoaded(true)}+ />+ </>+ );++ case ArchivedFormat.png:+ case ArchivedFormat.jpeg:+ return (+ <>+ {!imageLoaded && <Skeleton />}+ <div className="overflow-auto w-fit mx-auto h-full">+ <img+ alt=""+ src={`/api/v1/archives/${link.id}?format=${Number(+ router.query.format+ )}`}+ className={clsx(+ "w-fit h-auto mx-auto", // Ensure block display and proper resizing+ !imageLoaded && "hidden"+ )}+ onLoad={() => setImageLoaded(true)}+ />+ </div>+ </>+ );++ default:+ return null;+ }+ };++ const handleDownload = () => {+ const path = `/api/v1/archives/${link?.id}?format=${format}`;+ fetch(path)+ .then((response) => {+ if (response.ok) {+ const anchorElement = document.createElement("a");+ anchorElement.href = path;+ anchorElement.download =+ format === ArchivedFormat.monolith+ ? "Webpage"+ : format === ArchivedFormat.pdf+ ? "PDF"+ : format === ArchivedFormat.readability+ ? "Readable"+ : "Screenshot";+ anchorElement.click();+ } else {+ console.error("Failed to download file");+ }+ })+ .catch((error) => {+ console.error("Error:", error);+ });+ };++ return (+ <div+ className={clsx(+ !isExpanded && "max-w-screen-lg mx-auto p-3 relative",+ isExpanded && "fixed inset-0 w-screen h-screen z-50"+ )}+ style={{+ overflow: isExpanded ? "hidden" : "visible",+ }}+ >+ {!isExpanded && link?.id && (+ <div className="text-sm text-neutral mb-3 flex justify-between items-center w-full gap-2">+ <div className="flex gap-1 h-8 rounded-xl bg-neutral-content bg-opacity-50 text-base-content p-1 text-xs duration-100 select-none z-10">+ {formatAvailable(link, "readable") && (+ <div+ className={clsx(+ "py-1 px-2 cursor-pointer duration-100 rounded-lg font-semibold text-center flex justify-between items-center w-6",+ format === ArchivedFormat.readability &&+ "bg-primary bg-opacity-50"+ )}+ onClick={() => setFormat(ArchivedFormat.readability)}+ >+ <div title={t("readable")}>+ <i className={`bi-file-earmark-text text-lg -ml-[0.3rem]`} />+ </div>+ </div>+ )}+ {formatAvailable(link, "monolith") && (+ <div+ className={clsx(+ "py-1 px-2 cursor-pointer duration-100 rounded-lg font-semibold text-center flex justify-between items-center w-6",+ format === ArchivedFormat.monolith &&+ "bg-primary bg-opacity-50"+ )}+ onClick={() => setFormat(ArchivedFormat.monolith)}+ >+ <div title={t("webpage")}>+ <i className={`bi-filetype-html text-lg -ml-[0.3rem]`} />+ </div>+ </div>+ )}+ {formatAvailable(link, "image") && (+ <div+ className={clsx(+ "py-1 px-2 cursor-pointer duration-100 rounded-lg font-semibold text-center flex justify-between items-center w-6",+ format ===+ (link?.image?.endsWith("png")+ ? ArchivedFormat.png+ : ArchivedFormat.jpeg) && "bg-primary bg-opacity-50"+ )}+ onClick={() =>+ setFormat(+ link?.image?.endsWith("png")+ ? ArchivedFormat.png+ : ArchivedFormat.jpeg+ )+ }+ >+ <div title={t("image")}>+ <i className={`bi-file-earmark-image text-lg -ml-[0.3rem]`} />+ </div>+ </div>+ )}+ {formatAvailable(link, "pdf") && (+ <div+ className={clsx(+ "py-1 px-2 cursor-pointer duration-100 rounded-lg font-semibold text-center flex justify-between items-center w-6",+ format === ArchivedFormat.pdf && "bg-primary bg-opacity-50"+ )}+ onClick={() => setFormat(ArchivedFormat.pdf)}+ >+ <div title={t("pdf")}>+ <i className={`bi-file-earmark-pdf text-lg -ml-[0.3rem]`} />+ </div>+ </div>+ )}+ </div>++ <div className="flex gap-2">+ <div onClick={handleDownload} className="btn btn-sm btn-circle">+ <i className="bi-cloud-arrow-down text-xl text-neutral" />+ </div>+ <div+ className="btn btn-circle btn-sm"+ onClick={() => setIsExpanded(true)}+ >+ <i className="bi-arrows-angle-expand" />+ </div>+ </div>+ </div>+ )}++ {error ? (+ <p>{t("not_found_404")}</p>+ ) : (+ <div className={clsx("w-full", isExpanded ? "h-full" : "h-auto")}>+ {renderFormat()}+ </div>+ )}++ {isExpanded && (+ <div+ className="absolute top-3 right-3 btn btn-circle btn-sm"+ onClick={() => setIsExpanded(false)}+ >+ <i className="bi-arrows-angle-contract" />+ </div>+ )}+ </div>+ );+}diff --git a/pages/preserved/[id].tsx b/pages/preserved/[id].tsxindex 311a5a88..c84f8630 100644--- a/pages/preserved/[id].tsx+++ b/pages/preserved/[id].tsx@@ -1,7 +1,8 @@-import { useRouter } from "next/router";-export default function Index() {- const router = useRouter();- const { id } = router.query;+import getServerSideProps from "@/lib/client/getServerSideProps";+import PreservationStandalone from "@/components/PreservationStandalone";- return router.push(`/links/${id}`);+export default function Index() {+ return <PreservationStandalone />;}++export { getServerSideProps };diff --git a/pages/public/preserved/[id].tsx b/pages/public/preserved/[id].tsxindex 41c27d76..c84f8630 100644--- a/pages/public/preserved/[id].tsx+++ b/pages/public/preserved/[id].tsx@@ -1,7 +1,8 @@-import { useRouter } from "next/router";-export default function Index() {- const router = useRouter();- const { id } = router.query;+import getServerSideProps from "@/lib/client/getServerSideProps";+import PreservationStandalone from "@/components/PreservationStandalone";- return router.push(`/public/links/${id}`);+export default function Index() {+ return <PreservationStandalone />;}++export { getServerSideProps };