diff --git a/src/components/home/HomeFeed.tsx b/src/components/home/HomeFeed.tsx index 13d389e3..1bb0e07c 100644 --- a/src/components/home/HomeFeed.tsx +++ b/src/components/home/HomeFeed.tsx @@ -19,7 +19,7 @@ import { useDate } from "~/hooks/useDate" import { useTranslation } from "~/lib/i18n/client" import { getStorage, setStorage } from "~/lib/storage" import { ExpandedNote } from "~/lib/types" -import { cn } from "~/lib/utils" +import { cn, getStringLength } from "~/lib/utils" import type { FeedType, SearchType } from "~/models/home.model" import { useGetFeed } from "~/queries/home" @@ -146,6 +146,12 @@ const Post = ({ if (post.toNote?.metadata?.content?.tags?.includes("comment")) { return null } + if ( + !post.metadata?.content?.summary || + getStringLength(post.metadata.content.summary) < 6 + ) { + return null + } } return ( diff --git a/src/lib/utils.ts b/src/lib/utils.ts index e100112a..dad3758a 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -48,3 +48,16 @@ export const calculateElementTop = (el: HTMLElement) => { } return top } + +export function getStringLength(str: string) { + let len = 0 + for (let i = 0; i < str.length; i++) { + const code = str.charCodeAt(i) + if (code >= 0 && code <= 128) { + len += 1 + } else { + len += 2 + } + } + return len +}