forked from CaliCastle/cali.so
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4c2d0e0
commit 0f4636c
Showing
7 changed files
with
139 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
.next |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import Image from 'next/image' | ||
import Link from 'next/link' | ||
|
||
import { | ||
CalendarIcon, | ||
CursorClickIcon, | ||
HourglassIcon, | ||
ScriptIcon, | ||
} from '~/assets' | ||
import { prettifyNumber } from '~/lib/math' | ||
import { type Post } from '~/sanity/schemas/post' | ||
|
||
export function BlogPostCard({ post, views }: { post: Post; views: number }) { | ||
const { title, slug, mainImage, publishedAt, categories, readingTime } = post | ||
|
||
return ( | ||
<Link | ||
href={`/blog/${slug}`} | ||
prefetch={false} | ||
className="group relative w-full rounded-3xl bg-transparent ring-2 ring-zinc-800/10 dark:ring-zinc-200/10" | ||
style={ | ||
{ | ||
'--post-image-fg': mainImage.asset.dominant?.foreground, | ||
'--post-image-bg': mainImage.asset.dominant?.background, | ||
'--post-image': `url(${mainImage.asset.url}`, | ||
} as React.CSSProperties | ||
} | ||
> | ||
<div className="relative aspect-[240/135] w-full"> | ||
<Image | ||
src={mainImage.asset.url} | ||
alt="" | ||
className="rounded-t-3xl object-cover" | ||
placeholder="blur" | ||
blurDataURL={mainImage.asset.lqip} | ||
fill | ||
sizes="(max-width: 768px) 100vw, (max-width: 1200px) 50vw" | ||
/> | ||
</div> | ||
<span className="relative z-10 flex w-full flex-col gap-0.5 rounded-b-3xl bg-cover bg-bottom bg-no-repeat p-4 bg-blend-overlay [background-image:var(--post-image)] before:pointer-events-none before:absolute before:inset-0 before:z-10 before:select-none before:rounded-b-3xl before:bg-[--post-image-bg] before:opacity-70 before:transition-opacity after:pointer-events-none after:absolute after:inset-0 after:z-10 after:select-none after:rounded-b-3xl after:bg-gradient-to-b after:from-transparent after:to-[--post-image-bg] after:backdrop-blur after:transition-opacity group-hover:before:opacity-30 md:p-5"> | ||
<h2 className="z-20 text-base font-bold tracking-tight text-[--post-image-fg] mix-blend-overlay md:text-xl"> | ||
{title} | ||
</h2> | ||
|
||
<span className="relative z-20 flex items-center justify-between mix-blend-overlay"> | ||
<span className="inline-flex items-center space-x-3"> | ||
<span className="inline-flex items-center space-x-1 text-[12px] font-medium text-[--post-image-fg] opacity-80 transition-opacity group-hover:opacity-100 md:text-sm"> | ||
<CalendarIcon /> | ||
<span> | ||
{Intl.DateTimeFormat('zh').format(new Date(publishedAt))} | ||
</span> | ||
</span> | ||
|
||
<span className="inline-flex items-center space-x-1 text-[12px] font-medium text-[--post-image-fg] opacity-80 transition-opacity group-hover:opacity-100 md:text-sm"> | ||
<ScriptIcon /> | ||
<span>{categories.join(', ')}</span> | ||
</span> | ||
</span> | ||
<span className="inline-flex items-center space-x-3 text-[12px] font-medium text-[--post-image-fg] opacity-80 transition-opacity group-hover:opacity-100 md:text-xs"> | ||
<span className="inline-flex items-center space-x-1"> | ||
<CursorClickIcon /> | ||
<span>{prettifyNumber(views, true)}</span> | ||
</span> | ||
|
||
<span className="inline-flex items-center space-x-1"> | ||
<HourglassIcon /> | ||
<span>{readingTime.toFixed(0)}分钟阅读</span> | ||
</span> | ||
</span> | ||
</span> | ||
</span> | ||
</Link> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import * as React from 'react' | ||
import ReactMarkdown from 'react-markdown' | ||
|
||
import { Heading, Section } from './_components' | ||
import { Layout } from './Layout' | ||
|
||
const NewslettersTemplate = (props: { | ||
subject?: string | null | ||
body?: string | null | ||
}) => { | ||
const { | ||
subject = '测试主题', | ||
body = `# 你好,世界 | ||
- 你好 | ||
- 世界 | ||
`, | ||
} = props | ||
|
||
return ( | ||
<Layout previewText={subject ?? ''}> | ||
<Heading>{subject}</Heading> | ||
|
||
{body && ( | ||
<Section className="px-2 text-[14px] leading-[16px] text-zinc-700"> | ||
<ReactMarkdown>{body}</ReactMarkdown> | ||
</Section> | ||
)} | ||
</Layout> | ||
) | ||
} | ||
|
||
export default NewslettersTemplate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters