⚡️⚡️⚡️ 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
improvements
daniel31x13e9b47a69c591
diff --git a/components/LinkViews/Layouts/GridView.tsx b/components/LinkViews/Layouts/GridView.tsxindex 1cdbd35a..005ba28a 100644--- a/components/LinkViews/Layouts/GridView.tsx+++ b/components/LinkViews/Layouts/GridView.tsx@@ -7,13 +7,9 @@ export default function GridView({links: LinkIncludingShortenedCollectionAndTags[];}) {return (- <div className="columns-1 xl:columns-2 2xl:columns-3 gap-5">+ <div className="grid 2xl:grid-cols-3 xl:grid-cols-2 grid-cols-1 gap-5">{links.map((e, i) => {- return (- <div key={i} className="break-inside-avoid mb-5">- <LinkGrid link={e} count={i} />- </div>- );+ return <LinkGrid link={e} count={i} key={i} />;})}</div>);diff --git a/components/LinkViews/LinkCard.tsx b/components/LinkViews/LinkCard.tsxindex 23361242..61d4bbaa 100644--- a/components/LinkViews/LinkCard.tsx+++ b/components/LinkViews/LinkCard.tsx@@ -2,15 +2,15 @@ import {CollectionIncludingMembersAndLinkCount,LinkIncludingShortenedCollectionAndTags,} from "@/types/global";-import React, { useEffect, useState } from "react";+import { useEffect, useState } from "react";import useLinkStore from "@/store/links";import useCollectionStore from "@/store/collections";-import isValidUrl from "@/lib/shared/isValidUrl";import unescapeString from "@/lib/client/unescapeString";import LinkActions from "@/components/LinkViews/LinkComponents/LinkActions";import LinkDate from "@/components/LinkViews/LinkComponents/LinkDate";import LinkCollection from "@/components/LinkViews/LinkComponents/LinkCollection";import LinkIcon from "@/components/LinkViews/LinkComponents/LinkIcon";+import Link from "next/link";type Props = {link: LinkIncludingShortenedCollectionAndTags;@@ -18,10 +18,18 @@ type Props = {className?: string;};-export default function LinkCard({ link, count, className }: Props) {+export default function LinkGrid({ link, count, className }: Props) {+ const { collections } = useCollectionStore();+const { links } = useLinkStore();- const { collections } = useCollectionStore();+ let shortendURL;++ try {+ shortendURL = new URL(link.url || "").host.toLowerCase();+ } catch (error) {+ console.log(error);+ }const [collection, setCollection] =useState<CollectionIncludingMembersAndLinkCount>(@@ -38,53 +46,61 @@ export default function LinkCard({ link, count, className }: Props) {);}, [collections, links]);- let shortendURL;-- try {- shortendURL = new URL(link.url || "").host.toLowerCase();- } catch (error) {- console.log(error);- }-- const url =- isValidUrl(link.url || "") && link.url ? new URL(link.url) : undefined;-return (- <div- className={`h-fit hover:bg-base-300 hover:border-base-300 border border-solid border-neutral-content bg-base-200 shadow-md hover:shadow-none duration-200 rounded-2xl relative ${- className || ""- }`}- >+ <div className="border border-solid border-neutral-content bg-base-200 shadow-md hover:shadow-none duration-100 rounded-2xl relative p-3"><divonClick={() => link.url && window.open(link.url || "", "_blank")}- className="flex flex-col justify-between cursor-pointer h-full w-full gap-1 p-3"+ className="cursor-pointer">- <div className="absolute bottom-3 right-3">- <LinkIcon link={link}/>- </div>+ <LinkIcon link={link} width="w-12 mb-3" />+ <p className="truncate w-full">+ {unescapeString(link.name || link.description) || link.url}+ </p>- <div className="flex items-baseline gap-1">- <p className="text-sm text-neutral">{count + 1}</p>- <p className="text-lg truncate w-full pr-8">- {unescapeString(link.name || link.description) || link.url}- </p>+ <div className="mt-1 flex flex-col text-xs text-neutral">+ <div className="flex items-center gap-2">+ <LinkCollection link={link} collection={collection} />+ ·+ {link.url ? (+ <div+ onClick={(e) => {+ e.preventDefault();+ window.open(link.url || "", "_blank");+ }}+ className="flex items-center hover:opacity-60 cursor-pointer duration-100"+ >+ <p className="truncate">{shortendURL}</p>+ </div>+ ) : (+ <div className="badge badge-primary badge-sm my-1">+ {link.type}+ </div>+ )}+ </div>+ <LinkDate link={link} /></div>-- {link.url ? (- <div className="flex items-center gap-1 max-w-full w-fit text-neutral">- <i className="bi-link-45deg"/>- <p className="truncate w-full">{shortendURL}</p>+ {/* <p className="truncate">{unescapeString(link.description)}</p>+ {link.tags[0] ? (+ <div className="flex gap-3 items-center flex-wrap mt-2 truncate relative">+ <div className="flex gap-1 items-center flex-wrap">+ {link.tags.map((e, i) => (+ <Link+ href={"/tags/" + e.id}+ key={i}+ onClick={(e) => {+ e.stopPropagation();+ }}+ className="btn btn-xs btn-ghost truncate max-w-[19rem]"+ >+ #{e.name}+ </Link>+ ))}+ </div></div>- ) : (- <div className="badge badge-primary badge-sm my-1">{link.type}</div>- )}-- <LinkCollection link={link} collection={collection}/>-- <LinkDate link={link}/>+ ) : undefined} */}</div>- <LinkActions link={link} collection={collection}/>+ <LinkActions link={link} collection={collection} /></div>);}diff --git a/components/LinkViews/LinkComponents/LinkActions.tsx b/components/LinkViews/LinkComponents/LinkActions.tsxindex 015e32d8..0c4adf13 100644--- a/components/LinkViews/LinkComponents/LinkActions.tsx+++ b/components/LinkViews/LinkComponents/LinkActions.tsx@@ -55,7 +55,7 @@ export default function LinkActions({ link, collection, position }: Props) {};return (- <div>+ <><divclassName={`dropdown dropdown-left absolute ${position || "top-3 right-3"@@ -66,11 +66,7 @@ export default function LinkActions({ link, collection, position }: Props) {role="button"className="btn btn-ghost btn-sm btn-square text-neutral">- <i- id={"expand-dropdown" + collection.id}- title="More"- className="bi-three-dots text-xl"- />+ <i title="More" className="bi-three-dots text-xl" /></div><ul className="dropdown-content z-[20] menu shadow bg-base-200 border border-neutral-content rounded-box w-44 mr-1">{permissions === true ? (@@ -154,6 +150,6 @@ export default function LinkActions({ link, collection, position }: Props) {{/* {expandedLink ? (<ExpandedLink onClose={() => setExpandedLink(false)} link={link} />) : undefined} */}- </div>+ </>);}diff --git a/components/LinkViews/LinkComponents/LinkIcon.tsx b/components/LinkViews/LinkComponents/LinkIcon.tsxindex 4e423bfb..583d721d 100644--- a/components/LinkViews/LinkComponents/LinkIcon.tsx+++ b/components/LinkViews/LinkComponents/LinkIcon.tsx@@ -3,7 +3,10 @@ import Image from "next/image";import isValidUrl from "@/lib/shared/isValidUrl";import React from "react";-export default function LinkIcon({ link, width }: {+export default function LinkIcon({+ link,+ width,+}: {link: LinkIncludingShortenedCollectionAndTags;width?: string;}) {diff --git a/components/LinkViews/LinkGrid.tsx b/components/LinkViews/LinkGrid.tsxindex 89ebcf1a..ac8a31d7 100644--- a/components/LinkViews/LinkGrid.tsx+++ b/components/LinkViews/LinkGrid.tsx@@ -47,63 +47,57 @@ export default function LinkGrid({ link, count, className }: Props) {}, [collections, links]);return (- <div className="w-full border border-solid border-neutral-content bg-base-200 shadow-md hover:shadow-none duration-100 rounded-2xl relative">+ <div className="border border-solid border-neutral-content bg-base-200 shadow-md hover:shadow-none duration-100 rounded-2xl relative p-3"><divonClick={() => link.url && window.open(link.url || "", "_blank")}- className="flex items-center cursor-pointer p-3"+ className="cursor-pointer">- <div className="shrink-0">- <LinkIcon link={link} width="w-12" />- </div>-- <div className="w-[calc(100%-56px)] ml-2">- <p className="line-clamp-1 mr-8">- {unescapeString(link.name || link.description) || link.url}- </p>+ <LinkIcon link={link} width="w-12 mb-3" />+ <p className="truncate w-full">+ {unescapeString(link.name || link.description) || link.url}+ </p>- <div className="mt-1 flex flex-col sm:flex-row sm:items-center gap-2 text-xs text-neutral">- <div className="flex items-center gap-2">- <LinkCollection link={link} collection={collection} />- ·- {link.url ? (- <div+ <div className="mt-1 flex flex-col text-xs text-neutral">+ <div className="flex items-center gap-2">+ <LinkCollection link={link} collection={collection} />+ ·+ {link.url ? (+ <div+ onClick={(e) => {+ e.preventDefault();+ window.open(link.url || "", "_blank");+ }}+ className="flex items-center hover:opacity-60 cursor-pointer duration-100"+ >+ <p className="truncate">{shortendURL}</p>+ </div>+ ) : (+ <div className="badge badge-primary badge-sm my-1">+ {link.type}+ </div>+ )}+ </div>+ <LinkDate link={link} />+ </div>+ <p className="truncate">{unescapeString(link.description)}</p>+ {link.tags[0] ? (+ <div className="flex gap-3 items-center flex-wrap mt-2 truncate relative">+ <div className="flex gap-1 items-center flex-wrap">+ {link.tags.map((e, i) => (+ <Link+ href={"/tags/" + e.id}+ key={i}onClick={(e) => {- e.preventDefault();- window.open(link.url || "", "_blank");+ e.stopPropagation();}}- className="flex items-center hover:opacity-60 cursor-pointer duration-100"+ className="btn btn-xs btn-ghost truncate max-w-[19rem]">- <p className="truncate w-full">{shortendURL}</p>- </div>- ) : (- <div className="badge badge-primary badge-sm my-1">- {link.type}- </div>- )}+ #{e.name}+ </Link>+ ))}</div>- <span className="hidden sm:block">·</span>- <LinkDate link={link} /></div>- <p>{unescapeString(link.description)}</p>- {link.tags[0] ? (- <div className="flex gap-3 items-center flex-wrap mt-2 truncate relative">- <div className="flex gap-1 items-center flex-wrap">- {link.tags.map((e, i) => (- <Link- href={"/tags/" + e.id}- key={i}- onClick={(e) => {- e.stopPropagation();- }}- className="btn btn-xs btn-ghost truncate max-w-[19rem]"- >- #{e.name}- </Link>- ))}- </div>- </div>- ) : undefined}- </div>+ ) : undefined}</div><LinkActions link={link} collection={collection} />diff --git a/components/ViewDropdown.tsx b/components/ViewDropdown.tsxindex 2be399a7..23558d2d 100644--- a/components/ViewDropdown.tsx+++ b/components/ViewDropdown.tsx@@ -25,48 +25,36 @@ export default function ViewDropdown({ viewMode, setViewMode }: Props) {return (<div className="p-1 flex flex-row gap-1 border border-neutral-content rounded-[0.625rem]"><button- onClick={(e) => onChangeViewMode(e, ViewMode.Default)}- className={`p-2 rounded-md ${- viewMode == ViewMode.Default ? "bg-primary/20" : "hover:bg-neutral/20"+ onClick={(e) => onChangeViewMode(e, ViewMode.Card)}+ className={`btn btn-square btn-sm btn-ghost ${+ viewMode == ViewMode.Card+ ? "bg-primary/20 hover:bg-primary/20"+ : "hover:bg-neutral/20"}`}>- <svg- className="w-4 h-4 text-neutral"- viewBox="0 0 24 24"- fill="currentColor"- >- <path d="M10.93,14.44v5.45a1.38,1.38,0,0,1-1.37,1.37H4.11a1.38,1.38,0,0,1-1.37-1.37V14.44a1.38,1.38,0,0,1,1.37-1.37H9.56A1.38,1.38,0,0,1,10.93,14.44ZM9.56,2.74H4.11A1.38,1.38,0,0,0,2.74,4.11V9.56a1.38,1.38,0,0,0,1.37,1.37H9.56a1.38,1.38,0,0,0,1.37-1.37V4.11A1.38,1.38,0,0,0,9.56,2.74Zm11.7,17.15V14.44a1.38,1.38,0,0,0-1.37-1.37H14.44a1.38,1.38,0,0,0-1.37,1.37v5.45a1.38,1.38,0,0,0,1.37,1.37h5.45A1.38,1.38,0,0,0,21.26,19.89Zm0-10.33V4.11a1.38,1.38,0,0,0-1.37-1.37H14.44a1.38,1.38,0,0,0-1.37,1.37V9.56a1.38,1.38,0,0,0,1.37,1.37h5.45A1.38,1.38,0,0,0,21.26,9.56Z" />- </svg>+ <i className="bi-grid w-4 h-4 text-neutral"></i></button><buttononClick={(e) => onChangeViewMode(e, ViewMode.List)}- className={`p-2 rounded-md ${- viewMode == ViewMode.List ? "bg-primary/20" : "hover:bg-neutral/20"+ className={`btn btn-square btn-sm btn-ghost ${+ viewMode == ViewMode.List+ ? "bg-primary/20 hover:bg-primary/20"+ : "hover:bg-neutral/20"}`}>- <svg- className="w-4 h-4 text-neutral"- viewBox="0 0 24 24"- fill="currentColor"- >- <path d="M5.36,5A1.76,1.76,0,1,1,3.6,3.26,1.76,1.76,0,0,1,5.36,5ZM20.78,3.48H8.6A1.37,1.37,0,0,0,7.22,4.85v.33A1.37,1.37,0,0,0,8.6,6.55H20.78a1.37,1.37,0,0,0,1.37-1.37V4.85A1.37,1.37,0,0,0,20.78,3.48ZM3.6,10.24A1.76,1.76,0,1,0,5.36,12,1.75,1.75,0,0,0,3.6,10.24Zm17.18.22H8.6a1.38,1.38,0,0,0-1.38,1.37v.34A1.38,1.38,0,0,0,8.6,13.54H20.78a1.37,1.37,0,0,0,1.37-1.37v-.34A1.37,1.37,0,0,0,20.78,10.46ZM3.6,17.23A1.76,1.76,0,1,0,5.36,19,1.75,1.75,0,0,0,3.6,17.23Zm17.18.22H8.6a1.37,1.37,0,0,0-1.38,1.37v.33A1.37,1.37,0,0,0,8.6,20.52H20.78a1.37,1.37,0,0,0,1.37-1.37v-.33A1.37,1.37,0,0,0,20.78,17.45Z" />- </svg>+ <i className="bi bi-view-stacked w-4 h-4 text-neutral"></i></button>{/* <buttononClick={(e) => onChangeViewMode(e, ViewMode.Grid)}- className={`p-2 rounded-md ${- viewMode == ViewMode.Grid ? "bg-primary/20" : "hover:bg-neutral/20"+ className={`btn btn-square btn-sm btn-ghost ${+ viewMode == ViewMode.Grid+ ? "bg-primary/20 hover:bg-primary/20"+ : "hover:bg-neutral/20"}`}>- <svg- className="w-4 h-4 text-neutral"- viewBox="0 0 24 24"- fill="currentColor"- >- <path d="M14.34,11V13A1.37,1.37,0,0,1,13,14.34H11A1.37,1.37,0,0,1,9.66,13V11A1.37,1.37,0,0,1,11,9.66H13A1.37,1.37,0,0,1,14.34,11ZM13,2.74H11A1.37,1.37,0,0,0,9.66,4.11V6.06A1.37,1.37,0,0,0,11,7.43H13a1.37,1.37,0,0,0,1.37-1.37V4.11A1.37,1.37,0,0,0,13,2.74ZM21.26,13V11a1.37,1.37,0,0,0-1.37-1.37H17.94A1.37,1.37,0,0,0,16.57,11V13a1.37,1.37,0,0,0,1.37,1.37h1.95A1.37,1.37,0,0,0,21.26,13ZM11,21.26H13a1.37,1.37,0,0,0,1.37-1.37V17.94A1.37,1.37,0,0,0,13,16.57H11a1.37,1.37,0,0,0-1.37,1.37v1.95A1.37,1.37,0,0,0,11,21.26ZM2.74,11V13a1.37,1.37,0,0,0,1.37,1.37H6.06A1.37,1.37,0,0,0,7.43,13V11A1.37,1.37,0,0,0,6.06,9.66H4.11A1.37,1.37,0,0,0,2.74,11Zm18.52-5V4.11a1.38,1.38,0,0,0-1.37-1.37H17.94a1.38,1.38,0,0,0-1.37,1.37V6.06a1.38,1.38,0,0,0,1.37,1.37h1.95A1.38,1.38,0,0,0,21.26,6.06ZM2.74,4.11V6.06A1.38,1.38,0,0,0,4.11,7.43H6.06A1.38,1.38,0,0,0,7.43,6.06V4.11A1.38,1.38,0,0,0,6.06,2.74H4.11A1.38,1.38,0,0,0,2.74,4.11ZM21.26,19.89V17.94a1.38,1.38,0,0,0-1.37-1.37H17.94a1.38,1.38,0,0,0-1.37,1.37v1.95a1.38,1.38,0,0,0,1.37,1.37h1.95A1.38,1.38,0,0,0,21.26,19.89ZM2.74,17.94v1.95a1.38,1.38,0,0,0,1.37,1.37H6.06a1.38,1.38,0,0,0,1.37-1.37V17.94a1.38,1.38,0,0,0-1.37-1.37H4.11A1.38,1.38,0,0,0,2.74,17.94Z" />- </svg>+ <i className="bi-columns-gap w-4 h-4 text-neutral"></i></button> */}</div>);diff --git a/pages/collections/[id].tsx b/pages/collections/[id].tsxindex 9df58197..aa8ebd78 100644--- a/pages/collections/[id].tsx+++ b/pages/collections/[id].tsx@@ -1,4 +1,3 @@-import LinkCard from "@/components/LinkViews/LinkCard";import useCollectionStore from "@/store/collections";import useLinkStore from "@/store/links";import {@@ -22,7 +21,7 @@ import EditCollectionSharingModal from "@/components/ModalContent/EditCollectionimport DeleteCollectionModal from "@/components/ModalContent/DeleteCollectionModal";import ViewDropdown from "@/components/ViewDropdown";import CardView from "@/components/LinkViews/Layouts/CardView";-import GridView from "@/components/LinkViews/Layouts/GridView";+// import GridView from "@/components/LinkViews/Layouts/GridView";import ListView from "@/components/LinkViews/Layouts/ListView";export default function Index() {@@ -87,11 +86,11 @@ export default function Index() {const [deleteCollectionModal, setDeleteCollectionModal] = useState(false);const [viewMode, setViewMode] = useState<string>(- localStorage.getItem("viewMode") || ViewMode.Default+ localStorage.getItem("viewMode") || ViewMode.Card);const linkView = {- [ViewMode.Default]: CardView,+ [ViewMode.Card]: CardView,// [ViewMode.Grid]: GridView,[ViewMode.List]: ListView,};diff --git a/pages/links/index.tsx b/pages/links/index.tsxindex 40d59f1e..91693985 100644--- a/pages/links/index.tsx+++ b/pages/links/index.tsx@@ -15,14 +15,14 @@ export default function Links() {const { links } = useLinkStore();const [viewMode, setViewMode] = useState<string>(- localStorage.getItem("viewMode") || ViewMode.Default+ localStorage.getItem("viewMode") || ViewMode.Card);const [sortBy, setSortBy] = useState<Sort>(Sort.DateNewestFirst);useLinks({ sort: sortBy });const linkView = {- [ViewMode.Default]: CardView,+ [ViewMode.Card]: CardView,// [ViewMode.Grid]: GridView,[ViewMode.List]: ListView,};diff --git a/pages/links/pinned.tsx b/pages/links/pinned.tsxindex 2c754a45..c6b5ee06 100644--- a/pages/links/pinned.tsx+++ b/pages/links/pinned.tsx@@ -8,19 +8,20 @@ import { Sort, ViewMode } from "@/types/global";import ViewDropdown from "@/components/ViewDropdown";import CardView from "@/components/LinkViews/Layouts/CardView";import ListView from "@/components/LinkViews/Layouts/ListView";+// import GridView from "@/components/LinkViews/Layouts/GridView";export default function PinnedLinks() {const { links } = useLinkStore();const [viewMode, setViewMode] = useState<string>(- localStorage.getItem("viewMode") || ViewMode.Default+ localStorage.getItem("viewMode") || ViewMode.Card);const [sortBy, setSortBy] = useState<Sort>(Sort.DateNewestFirst);useLinks({ sort: sortBy, pinnedOnly: true });const linkView = {- [ViewMode.Default]: CardView,+ [ViewMode.Card]: CardView,// [ViewMode.Grid]: GridView,[ViewMode.List]: ListView,};diff --git a/pages/search.tsx b/pages/search.tsxindex c8b9f1b3..32dbf969 100644--- a/pages/search.tsx+++ b/pages/search.tsx@@ -8,7 +8,7 @@ import { useRouter } from "next/router";import React, { useState } from "react";import ViewDropdown from "@/components/ViewDropdown";import CardView from "@/components/LinkViews/Layouts/CardView";-import GridView from "@/components/LinkViews/Layouts/GridView";+// import GridView from "@/components/LinkViews/Layouts/GridView";import ListView from "@/components/LinkViews/Layouts/ListView";import PageHeader from "@/components/PageHeader";@@ -28,7 +28,7 @@ export default function Search() {const [filterDropdown, setFilterDropdown] = useState(false);const [viewMode, setViewMode] = useState<string>(- localStorage.getItem("viewMode") || ViewMode.Default+ localStorage.getItem("viewMode") || ViewMode.Card);const [sortBy, setSortBy] = useState<Sort>(Sort.DateNewestFirst);@@ -43,7 +43,7 @@ export default function Search() {});const linkView = {- [ViewMode.Default]: CardView,+ [ViewMode.Card]: CardView,// [ViewMode.Grid]: GridView,[ViewMode.List]: ListView,};diff --git a/pages/tags/[id].tsx b/pages/tags/[id].tsxindex 52f134e6..a4cbb69b 100644--- a/pages/tags/[id].tsx+++ b/pages/tags/[id].tsx@@ -9,7 +9,7 @@ import useLinks from "@/hooks/useLinks";import { toast } from "react-hot-toast";import ViewDropdown from "@/components/ViewDropdown";import CardView from "@/components/LinkViews/Layouts/CardView";-import GridView from "@/components/LinkViews/Layouts/GridView";+// import GridView from "@/components/LinkViews/Layouts/GridView";import ListView from "@/components/LinkViews/Layouts/ListView";export default function Index() {@@ -91,11 +91,11 @@ export default function Index() {};const [viewMode, setViewMode] = useState<string>(- localStorage.getItem("viewMode") || ViewMode.Default+ localStorage.getItem("viewMode") || ViewMode.Card);const linkView = {- [ViewMode.Default]: CardView,+ [ViewMode.Card]: CardView,// [ViewMode.Grid]: GridView,[ViewMode.List]: ListView,};diff --git a/types/global.ts b/types/global.tsindex 49505bda..8b3efcfc 100644--- a/types/global.ts+++ b/types/global.ts@@ -58,7 +58,7 @@ export interface PublicCollectionIncludingLinks extends Collection {}export enum ViewMode {- Default = "default",+ Card = "card",Grid = "grid",List = "list",}