feat: social media item
This commit is contained in:
@@ -6,7 +6,7 @@ export function ArticleItem({
|
||||
entry: any,
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
<div className='flex px-2 py-3'>
|
||||
<img
|
||||
src={`https://icons.duckduckgo.com/ip3/${new URL(entry.feed.site_url).host}.ico`}
|
||||
className="w-5 h-5 mr-2 rounded-sm shrink-0"
|
||||
@@ -15,8 +15,7 @@ export function ArticleItem({
|
||||
<div className="text-zinc-500 text-[13px]">
|
||||
{dayjs
|
||||
.duration(dayjs(entry.published_at).diff(dayjs(), 'minute'), 'minute')
|
||||
.humanize()}{' '}
|
||||
ago
|
||||
.humanize()}
|
||||
</div>
|
||||
<div className="font-medium">{entry.title}</div>
|
||||
<div className="text-zinc-500 text-[13px] mt-0.5">{entry.text}</div>
|
||||
@@ -28,6 +27,6 @@ export function ArticleItem({
|
||||
loading="lazy"
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import { ActivedList } from '@renderer/lib/types'
|
||||
import { m } from 'framer-motion'
|
||||
import { cn } from '@renderer/lib/utils'
|
||||
import { ArticleItem } from './article-item'
|
||||
import { SocialMediaItem } from './social-media-item'
|
||||
|
||||
export function EntryColumn({
|
||||
activedList,
|
||||
@@ -14,10 +15,22 @@ export function EntryColumn({
|
||||
setActivedEntry: (value: number | null) => void
|
||||
}) {
|
||||
const entries = useEntries({
|
||||
type: activedList?.level,
|
||||
level: activedList?.level,
|
||||
id: activedList?.id
|
||||
})
|
||||
|
||||
let Item;
|
||||
switch (activedList?.type) {
|
||||
case 'Articles':
|
||||
Item = ArticleItem
|
||||
break
|
||||
case 'Social Media':
|
||||
Item = SocialMediaItem
|
||||
break
|
||||
default:
|
||||
Item = ArticleItem
|
||||
}
|
||||
|
||||
return (
|
||||
<div className='px-2' onClick={() => setActivedEntry(null)}>
|
||||
<div className="ml-9">
|
||||
@@ -30,20 +43,25 @@ export function EntryColumn({
|
||||
{entries.data?.pages?.map((page, index) => (
|
||||
<m.div
|
||||
key={`${activedList?.level}-${activedList?.id}-${index}`}
|
||||
initial={{ y: 100, opacity: 0 }}
|
||||
animate={{ y: 0, opacity: 1 }}
|
||||
exit={{ y: -100, opacity: 0 }}
|
||||
transition={{
|
||||
type: 'tween',
|
||||
duration: 0.1,
|
||||
ease: 'easeInOut',
|
||||
}}
|
||||
initial={{ opacity: 0 }}
|
||||
animate={{ opacity: 1 }}
|
||||
exit={{ opacity: 0 }}
|
||||
>
|
||||
{page.entries.map((entry) => (
|
||||
<div
|
||||
key={entry.id}
|
||||
className={cn("mt-5 flex px-2 py-3 rounded-md cursor-pointer", activedEntry === entry.id && 'bg-[#DEDDDC]')}
|
||||
className={cn("mt-5 rounded-md cursor-pointer", activedEntry === entry.id && 'bg-[#DEDDDC]')}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
setActivedEntry(entry.id)
|
||||
}}
|
||||
>
|
||||
<ArticleItem entry={entry} />
|
||||
<Item entry={entry} />
|
||||
</div>
|
||||
))}
|
||||
</m.div>
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
import dayjs from '@renderer/lib/dayjs'
|
||||
|
||||
export function SocialMediaItem({
|
||||
entry,
|
||||
}: {
|
||||
entry: any,
|
||||
}) {
|
||||
return (
|
||||
<div className='flex px-2 py-3'>
|
||||
<img
|
||||
src={`https://icons.duckduckgo.com/ip3/${new URL(entry.feed.site_url).host}.ico`}
|
||||
className="w-5 h-5 mr-2 rounded-sm shrink-0"
|
||||
/>
|
||||
<div>
|
||||
<div className="line-clamp-5 text-sm flex-1 -mt-0.5 leading-tight text-[13px]">
|
||||
<div className='space-x-1'>
|
||||
<span className='font-medium'>{entry.author}</span>
|
||||
<span className="text-zinc-500">·</span>
|
||||
<span className="text-zinc-500">
|
||||
{dayjs
|
||||
.duration(dayjs(entry.published_at).diff(dayjs(), 'minute'), 'minute')
|
||||
.humanize()}
|
||||
</span>
|
||||
</div>
|
||||
<div className="mt-0.5">{entry.text}</div>
|
||||
</div>
|
||||
<div className='flex gap-2 overflow-x-auto mt-1'>
|
||||
{entry.images?.map((image) => (
|
||||
<img
|
||||
key={image}
|
||||
src={image}
|
||||
className="w-20 h-20 shrink-0 rounded object-cover"
|
||||
loading="lazy"
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -2,19 +2,19 @@ import { useInfiniteQuery } from '@tanstack/react-query'
|
||||
import { parseHtml } from './parse-html'
|
||||
|
||||
export const useEntries = ({
|
||||
type,
|
||||
level,
|
||||
id,
|
||||
}: {
|
||||
type?: string
|
||||
level?: string
|
||||
id?: number | string
|
||||
}) =>
|
||||
useInfiniteQuery({
|
||||
queryKey: ['entries', type, id],
|
||||
enabled: !!type && !!id,
|
||||
queryKey: ['entries', level, id],
|
||||
enabled: !!level && !!id,
|
||||
queryFn: async ({ pageParam }) => {
|
||||
const entries = await (await fetch(`${import.meta.env.VITE_MINIFLUX_ENDPOINT}/v1/categories/${id}/entries?` + new URLSearchParams({
|
||||
direction: 'desc',
|
||||
limit: '20',
|
||||
limit: '10',
|
||||
after_entry_id: pageParam,
|
||||
}), {
|
||||
headers: {
|
||||
|
||||
Reference in New Issue
Block a user