From 74cf57a08d4c8f5f45c7f7fac775430779797eee Mon Sep 17 00:00:00 2001 From: DIYgod Date: Wed, 12 Jul 2023 00:15:35 +0100 Subject: [PATCH] feat: generate default post cover --- package.json | 1 + pnpm-lock.yaml | 7 +++++++ src/components/home/HomeFeed.tsx | 8 ++------ src/components/home/PostCover.tsx | 26 +++++++++++++++++++++++++- 4 files changed, 35 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 9b7ca8d4..513abe79 100644 --- a/package.json +++ b/package.json @@ -149,6 +149,7 @@ "tailwind-scrollbar-hide": "1.1.7", "tailwindcss-animate": "1.0.6", "unified": "10.1.2", + "uniqolor": "^1.1.0", "unist-builder": "4.0.0", "unist-util-visit": "5.0.0", "use-onclickoutside": "0.4.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 55e1e171..9f1095e7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -362,6 +362,9 @@ dependencies: unified: specifier: 10.1.2 version: 10.1.2 + uniqolor: + specifier: ^1.1.0 + version: 1.1.0 unist-builder: specifier: 4.0.0 version: 4.0.0 @@ -12891,6 +12894,10 @@ packages: vfile: 5.3.7 dev: false + /uniqolor@1.1.0: + resolution: {integrity: sha512-j2XyokF24fsj+L5u6fbu4rM3RQc6VWJuAngYM2k0ZdG3yiVxt0smLkps2GmQIYqK8VkELGdM9vFU/HfOkK/zoQ==} + dev: false + /unique-string@2.0.0: resolution: {integrity: sha512-uNaeirEPvpZWSgzwsPGtU2zVSTrn/8L5q/IexZmH0eH6SA73CmAA5U4GwORTxQAZs95TAXLNqeLoPPNO5gZfWg==} engines: {node: '>=8'} diff --git a/src/components/home/HomeFeed.tsx b/src/components/home/HomeFeed.tsx index e3a6daaa..c201ab98 100644 --- a/src/components/home/HomeFeed.tsx +++ b/src/components/home/HomeFeed.tsx @@ -20,7 +20,6 @@ import { Tabs } from "~/components/ui/Tabs" import { Tooltip } from "~/components/ui/Tooltip" import { useDate } from "~/hooks/useDate" import { useIsMobileLayout } from "~/hooks/useMobileLayout" -import { DEFAULT_AVATAR } from "~/lib/env" import { getSiteLink } from "~/lib/helpers" import { useTranslation } from "~/lib/i18n/client" import { getStorage, setStorage } from "~/lib/storage" @@ -62,11 +61,8 @@ const PostCard = ({ )} >
diff --git a/src/components/home/PostCover.tsx b/src/components/home/PostCover.tsx index d014f3da..f2e01d89 100644 --- a/src/components/home/PostCover.tsx +++ b/src/components/home/PostCover.tsx @@ -1,13 +1,37 @@ +import uniqolor from "uniqolor" + import { Image } from "~/components/ui/Image" export default function PostCover({ cover, priority, + title, }: { cover?: string priority?: boolean + title?: string }) { - if (!cover) return null + if (!cover) { + if (title) { + return ( + <> +
+
{title}
+
+ + ) + } else { + return null + } + } return ( <>