fix(ssr): load i18n before renderer
- Changed the initialization function to be asynchronous, ensuring all necessary setups are completed before rendering. - Modified the rendering logic in the Item component to return the memoized content directly. - Cleaned up the NormalListItem component by removing unnecessary wrapper elements and updating class names for better styling consistency. Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
@@ -27,7 +27,7 @@ export const Item = ({
|
||||
feed?: Feed
|
||||
view: FeedViewType
|
||||
}) => {
|
||||
const renderContent = useMemo(() => {
|
||||
return useMemo(() => {
|
||||
switch (true) {
|
||||
case viewsRenderType.Normal.includes(view): {
|
||||
return <NormalList entries={entries} feed={feed} />
|
||||
@@ -40,8 +40,6 @@ export const Item = ({
|
||||
}
|
||||
}
|
||||
}, [entries, feed, view])
|
||||
|
||||
return <div>{renderContent}</div>
|
||||
}
|
||||
|
||||
const NormalList: FC<{
|
||||
@@ -53,18 +51,16 @@ const NormalList: FC<{
|
||||
<>
|
||||
{entries?.map((entry) => (
|
||||
<a className="relative" href={entry.url || void 0} target="_blank" key={entry.id}>
|
||||
<div className="rounded-xl pl-3 duration-300">
|
||||
<NormalListItem
|
||||
withDetails
|
||||
entryId={entry.id}
|
||||
entryPreview={{
|
||||
entries: entry,
|
||||
feeds: feed?.feed || entry.feeds!,
|
||||
read: true,
|
||||
feedId: feed?.feed.id || entry.feeds?.id!,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<NormalListItem
|
||||
withDetails
|
||||
entryId={entry.id}
|
||||
entryPreview={{
|
||||
entries: entry,
|
||||
feeds: feed?.feed || entry.feeds!,
|
||||
read: true,
|
||||
feedId: feed?.feed.id || entry.feeds?.id!,
|
||||
}}
|
||||
/>
|
||||
</a>
|
||||
))}
|
||||
</>
|
||||
|
||||
@@ -29,7 +29,7 @@ function NormalListItemImpl({
|
||||
<div
|
||||
className={cn(
|
||||
"flex gap-1 text-[10px] font-bold",
|
||||
"text-zinc-400 dark:text-neutral-500",
|
||||
"text-text-secondary",
|
||||
entry.collections && "text-zinc-600 dark:text-zinc-500",
|
||||
)}
|
||||
>
|
||||
@@ -41,7 +41,7 @@ function NormalListItemImpl({
|
||||
</div>
|
||||
<div
|
||||
className={cn(
|
||||
"relative my-0.5 line-clamp-2 break-words",
|
||||
"text-text relative my-0.5 line-clamp-2 break-words",
|
||||
!!entry.collections && "pr-5",
|
||||
entry.entries.title ? withDetails && "font-medium" : "text-[13px]",
|
||||
)}
|
||||
@@ -52,9 +52,7 @@ function NormalListItemImpl({
|
||||
</div>
|
||||
{withDetails && (
|
||||
<div className="flex gap-2">
|
||||
<div
|
||||
className={cn("grow text-[13px]", "line-clamp-5 text-zinc-400 dark:text-neutral-500")}
|
||||
>
|
||||
<div className={cn("grow text-[13px]", "text-text-secondary line-clamp-5")}>
|
||||
{entry.entries.description}
|
||||
</div>
|
||||
|
||||
|
||||
@@ -11,11 +11,11 @@ import { initialize } from "./initialize"
|
||||
import { router } from "./router"
|
||||
|
||||
const $container = document.querySelector("#root") as HTMLElement
|
||||
initialize()
|
||||
|
||||
ReactDOM.createRoot($container).render(
|
||||
<React.StrictMode>
|
||||
<RouterProvider router={router} />
|
||||
<ClickToComponent editor={import.meta.env.VITE_EDITOR} />
|
||||
</React.StrictMode>,
|
||||
)
|
||||
initialize().finally(() => {
|
||||
ReactDOM.createRoot($container).render(
|
||||
<React.StrictMode>
|
||||
<RouterProvider router={router} />
|
||||
<ClickToComponent editor={import.meta.env.VITE_EDITOR} />
|
||||
</React.StrictMode>,
|
||||
)
|
||||
})
|
||||
|
||||
@@ -4,9 +4,8 @@ import { initializeDayjs } from "@follow/components/dayjs"
|
||||
import { initAnalytics } from "./analytics"
|
||||
import { initSentry } from "./sentry"
|
||||
|
||||
export const initialize = () => {
|
||||
initializeDayjs()
|
||||
initI18n()
|
||||
export const initialize = async () => {
|
||||
initAnalytics()
|
||||
initSentry()
|
||||
initializeDayjs()
|
||||
await Promise.all([initI18n(), initSentry()])
|
||||
}
|
||||
|
||||
@@ -59,8 +59,8 @@ const MagneticHoverEffect = <T extends React.ElementType = "div">(
|
||||
{...rest}
|
||||
className={cn(
|
||||
"relative",
|
||||
"inline-block transition-all duration-200 ease-out",
|
||||
"hover:bg-material-ultra-thick",
|
||||
"inline-block transition-transform duration-200 ease-out will-change-transform",
|
||||
"hover:before:bg-material-ultra-thick",
|
||||
"before:backdrop-blur-background before:absolute before:-inset-x-2 before:inset-y-0 before:z-[-1] before:scale-0 before:rounded-xl before:opacity-0 before:transition-all before:duration-200 before:[transform-origin:var(--origin-x)_var(--origin-y)] hover:before:scale-100 hover:before:opacity-100",
|
||||
rest.className,
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user