Skip to content

Commit 9e80d70

Browse files
committed
feat: search panel
Signed-off-by: Innei <[email protected]>
1 parent 41f40ef commit 9e80d70

File tree

9 files changed

+386
-11
lines changed

9 files changed

+386
-11
lines changed

src/app/(page-detail)/[slug]/pageExtra.tsx

+9-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,14 @@ export const PostMarkdown = () => {
2929
const text = useCurrentPageDataSelector((data) => data?.text)
3030
if (!text) return null
3131

32-
return <Markdown value={text} as="main" className="min-w-0 overflow-hidden" />
32+
return (
33+
<Markdown
34+
allowsScript
35+
value={text}
36+
as="main"
37+
className="min-w-0 overflow-hidden"
38+
/>
39+
)
3340
}
3441
export const MarkdownImageRecordProviderInternal = (
3542
props: PropsWithChildren,
@@ -90,7 +97,7 @@ export const PagePaginator = () => {
9097
const hasNext = indexInPages + 1 < n
9198
const hasPrev = indexInPages - 1 >= 0
9299
return (
93-
<div className="relative grid h-20 select-none grid-cols-2">
100+
<div className="relative mt-8 grid h-20 select-none grid-cols-2">
94101
<div className="justify-start">
95102
{hasPrev && (
96103
<Fragment>

src/app/friends/page.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export default function Page() {
3434
},
3535
staleTime: Infinity,
3636
cacheTime: Infinity,
37-
select(data) {
37+
select: useCallback((data: LinkModel[]) => {
3838
const friends: LinkModel[] = []
3939
const collections: LinkModel[] = []
4040
const outdated: LinkModel[] = []
@@ -66,7 +66,7 @@ export default function Page() {
6666
}
6767

6868
return { friends: shuffle(friends), collections, outdated, banned }
69-
},
69+
}, []),
7070
})
7171

7272
if (isLoading) return <Loading useDefaultLoadingText />

src/app/notes/[id]/page.tsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,14 @@ const NoteHeaderDate = () => {
169169
const NoteMarkdown = () => {
170170
const text = useCurrentNoteDataSelector((data) => data?.data.text)!
171171

172-
return <Markdown as="main" renderers={MarkdownRenderers} value={text} />
172+
return (
173+
<Markdown
174+
allowsScript
175+
as="main"
176+
renderers={MarkdownRenderers}
177+
value={text}
178+
/>
179+
)
173180
}
174181
const NoteMarkdownImageRecordProvider = (props: PropsWithChildren) => {
175182
const images = useCurrentNoteDataSelector(

src/app/posts/(post-detail)/[category]/[slug]/page.tsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,14 @@ const PostMarkdown = () => {
7474
const text = useCurrentPostDataSelector((data) => data?.text)
7575
if (!text) return null
7676

77-
return <Markdown value={text} as="main" className="min-w-0 overflow-hidden" />
77+
return (
78+
<Markdown
79+
allowsScript
80+
value={text}
81+
as="main"
82+
className="min-w-0 overflow-hidden"
83+
/>
84+
)
7885
}
7986
const PostMarkdownImageRecordProvider = (props: PropsWithChildren) => {
8087
const images = useCurrentPostDataSelector(

src/app/posts/page.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { PostItem } from '~/components/widgets/post/PostItem'
44
import { PostPagination } from '~/components/widgets/post/PostPagination'
55
import { PostTagsFAB } from '~/components/widgets/post/PostTagsFAB'
66
import { NothingFound } from '~/components/widgets/shared/NothingFound'
7+
import { SearchFAB } from '~/components/widgets/shared/SearchFAB'
78
import { apiClient } from '~/lib/request'
89

910
interface Props {
@@ -42,6 +43,8 @@ export default async (props: Props) => {
4243

4344
<PostPagination pagination={pagination} />
4445
<PostTagsFAB />
46+
47+
<SearchFAB />
4548
</NormalContainer>
4649
)
4750
}

src/components/layout/header/internal/SiteOwnerAvatar.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ export const SiteOwnerAvatar: Component = ({ className }) => {
1717
fetch('/api/bilibili/live_check')
1818
.then((res) => res.json())
1919
.catch(() => null),
20-
select(data) {
20+
select: useCallback((data: any) => {
2121
return !!data
22-
},
22+
}, []),
2323
refetchInterval: 1000 * 60,
2424
})
2525

src/components/ui/markdown/Markdown.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import React, { Fragment, memo, Suspense, useMemo, useRef } from 'react'
33
import { clsx } from 'clsx'
44
import { compiler, sanitizeUrl } from 'markdown-to-jsx'
55
import dynamic from 'next/dynamic'
6+
import Script from 'next/script'
67
import type { MarkdownToJSX } from 'markdown-to-jsx'
78
import type { FC, PropsWithChildren } from 'react'
89

@@ -41,6 +42,8 @@ export interface MdProps {
4142
codeBlockFully?: boolean
4243
className?: string
4344
as?: React.ElementType
45+
46+
allowsScript?: boolean
4447
}
4548

4649
export const Markdown: FC<MdProps & MarkdownToJSX.Options & PropsWithChildren> =
@@ -56,7 +59,7 @@ export const Markdown: FC<MdProps & MarkdownToJSX.Options & PropsWithChildren> =
5659
extendsRules,
5760
additionalParserRules,
5861
as: As = 'div',
59-
62+
allowsScript = false,
6063
...rest
6164
} = props
6265

@@ -82,6 +85,7 @@ export const Markdown: FC<MdProps & MarkdownToJSX.Options & PropsWithChildren> =
8285
// for custom react component
8386
LinkCard,
8487
Gallery,
88+
script: allowsScript ? Script : undefined,
8589
...overrides,
8690
},
8791

src/components/widgets/post/PostMetaBar.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import type { PostModel } from '@mx-space/api-client'
44

55
import { MdiClockOutline } from '~/components/icons/clock'
66
import { FeHash } from '~/components/icons/fa-hash'
7+
import { ThumbsupIcon } from '~/components/icons/thumbs-up'
78
import { FloatPopover } from '~/components/ui/float-popover'
9+
import { NumberSmoothTransition } from '~/components/ui/number-transition/NumberSmoothTransition'
810
import { RelativeTime } from '~/components/ui/relative-time'
911
import { clsxm } from '~/lib/helper'
1012

@@ -50,8 +52,10 @@ export const PostMetaBar: Component<{
5052
)}
5153
{!!meta.count?.like && (
5254
<div className="flex min-w-0 items-center space-x-1">
53-
<i className="icon-[mingcute--heart-fill]" />
54-
<span className="min-w-0 truncate">{meta.count.like}</span>
55+
<ThumbsupIcon />
56+
<span className="min-w-0 truncate">
57+
<NumberSmoothTransition>{meta.count.like}</NumberSmoothTransition>
58+
</span>
5559
</div>
5660
)}
5761
</div>

0 commit comments

Comments
 (0)