@alauda/doom 1.17.5 → 1.17.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { Options } from 'masonry-layout';
|
|
2
2
|
import { type HTMLAttributes } from 'react';
|
|
3
3
|
export interface MasonryProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
|
-
options?:
|
|
4
|
+
options?: Options;
|
|
5
5
|
}
|
|
6
6
|
export declare const Masonry: ({ options, ...props }: MasonryProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
7
|
export default Masonry;
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useLayoutEffect, useRef } from 'react';
|
|
3
|
+
let MasonryLayout;
|
|
4
|
+
if (typeof window !== 'undefined') {
|
|
5
|
+
MasonryLayout = (await import('masonry-layout')).default;
|
|
6
|
+
}
|
|
3
7
|
export const Masonry = ({ options, ...props }) => {
|
|
4
8
|
const ref = useRef(null);
|
|
5
9
|
useLayoutEffect(() => {
|
|
6
10
|
if (!ref.current) {
|
|
7
11
|
return;
|
|
8
12
|
}
|
|
9
|
-
|
|
10
|
-
const masonry = new (require('masonry-layout'))(ref.current, options);
|
|
13
|
+
const masonry = new MasonryLayout(ref.current, options);
|
|
11
14
|
return () => {
|
|
12
15
|
masonry.destroy?.();
|
|
13
16
|
};
|
|
@@ -15,7 +15,7 @@ const getChildLink = (traverseItem) => {
|
|
|
15
15
|
return '';
|
|
16
16
|
};
|
|
17
17
|
const masonryOptions = {
|
|
18
|
-
itemSelector:
|
|
18
|
+
itemSelector: `.masonry-item`,
|
|
19
19
|
gutter: 16,
|
|
20
20
|
};
|
|
21
21
|
// The sidebar data include two types: sidebar item and sidebar group.
|
|
@@ -113,6 +113,6 @@ export function Overview(props) {
|
|
|
113
113
|
}, [getGroup, overviewSidebarGroups]);
|
|
114
114
|
const groups = customGroups ?? defaultGroups;
|
|
115
115
|
return (_jsxs("div", { className: "overview-index doom-overview-index", children: [content, groups.map((group) => (_jsxs(Fragment, { children: [(!title || [title, defaultGroupTitle].includes(group.name)) &&
|
|
116
|
-
groups.length === 1 ? (_jsx("h2", { style: { paddingTop: 0 } })) : (_jsx(FallbackHeading, { level: 2, title: group.name })), _jsx(Masonry, { className: classes.overviewGroups, options: masonryOptions, children: group.items.map((item) => (_jsxs("div", { className: classes.overviewGroup
|
|
116
|
+
groups.length === 1 ? (_jsx("h2", { style: { paddingTop: 0 } })) : (_jsx(FallbackHeading, { level: 2, title: group.name })), _jsx(Masonry, { className: classes.overviewGroups, options: masonryOptions, children: group.items.map((item) => (_jsxs("div", { className: `${classes.overviewGroup} masonry-item`, children: [_jsx("h3", { children: _jsx(Link, { href: item.link, ...renderInlineMarkdown(item.text) }) }), item.description && (_jsx("div", { className: classes.overviewDescription, children: item.description })), !item.headers?.length || (_jsx("ul", { className: classes.overviewList, children: item.headers.map((header) => (_jsx("li", { className: `${classes.overviewGroupLi} ${classes[`level${header.depth}`]}`, children: _jsx(Link, { href: `${item.link}#${header.id}`, ...renderInlineMarkdown(header.text) }) }, header.id))) }))] }, item.link))) })] }, group.name)))] }));
|
|
117
117
|
}
|
|
118
118
|
export default Overview;
|