Skip to content

Commit 7e936a5

Browse files
committed
fix: SSG compatibility
1 parent d375ba7 commit 7e936a5

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

packages/doom/src/runtime/components/Masonry.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import MasonryLayout from 'masonry-layout'
1+
import type MasonryLayout from 'masonry-layout'
22
import { useLayoutEffect, useRef, type HTMLAttributes } from 'react'
33

44
export interface MasonryProps extends HTMLAttributes<HTMLDivElement> {
@@ -13,7 +13,11 @@ export const Masonry = ({ options, ...props }: MasonryProps) => {
1313
return
1414
}
1515

16-
const masonry = new MasonryLayout(ref.current, options)
16+
// eslint-disable-next-line @typescript-eslint/no-require-imports
17+
const masonry = new (require('masonry-layout') as typeof MasonryLayout)(
18+
ref.current,
19+
options,
20+
)
1721

1822
return () => {
1923
masonry.destroy?.()

packages/doom/src/runtime/components/Overview.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ const getChildLink = (
5050
return ''
5151
}
5252

53+
const masonryOptions = {
54+
itemSelector: `.${classes.overviewGroup}`,
55+
gutter: 16,
56+
}
57+
5358
// The sidebar data include two types: sidebar item and sidebar group.
5459
// In overpage page, we select all the related sidebar groups and show the groups in the page.
5560
// In the meantime, some sidebar items also should be shown in the page, we collect them in the group named 'Others' and show them in the page.
@@ -212,14 +217,6 @@ export function Overview(props: {
212217

213218
const groups = customGroups ?? defaultGroups
214219

215-
const masonryOptions = useMemo(
216-
() => ({
217-
itemSelector: `.${classes.overviewGroup}`,
218-
gutter: 16,
219-
}),
220-
[],
221-
)
222-
223220
return (
224221
<div className="overview-index doom-overview-index">
225222
{content}

0 commit comments

Comments
 (0)