Skip to content

Commit

Permalink
fix: hack nextjs bug 60021
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <i@innei.in>
  • Loading branch information
Innei committed Dec 29, 2023
1 parent 5aa9c85 commit ef7a0d8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/app/notes/[id]/pageImpl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const NotePage = function (props: NoteModel) {
<>
<AckRead id={props.id} type="note" />

{props.meta?.cover && <NoteHeadCover image={props.meta.cover} />}
<NoteHeadCover image={props.meta?.cover} />
<NoteHeaderMetaInfoSetting />
<IndentArticleContainer>
<header>
Expand Down
35 changes: 21 additions & 14 deletions src/components/widgets/note/NoteHeadCover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,12 @@ function cropImageTo16by9(src: string): Promise<string> {
img.src = src
})
}
export const NoteHeadCover = ({ image }: { image?: string }) => {
if (!image) return null

export const NoteHeadCover = ({ image }: { image: string }) => {
return <NoteHeadCoverImpl image={image} />
}
const NoteHeadCoverImpl = ({ image }: { image: string }) => {
const [imageBlob, setImageBlob] = useState<string | null>(null)
useLayoutEffect(() => {
let isMounted = true
Expand All @@ -69,23 +73,26 @@ export const NoteHeadCover = ({ image }: { image: string }) => {
isMounted = false
}
}, [image])

return (
<>
<AutoResizeHeight>
<div
data-hide-print
className={clsx(
'z-1 absolute left-0 right-0 top-0',
imageBlob ? 'h-[224px]' : '0',
)}
>
{imageBlob && (
<div
style={{
backgroundImage: `url(${imageBlob})`,
}}
className="cover-mask-b h-full w-full bg-cover bg-center bg-no-repeat"
/>
</div>
data-hide-print
className={clsx(
'z-1 absolute left-0 right-0 top-0',
imageBlob ? 'h-[224px]' : '0',
)}
>
<div
style={{
backgroundImage: `url(${imageBlob})`,
}}
className="cover-mask-b h-full w-full bg-cover bg-center bg-no-repeat"
/>
</div>
)}
</AutoResizeHeight>

<AutoResizeHeight>
Expand Down
2 changes: 1 addition & 1 deletion src/components/widgets/peek/NotePreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const NotePreview: FC<NotePreviewProps> = (props) => {
<CurrentNoteDataProvider data={data} />
{!!note.id && <AckRead id={note.id} type="note" />}
<Paper>
{note.meta?.cover && <NoteHeadCover image={note.meta.cover} />}
<NoteHeadCover image={note.meta?.cover} />
<IndentArticleContainer>
<header>
<NoteTitle />
Expand Down

1 comment on commit ef7a0d8

@vercel
Copy link

@vercel vercel bot commented on ef7a0d8 Dec 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

shiro – ./

innei.in
shiro-git-main-innei.vercel.app
shiro-innei.vercel.app
springtide.vercel.app

Please sign in to comment.