+
+
Description
+
+
+
+ {link.description ? (
+ unescapeString(link.description)
+ ) : (
+
+ No description provided.
+
+ )}
+
{link.tags[0] ? (
-
-
- {link.tags.map((e, i) => (
-
{
- e.stopPropagation();
- }}
- className="btn btn-xs btn-ghost truncate max-w-[19rem]"
- >
- #{e.name}
-
- ))}
+ <>
+
+ Tags
+
+
+
+
+
+
+ {link.tags.map((e, i) => (
+ {
+ e.stopPropagation();
+ }}
+ className="btn btn-xs btn-ghost truncate max-w-[19rem]"
+ >
+ #{e.name}
+
+ ))}
+
-
+ >
) : undefined}
diff --git a/components/PublicPage/PublicLinkCard.tsx b/components/PublicPage/PublicLinkCard.tsx
deleted file mode 100644
index 97c95861..00000000
--- a/components/PublicPage/PublicLinkCard.tsx
+++ /dev/null
@@ -1,132 +0,0 @@
-import Image from "next/image";
-import { Link as LinkType, Tag } from "@prisma/client";
-import isValidUrl from "@/lib/shared/isValidUrl";
-import unescapeString from "@/lib/client/unescapeString";
-import { TagIncludingLinkCount } from "@/types/global";
-import Link from "next/link";
-import { useState } from "react";
-import PreservedFormatsModal from "../ModalContent/PreservedFormatsModal";
-
-interface LinksIncludingTags extends LinkType {
- tags: TagIncludingLinkCount[];
-}
-
-type Props = {
- link: LinksIncludingTags;
- count: number;
-};
-
-export default function LinkCard({ link, count }: Props) {
- const url = link.url && isValidUrl(link.url) ? new URL(link.url) : undefined;
-
- const formattedDate = new Date(
- link.createdAt as unknown as string
- ).toLocaleString("en-US", {
- year: "numeric",
- month: "short",
- day: "numeric",
- });
-
- const [preservedFormatsModal, setPreservedFormatsModal] = useState(false);
-
- return (
-
-
-
-
-
- {url && (
- {
- const target = e.target as HTMLElement;
- target.style.display = "none";
- }}
- />
- )}
- {unescapeString(link.name || link.description)}
-
-
-
-
-
- {link.tags.map((e, i) => (
-
- #{e.name}
-
- ))}
-
-
-
-
{formattedDate}
-
ยท
-
- {url ? url.host : link.url}
-
-
-
- {unescapeString(link.description)}{" "}
-
-
Visit
-
-
-
-
-
-
- {preservedFormatsModal ? (
-
setPreservedFormatsModal(false)}
- activeLink={link as any}
- />
- ) : undefined}
-
- );
-}
diff --git a/pages/public/collections/[id].tsx b/pages/public/collections/[id].tsx
index 586ca4ac..7220615e 100644
--- a/pages/public/collections/[id].tsx
+++ b/pages/public/collections/[id].tsx
@@ -1,7 +1,10 @@
"use client";
-import PublicLinkCard from "@/components/PublicPage/PublicLinkCard";
import getPublicCollectionData from "@/lib/client/getPublicCollectionData";
-import { CollectionIncludingMembersAndLinkCount, Sort } from "@/types/global";
+import {
+ CollectionIncludingMembersAndLinkCount,
+ Sort,
+ ViewMode,
+} from "@/types/global";
import { useRouter } from "next/router";
import React, { useEffect, useState } from "react";
import { motion, Variants } from "framer-motion";
@@ -18,6 +21,10 @@ import SortDropdown from "@/components/SortDropdown";
import useLocalSettingsStore from "@/store/localSettings";
import SearchBar from "@/components/SearchBar";
import EditCollectionSharingModal from "@/components/ModalContent/EditCollectionSharingModal";
+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";
const cardVariants: Variants = {
offscreen: {
@@ -94,6 +101,19 @@ export default function PublicCollections() {
const [editCollectionSharingModal, setEditCollectionSharingModal] =
useState(false);
+ const [viewMode, setViewMode] = useState
(
+ localStorage.getItem("viewMode") || ViewMode.Card
+ );
+
+ const linkView = {
+ [ViewMode.Card]: CardView,
+ // [ViewMode.Grid]: GridView,
+ [ViewMode.List]: ListView,
+ };
+
+ // @ts-ignore
+ const LinkComponent = linkView[viewMode];
+
return collection ? (
-
+
-
-
- {links
- ?.filter((e) => e.collectionId === Number(router.query.id))
- .map((e, i) => {
- const linkWithCollectionData = {
- ...e,
- collection: collection, // Append collection data
- };
-
- return (
-
-
-
-
-
- );
- })}
-
+ {links[0] ? (
+
e.collectionId === Number(router.query.id))
+ .map((e, i) => {
+ const linkWithCollectionData = {
+ ...e,
+ collection: collection, // Append collection data
+ };
+ return linkWithCollectionData;
+ })}
+ />
+ ) : (
+ This collection is empty...
+ )}
{/*
List created with Linkwarden.