Skip to content

Commit 6f187ec

Browse files
committed
feat: note
Signed-off-by: Innei <[email protected]>
1 parent d3b1e49 commit 6f187ec

File tree

1 file changed

+81
-9
lines changed

1 file changed

+81
-9
lines changed

src/app/(home)/page.tsx

+81-9
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ import Link from 'next/link'
88
import type { PropsWithChildren } from 'react'
99

1010
import { MotionButtonBase } from '~/components/ui/button'
11+
import { RelativeTime } from '~/components/ui/relative-time'
1112
import { BottomToUpTransitionView } from '~/components/ui/transition/BottomToUpTransitionView'
1213
import { TextUpTransitionView } from '~/components/ui/transition/TextUpTransitionView'
1314
import { isSupportIcon, SocialIcon } from '~/components/widgets/home/SocialIcon'
15+
import { PeekLink } from '~/components/widgets/peek/PeekLink'
1416
import { PostMetaBar } from '~/components/widgets/post'
1517
import { softBouncePrest, softSpringPreset } from '~/constants/spring'
1618
import { useConfig } from '~/hooks/data/use-config'
@@ -70,18 +72,27 @@ export default function Home() {
7072
}
7173
const TwoColumnLayout = ({
7274
children,
75+
leftContainerClassName,
76+
rightContainerClassName,
7377
}: {
7478
children:
7579
| [React.ReactNode, React.ReactNode]
7680
| [React.ReactNode, React.ReactNode, React.ReactNode]
81+
82+
leftContainerClassName?: string
83+
rightContainerClassName?: string
7784
}) => {
7885
return (
7986
<div className="relative flex h-full w-full flex-col flex-wrap items-center lg:flex-row">
8087
{children.slice(0, 2).map((child, i) => {
8188
return (
8289
<div
8390
key={i}
84-
className="flex h-1/2 w-full flex-col center lg:h-auto lg:w-1/2"
91+
className={clsxm(
92+
'flex h-1/2 w-full flex-col center lg:h-auto lg:w-1/2',
93+
94+
i === 0 ? leftContainerClassName : rightContainerClassName,
95+
)}
8596
>
8697
<div className="relative max-w-full lg:max-w-xl ">{child}</div>
8798
</div>
@@ -197,8 +208,8 @@ const Welcome = () => {
197208
const PostScreen = () => {
198209
const { posts } = useHomeQueryData()
199210
return (
200-
<Screen>
201-
<TwoColumnLayout>
211+
<Screen className="h-[120vh]">
212+
<TwoColumnLayout leftContainerClassName="h-1/4 lg:h-1/2">
202213
<m.h2
203214
initial={{
204215
opacity: 0.0001,
@@ -303,15 +314,76 @@ const PostScreen = () => {
303314

304315
const NoteScreen = () => {
305316
const { notes } = useHomeQueryData()
317+
const theLast = notes[0]
318+
319+
const hasHistory = notes.length > 1
320+
321+
const history = hasHistory ? notes.slice(1) : []
322+
323+
if (!theLast) return null
306324
return (
307325
<Screen>
308-
<TwoColumnLayout>
326+
<TwoColumnLayout leftContainerClassName="block lg:flex">
309327
<div>
310-
<ul>
311-
{notes.map((note) => {
312-
return <li key={note.id}>{note.title}</li>
313-
})}
314-
</ul>
328+
<section className="flex flex-col justify-end">
329+
<h3 className="mb-6 text-center text-xl">
330+
看看我的近况,这是我最近的所思所想
331+
</h3>
332+
<div
333+
className={clsx(
334+
'relative flex h-[150px] w-full rounded-md ring-1 ring-slate-200 center dark:ring-neutral-800',
335+
'hover:shadow-md hover:shadow-slate-100 dark:hover:shadow-neutral-900',
336+
)}
337+
>
338+
<Link href={routeBuilder(Routes.Note, { id: theLast.nid })}>
339+
<div className="absolute bottom-6 right-6 ">
340+
<h4 className="font-2xl text-lg font-medium ">
341+
{theLast.title}
342+
</h4>
343+
344+
<small className="mt-1 block w-full text-right">
345+
<RelativeTime date={theLast.created} />
346+
</small>
347+
</div>
348+
</Link>
349+
350+
{!!theLast.images?.[0]?.src && (
351+
<div
352+
className="absolute inset-0 bg-cover bg-center"
353+
style={{
354+
background: `url(${theLast.images[0].src})`,
355+
}}
356+
/>
357+
)}
358+
</div>
359+
</section>
360+
361+
{hasHistory && (
362+
<section className="mt-[20%]">
363+
<div className="text-lg opacity-80">这里还有一些历史回顾</div>
364+
<ul className="shiro-timeline mt-4">
365+
{history.map((note) => {
366+
return (
367+
<li key={note.id} className="flex min-w-0 justify-between">
368+
<PeekLink
369+
className="min-w-0 flex-shrink truncate"
370+
href={routeBuilder(Routes.Note, { id: note.nid })}
371+
>
372+
{note.title}
373+
</PeekLink>
374+
375+
<span className="ml-2 flex-shrink-0 self-end text-xs opacity-70">
376+
<RelativeTime
377+
date={note.created}
378+
displayAbsoluteTimeAfterDay={180}
379+
/>
380+
</span>
381+
</li>
382+
)
383+
})}
384+
</ul>
385+
</section>
386+
)}
315387
</div>
316388
<h2 className="text-2xl font-medium leading-loose">
317389
而在这里,你会看到一个不同的我,

0 commit comments

Comments
 (0)