notion-to-jsx 0.0.0 → 0.2.0
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.
- package/dist/index.css +588 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.mts +88 -0
- package/dist/index.d.ts +88 -0
- package/dist/index.js +777 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +740 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +43 -5
- package/.turbo/turbo-test.log +0 -7
- package/tsconfig.json +0 -8
- package/tsconfig.lint.json +0 -8
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,740 @@
|
|
|
1
|
+
// src/components/Renderer/index.tsx
|
|
2
|
+
import React6, { useState as useState4, useMemo as useMemo2, useCallback } from "react";
|
|
3
|
+
|
|
4
|
+
// src/components/Renderer/styles.css.ts
|
|
5
|
+
var container = "styles_container__epva5u0";
|
|
6
|
+
|
|
7
|
+
// src/components/Renderer/components/List/styles.css.ts
|
|
8
|
+
import { createRuntimeFn as _7a468 } from "@vanilla-extract/recipes/createRuntimeFn";
|
|
9
|
+
var list = _7a468({ defaultClassName: "styles_list__es8vim0", variantClassNames: { type: { bulleted: "styles_list_type_bulleted__es8vim1", numbered: "styles_list_type_numbered__es8vim2" } }, defaultVariants: {}, compoundVariants: [] });
|
|
10
|
+
var listItem = "styles_listItem__es8vim3";
|
|
11
|
+
|
|
12
|
+
// src/components/Renderer/components/List/List.tsx
|
|
13
|
+
import { jsx } from "react/jsx-runtime";
|
|
14
|
+
var List = ({
|
|
15
|
+
as: Component = "ul",
|
|
16
|
+
type,
|
|
17
|
+
className,
|
|
18
|
+
children,
|
|
19
|
+
...props
|
|
20
|
+
}) => {
|
|
21
|
+
return /* @__PURE__ */ jsx(Component, { className: list({ type }), ...props, children });
|
|
22
|
+
};
|
|
23
|
+
var ListItem = ({
|
|
24
|
+
className,
|
|
25
|
+
children,
|
|
26
|
+
...props
|
|
27
|
+
}) => {
|
|
28
|
+
return /* @__PURE__ */ jsx("li", { className: listItem, ...props, children });
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// src/components/Renderer/components/MemoizedComponents.tsx
|
|
32
|
+
import React4 from "react";
|
|
33
|
+
|
|
34
|
+
// src/components/Renderer/components/RichText/styles.css.ts
|
|
35
|
+
import { createRuntimeFn as _7a4682 } from "@vanilla-extract/recipes/createRuntimeFn";
|
|
36
|
+
var link = "styles_link__fdf3tw7";
|
|
37
|
+
var richText = _7a4682({ defaultClassName: "styles_richText__fdf3tw0", variantClassNames: { bold: { true: "styles_richText_bold_true__fdf3tw1" }, italic: { true: "styles_richText_italic_true__fdf3tw2" }, strikethrough: { true: "styles_richText_strikethrough_true__fdf3tw3" }, underline: { true: "styles_richText_underline_true__fdf3tw4" }, code: { true: "styles_richText_code_true__fdf3tw5" } }, defaultVariants: {}, compoundVariants: [[{ strikethrough: true, underline: true }, "styles_richText_compound_0__fdf3tw6"]] });
|
|
38
|
+
|
|
39
|
+
// src/components/Renderer/components/RichText/RichTexts.tsx
|
|
40
|
+
import { Fragment, jsx as jsx2 } from "react/jsx-runtime";
|
|
41
|
+
var RichTexts = ({ richTexts }) => {
|
|
42
|
+
return /* @__PURE__ */ jsx2(Fragment, { children: richTexts.map((text, index) => {
|
|
43
|
+
const { bold, italic, strikethrough, underline, code, color } = text.annotations;
|
|
44
|
+
const content3 = text.text.link ? /* @__PURE__ */ jsx2(
|
|
45
|
+
"a",
|
|
46
|
+
{
|
|
47
|
+
href: text.text.link,
|
|
48
|
+
target: "_blank",
|
|
49
|
+
rel: "noopener noreferrer",
|
|
50
|
+
className: link,
|
|
51
|
+
children: text.text.content
|
|
52
|
+
}
|
|
53
|
+
) : text.text.content;
|
|
54
|
+
return /* @__PURE__ */ jsx2(
|
|
55
|
+
"span",
|
|
56
|
+
{
|
|
57
|
+
className: richText({
|
|
58
|
+
bold,
|
|
59
|
+
italic,
|
|
60
|
+
strikethrough,
|
|
61
|
+
underline,
|
|
62
|
+
code
|
|
63
|
+
}),
|
|
64
|
+
children: content3
|
|
65
|
+
},
|
|
66
|
+
index
|
|
67
|
+
);
|
|
68
|
+
}) });
|
|
69
|
+
};
|
|
70
|
+
var RichTexts_default = RichTexts;
|
|
71
|
+
|
|
72
|
+
// src/components/Renderer/components/Image/Image.tsx
|
|
73
|
+
import { useState, useEffect } from "react";
|
|
74
|
+
|
|
75
|
+
// src/components/Renderer/components/Image/styles.css.ts
|
|
76
|
+
import { createRuntimeFn as _7a4683 } from "@vanilla-extract/recipes/createRuntimeFn";
|
|
77
|
+
var caption = "styles_caption__2f3ncfc";
|
|
78
|
+
var imageContainer = "styles_imageContainer__2f3ncf0";
|
|
79
|
+
var imageWrapper = _7a4683({ defaultClassName: "styles_imageWrapper__2f3ncf3", variantClassNames: { hasWidth: { true: "styles_imageWrapper_hasWidth_true__2f3ncf4", false: "styles_imageWrapper_hasWidth_false__2f3ncf5" } }, defaultVariants: { hasWidth: false }, compoundVariants: [] });
|
|
80
|
+
var placeholder = "styles_placeholder__2f3ncfb";
|
|
81
|
+
var styledImage = _7a4683({ defaultClassName: "styles_styledImage__2f3ncf6", variantClassNames: { loaded: { true: "styles_styledImage_loaded_true__2f3ncf7", false: "styles_styledImage_loaded_false__2f3ncf8" }, hasAspectRatio: { true: "styles_styledImage_hasAspectRatio_true__2f3ncf9", false: "styles_styledImage_hasAspectRatio_false__2f3ncfa" } }, defaultVariants: { loaded: false, hasAspectRatio: false }, compoundVariants: [] });
|
|
82
|
+
|
|
83
|
+
// src/components/Renderer/components/Image/Image.tsx
|
|
84
|
+
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
85
|
+
var MAX_WIDTH = 720;
|
|
86
|
+
var Image = ({
|
|
87
|
+
src,
|
|
88
|
+
alt,
|
|
89
|
+
caption: imageCaption,
|
|
90
|
+
priority = false,
|
|
91
|
+
format
|
|
92
|
+
}) => {
|
|
93
|
+
const [isLoaded, setIsLoaded] = useState(false);
|
|
94
|
+
const [error, setError] = useState(false);
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
setIsLoaded(false);
|
|
97
|
+
setError(false);
|
|
98
|
+
}, [src]);
|
|
99
|
+
return /* @__PURE__ */ jsxs("figure", { className: imageContainer, children: [
|
|
100
|
+
/* @__PURE__ */ jsxs(
|
|
101
|
+
"div",
|
|
102
|
+
{
|
|
103
|
+
className: imageWrapper({
|
|
104
|
+
hasWidth: !!format?.block_width
|
|
105
|
+
}),
|
|
106
|
+
style: format?.block_width ? {
|
|
107
|
+
width: format.block_width > MAX_WIDTH ? "100%" : `${format.block_width}px`
|
|
108
|
+
} : void 0,
|
|
109
|
+
children: [
|
|
110
|
+
!isLoaded && !error && /* @__PURE__ */ jsx3(
|
|
111
|
+
"div",
|
|
112
|
+
{
|
|
113
|
+
className: placeholder,
|
|
114
|
+
style: {
|
|
115
|
+
width: format?.block_width ? format.block_width > MAX_WIDTH ? "100%" : `${format.block_width}px` : "100%",
|
|
116
|
+
aspectRatio: format?.block_aspect_ratio ? `${format.block_aspect_ratio}` : "auto"
|
|
117
|
+
},
|
|
118
|
+
children: /* @__PURE__ */ jsx3(
|
|
119
|
+
"svg",
|
|
120
|
+
{
|
|
121
|
+
width: "38",
|
|
122
|
+
height: "38",
|
|
123
|
+
viewBox: "0 0 38 38",
|
|
124
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
125
|
+
stroke: "#888",
|
|
126
|
+
children: /* @__PURE__ */ jsx3("g", { fill: "none", fillRule: "evenodd", children: /* @__PURE__ */ jsxs("g", { transform: "translate(1 1)", strokeWidth: "2", children: [
|
|
127
|
+
/* @__PURE__ */ jsx3("circle", { strokeOpacity: ".5", cx: "18", cy: "18", r: "18" }),
|
|
128
|
+
/* @__PURE__ */ jsx3("path", { d: "M36 18c0-9.94-8.06-18-18-18", children: /* @__PURE__ */ jsx3(
|
|
129
|
+
"animateTransform",
|
|
130
|
+
{
|
|
131
|
+
attributeName: "transform",
|
|
132
|
+
type: "rotate",
|
|
133
|
+
from: "0 18 18",
|
|
134
|
+
to: "360 18 18",
|
|
135
|
+
dur: "1s",
|
|
136
|
+
repeatCount: "indefinite"
|
|
137
|
+
}
|
|
138
|
+
) })
|
|
139
|
+
] }) })
|
|
140
|
+
}
|
|
141
|
+
)
|
|
142
|
+
}
|
|
143
|
+
),
|
|
144
|
+
error && /* @__PURE__ */ jsxs(
|
|
145
|
+
"div",
|
|
146
|
+
{
|
|
147
|
+
className: placeholder,
|
|
148
|
+
style: {
|
|
149
|
+
width: format?.block_width ? format.block_width > MAX_WIDTH ? "100%" : `${format.block_width}px` : "100%",
|
|
150
|
+
aspectRatio: format?.block_aspect_ratio ? `${format.block_aspect_ratio}` : "auto"
|
|
151
|
+
},
|
|
152
|
+
children: [
|
|
153
|
+
/* @__PURE__ */ jsxs(
|
|
154
|
+
"svg",
|
|
155
|
+
{
|
|
156
|
+
width: "48",
|
|
157
|
+
height: "48",
|
|
158
|
+
viewBox: "0 0 24 24",
|
|
159
|
+
fill: "none",
|
|
160
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
161
|
+
children: [
|
|
162
|
+
/* @__PURE__ */ jsx3(
|
|
163
|
+
"path",
|
|
164
|
+
{
|
|
165
|
+
d: "M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z",
|
|
166
|
+
stroke: "#FF6B6B",
|
|
167
|
+
strokeWidth: "2",
|
|
168
|
+
strokeLinecap: "round",
|
|
169
|
+
strokeLinejoin: "round"
|
|
170
|
+
}
|
|
171
|
+
),
|
|
172
|
+
/* @__PURE__ */ jsx3(
|
|
173
|
+
"path",
|
|
174
|
+
{
|
|
175
|
+
d: "M15 9L9 15",
|
|
176
|
+
stroke: "#FF6B6B",
|
|
177
|
+
strokeWidth: "2",
|
|
178
|
+
strokeLinecap: "round",
|
|
179
|
+
strokeLinejoin: "round"
|
|
180
|
+
}
|
|
181
|
+
),
|
|
182
|
+
/* @__PURE__ */ jsx3(
|
|
183
|
+
"path",
|
|
184
|
+
{
|
|
185
|
+
d: "M9 9L15 15",
|
|
186
|
+
stroke: "#FF6B6B",
|
|
187
|
+
strokeWidth: "2",
|
|
188
|
+
strokeLinecap: "round",
|
|
189
|
+
strokeLinejoin: "round"
|
|
190
|
+
}
|
|
191
|
+
)
|
|
192
|
+
]
|
|
193
|
+
}
|
|
194
|
+
),
|
|
195
|
+
/* @__PURE__ */ jsx3("div", { style: { width: "10px" } }),
|
|
196
|
+
/* @__PURE__ */ jsx3("p", { style: { color: "#FF6B6B", fontSize: "14px" }, children: "Image Load failed" })
|
|
197
|
+
]
|
|
198
|
+
}
|
|
199
|
+
),
|
|
200
|
+
/* @__PURE__ */ jsx3(
|
|
201
|
+
"img",
|
|
202
|
+
{
|
|
203
|
+
className: styledImage({
|
|
204
|
+
loaded: isLoaded,
|
|
205
|
+
hasAspectRatio: !!format?.block_aspect_ratio
|
|
206
|
+
}),
|
|
207
|
+
src,
|
|
208
|
+
alt,
|
|
209
|
+
loading: priority ? "eager" : "lazy",
|
|
210
|
+
onLoad: () => setIsLoaded(true),
|
|
211
|
+
onError: () => setError(true),
|
|
212
|
+
width: format?.block_width,
|
|
213
|
+
height: format?.block_height,
|
|
214
|
+
style: format?.block_aspect_ratio ? { aspectRatio: `${format.block_aspect_ratio}` } : void 0
|
|
215
|
+
}
|
|
216
|
+
)
|
|
217
|
+
]
|
|
218
|
+
}
|
|
219
|
+
),
|
|
220
|
+
imageCaption && imageCaption.length > 0 && /* @__PURE__ */ jsx3("figcaption", { className: caption, children: /* @__PURE__ */ jsx3(MemoizedRichText, { richTexts: imageCaption }) })
|
|
221
|
+
] });
|
|
222
|
+
};
|
|
223
|
+
var Image_default = Image;
|
|
224
|
+
|
|
225
|
+
// src/components/Renderer/components/Bookmark/Bookmark.tsx
|
|
226
|
+
import { useState as useState2, useEffect as useEffect2 } from "react";
|
|
227
|
+
|
|
228
|
+
// src/components/Renderer/components/Bookmark/styles.css.ts
|
|
229
|
+
var card = "styles_card__qrq8yf1";
|
|
230
|
+
var content = "styles_content__qrq8yf2";
|
|
231
|
+
var description = "styles_description__qrq8yf6";
|
|
232
|
+
var favicon = "styles_favicon__qrq8yf8";
|
|
233
|
+
var link2 = "styles_link__qrq8yf0";
|
|
234
|
+
var previewContainer = "styles_previewContainer__qrq8yf3";
|
|
235
|
+
var previewImage = "styles_previewImage__qrq8yf4";
|
|
236
|
+
var siteName = "styles_siteName__qrq8yf7";
|
|
237
|
+
var title = "styles_title__qrq8yf5";
|
|
238
|
+
var urlText = "styles_urlText__qrq8yf9";
|
|
239
|
+
|
|
240
|
+
// src/components/Renderer/components/Bookmark/Bookmark.tsx
|
|
241
|
+
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
242
|
+
var fetchOpenGraphData = async (url) => {
|
|
243
|
+
try {
|
|
244
|
+
const apiUrl = `https://api.microlink.io/?url=${encodeURIComponent(url)}`;
|
|
245
|
+
const response = await fetch(apiUrl);
|
|
246
|
+
const data = await response.json();
|
|
247
|
+
if (!response.ok) {
|
|
248
|
+
throw new Error("Failed to fetch metadata");
|
|
249
|
+
}
|
|
250
|
+
const { status, data: metaData } = data;
|
|
251
|
+
if (status !== "success") {
|
|
252
|
+
throw new Error("API returned error status");
|
|
253
|
+
}
|
|
254
|
+
const parsedUrl = new URL(url);
|
|
255
|
+
const domain = parsedUrl.hostname;
|
|
256
|
+
return {
|
|
257
|
+
title: metaData.title || domain,
|
|
258
|
+
description: metaData.description || "No description available",
|
|
259
|
+
image: metaData.image?.url || "",
|
|
260
|
+
siteName: metaData.publisher || domain,
|
|
261
|
+
url: metaData.url || "",
|
|
262
|
+
favicon: metaData.logo?.url || `https://www.google.com/s2/favicons?domain=${domain}&sz=64`
|
|
263
|
+
};
|
|
264
|
+
} catch (error) {
|
|
265
|
+
console.error("Error fetching OpenGraph data:", error);
|
|
266
|
+
const parsedUrl = new URL(url);
|
|
267
|
+
const domain = parsedUrl.hostname;
|
|
268
|
+
return {
|
|
269
|
+
title: domain,
|
|
270
|
+
description: "No description available",
|
|
271
|
+
image: "",
|
|
272
|
+
url: "",
|
|
273
|
+
siteName: domain,
|
|
274
|
+
favicon: `https://www.google.com/s2/favicons?domain=${domain}&sz=64`
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
var Bookmark = ({ url }) => {
|
|
279
|
+
const [ogData, setOgData] = useState2(null);
|
|
280
|
+
const [error, setError] = useState2(false);
|
|
281
|
+
useEffect2(() => {
|
|
282
|
+
const loadOgData = async () => {
|
|
283
|
+
try {
|
|
284
|
+
const data = await fetchOpenGraphData(url);
|
|
285
|
+
setOgData(data);
|
|
286
|
+
} catch (err) {
|
|
287
|
+
setError(true);
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
loadOgData();
|
|
291
|
+
}, [url]);
|
|
292
|
+
return /* @__PURE__ */ jsx4("a", { href: url, target: "_blank", rel: "noopener noreferrer", className: link2, children: /* @__PURE__ */ jsxs2("div", { className: card, children: [
|
|
293
|
+
/* @__PURE__ */ jsxs2("div", { className: content, children: [
|
|
294
|
+
/* @__PURE__ */ jsxs2("div", { children: [
|
|
295
|
+
/* @__PURE__ */ jsx4("h4", { className: title, children: ogData?.title || url }),
|
|
296
|
+
/* @__PURE__ */ jsx4("p", { className: description, children: ogData?.description || "" })
|
|
297
|
+
] }),
|
|
298
|
+
/* @__PURE__ */ jsxs2("div", { className: siteName, children: [
|
|
299
|
+
ogData?.favicon && /* @__PURE__ */ jsx4("img", { src: ogData.favicon, alt: "", className: favicon }),
|
|
300
|
+
/* @__PURE__ */ jsx4("span", { className: urlText, children: ogData?.url || "" })
|
|
301
|
+
] })
|
|
302
|
+
] }),
|
|
303
|
+
ogData?.image && /* @__PURE__ */ jsx4("div", { className: previewContainer, children: /* @__PURE__ */ jsx4(
|
|
304
|
+
"img",
|
|
305
|
+
{
|
|
306
|
+
className: previewImage,
|
|
307
|
+
src: ogData.image,
|
|
308
|
+
alt: ogData.title,
|
|
309
|
+
loading: "lazy",
|
|
310
|
+
onError: (e) => {
|
|
311
|
+
const target = e.target;
|
|
312
|
+
target.style.display = "none";
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
) })
|
|
316
|
+
] }) });
|
|
317
|
+
};
|
|
318
|
+
var Bookmark_default = Bookmark;
|
|
319
|
+
|
|
320
|
+
// src/components/Renderer/components/LinkPreview/LinkPreview.tsx
|
|
321
|
+
import { useState as useState3, useEffect as useEffect3 } from "react";
|
|
322
|
+
|
|
323
|
+
// src/components/Renderer/components/LinkPreview/styles.css.ts
|
|
324
|
+
var card2 = "styles_card__o1p3m11";
|
|
325
|
+
var content2 = "styles_content__o1p3m12";
|
|
326
|
+
var icon = "styles_icon__o1p3m14";
|
|
327
|
+
var iconContainer = "styles_iconContainer__o1p3m13";
|
|
328
|
+
var link3 = "styles_link__o1p3m10";
|
|
329
|
+
var title2 = "styles_title__o1p3m15";
|
|
330
|
+
var updatedText = "styles_updatedText__o1p3m16";
|
|
331
|
+
|
|
332
|
+
// src/components/Renderer/components/LinkPreview/LinkPreview.tsx
|
|
333
|
+
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
334
|
+
var fetchGitHubRepoData = async (repoPath) => {
|
|
335
|
+
try {
|
|
336
|
+
const apiUrl = `https://api.github.com/repos/${repoPath}`;
|
|
337
|
+
const response = await fetch(apiUrl);
|
|
338
|
+
if (!response.ok) {
|
|
339
|
+
throw new Error("Failed to fetch GitHub repo data");
|
|
340
|
+
}
|
|
341
|
+
const data = await response.json();
|
|
342
|
+
return data;
|
|
343
|
+
} catch (error) {
|
|
344
|
+
console.error("Error fetching GitHub repo data:", error);
|
|
345
|
+
return null;
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
var extractRepoPathFromUrl = (url) => {
|
|
349
|
+
try {
|
|
350
|
+
const parsedUrl = new URL(url);
|
|
351
|
+
if (parsedUrl.hostname === "github.com") {
|
|
352
|
+
const path = parsedUrl.pathname.substring(1);
|
|
353
|
+
const pathParts = path.split("/");
|
|
354
|
+
if (pathParts.length >= 2) {
|
|
355
|
+
return `${pathParts[0]}/${pathParts[1]}`;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
return null;
|
|
359
|
+
} catch (error) {
|
|
360
|
+
console.error("Error parsing URL:", error);
|
|
361
|
+
return null;
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
var formatUpdatedTime = (dateString) => {
|
|
365
|
+
const date = new Date(dateString);
|
|
366
|
+
const now = /* @__PURE__ */ new Date();
|
|
367
|
+
const diffInHours = Math.floor(
|
|
368
|
+
(now.getTime() - date.getTime()) / (1e3 * 60 * 60)
|
|
369
|
+
);
|
|
370
|
+
if (diffInHours < 24) {
|
|
371
|
+
return `Updated ${diffInHours} hours ago`;
|
|
372
|
+
} else {
|
|
373
|
+
const diffInDays = Math.floor(diffInHours / 24);
|
|
374
|
+
if (diffInDays === 1) {
|
|
375
|
+
return "Updated yesterday";
|
|
376
|
+
} else if (diffInDays < 30) {
|
|
377
|
+
return `Updated ${diffInDays} days ago`;
|
|
378
|
+
} else {
|
|
379
|
+
const months = [
|
|
380
|
+
"Jan",
|
|
381
|
+
"Feb",
|
|
382
|
+
"Mar",
|
|
383
|
+
"Apr",
|
|
384
|
+
"May",
|
|
385
|
+
"Jun",
|
|
386
|
+
"Jul",
|
|
387
|
+
"Aug",
|
|
388
|
+
"Sep",
|
|
389
|
+
"Oct",
|
|
390
|
+
"Nov",
|
|
391
|
+
"Dec"
|
|
392
|
+
];
|
|
393
|
+
return `Updated on ${months[date.getMonth()]} ${date.getDate()}, ${date.getFullYear()}`;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
};
|
|
397
|
+
var LinkPreview = ({ url }) => {
|
|
398
|
+
const [repoData, setRepoData] = useState3(null);
|
|
399
|
+
const [loading, setLoading] = useState3(true);
|
|
400
|
+
useEffect3(() => {
|
|
401
|
+
const loadRepoData = async () => {
|
|
402
|
+
setLoading(true);
|
|
403
|
+
const repoPath = extractRepoPathFromUrl(url);
|
|
404
|
+
if (repoPath) {
|
|
405
|
+
const data = await fetchGitHubRepoData(repoPath);
|
|
406
|
+
setRepoData(data);
|
|
407
|
+
}
|
|
408
|
+
setLoading(false);
|
|
409
|
+
};
|
|
410
|
+
loadRepoData();
|
|
411
|
+
}, [url]);
|
|
412
|
+
const repoName = repoData?.name || extractRepoPathFromUrl(url)?.split("/")[1] || "Repository";
|
|
413
|
+
const updatedTimeText = repoData?.updated_at ? formatUpdatedTime(repoData.updated_at) : "";
|
|
414
|
+
return /* @__PURE__ */ jsx5("a", { href: url, target: "_blank", rel: "noopener noreferrer", className: link3, children: /* @__PURE__ */ jsxs3("div", { className: card2, children: [
|
|
415
|
+
/* @__PURE__ */ jsx5("div", { className: iconContainer, children: /* @__PURE__ */ jsx5(
|
|
416
|
+
"img",
|
|
417
|
+
{
|
|
418
|
+
src: repoData?.owner?.avatar_url || "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png",
|
|
419
|
+
alt: "Repository icon",
|
|
420
|
+
className: icon
|
|
421
|
+
}
|
|
422
|
+
) }),
|
|
423
|
+
/* @__PURE__ */ jsxs3("div", { className: content2, children: [
|
|
424
|
+
/* @__PURE__ */ jsx5("div", { className: title2, children: repoName }),
|
|
425
|
+
/* @__PURE__ */ jsx5("div", { className: updatedText, children: loading ? "Loading..." : `NotionX \u2022 ${updatedTimeText}` })
|
|
426
|
+
] })
|
|
427
|
+
] }) });
|
|
428
|
+
};
|
|
429
|
+
var LinkPreview_default = LinkPreview;
|
|
430
|
+
|
|
431
|
+
// src/components/Renderer/components/MemoizedComponents.tsx
|
|
432
|
+
var MemoizedRichText = React4.memo(
|
|
433
|
+
RichTexts_default,
|
|
434
|
+
(prev, next) => {
|
|
435
|
+
return JSON.stringify(prev.richTexts) === JSON.stringify(next.richTexts);
|
|
436
|
+
}
|
|
437
|
+
);
|
|
438
|
+
var MemoizedImage = React4.memo(Image_default, (prev, next) => {
|
|
439
|
+
return prev.src === next.src && prev.alt === next.alt && JSON.stringify(prev.caption) === JSON.stringify(next.caption);
|
|
440
|
+
});
|
|
441
|
+
var MemoizedBookmark = React4.memo(
|
|
442
|
+
Bookmark_default,
|
|
443
|
+
(prev, next) => {
|
|
444
|
+
return prev.url === next.url;
|
|
445
|
+
}
|
|
446
|
+
);
|
|
447
|
+
var MemoizedLinkPreview = React4.memo(
|
|
448
|
+
LinkPreview_default,
|
|
449
|
+
(prev, next) => {
|
|
450
|
+
return prev.url === next.url;
|
|
451
|
+
}
|
|
452
|
+
);
|
|
453
|
+
|
|
454
|
+
// src/components/Renderer/components/List/ListBlocksRenderer.tsx
|
|
455
|
+
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
456
|
+
var RecursiveListItem = ({ block, index }) => {
|
|
457
|
+
const blockProps = {
|
|
458
|
+
tabIndex: 0,
|
|
459
|
+
"data-block-id": block.id
|
|
460
|
+
};
|
|
461
|
+
const blockType = block.type;
|
|
462
|
+
const richTexts = block[blockType]?.rich_text;
|
|
463
|
+
return /* @__PURE__ */ jsxs4(ListItem, { ...blockProps, children: [
|
|
464
|
+
/* @__PURE__ */ jsx6(MemoizedRichText, { richTexts }),
|
|
465
|
+
block.children && block.children.length > 0 && /* @__PURE__ */ jsx6(
|
|
466
|
+
RecursiveListGroup,
|
|
467
|
+
{
|
|
468
|
+
blocks: block.children,
|
|
469
|
+
type: blockType.split("_")[0]
|
|
470
|
+
}
|
|
471
|
+
)
|
|
472
|
+
] });
|
|
473
|
+
};
|
|
474
|
+
var RecursiveListGroup = ({ blocks, type }) => {
|
|
475
|
+
if (!blocks || blocks.length === 0) return null;
|
|
476
|
+
const listItems = blocks.filter(
|
|
477
|
+
(block) => block.type === `${type}_list_item`
|
|
478
|
+
);
|
|
479
|
+
if (listItems.length === 0) return null;
|
|
480
|
+
return /* @__PURE__ */ jsx6(
|
|
481
|
+
List,
|
|
482
|
+
{
|
|
483
|
+
as: type === "numbered" ? "ol" : "ul",
|
|
484
|
+
type,
|
|
485
|
+
role: "list",
|
|
486
|
+
"aria-label": type === "bulleted" ? "Bulleted list" : "Numbered list",
|
|
487
|
+
children: listItems.map((block, index) => /* @__PURE__ */ jsx6(RecursiveListItem, { block, index }, block.id))
|
|
488
|
+
}
|
|
489
|
+
);
|
|
490
|
+
};
|
|
491
|
+
var ListBlocksRenderer = ({ blocks, startIndex, type }) => {
|
|
492
|
+
let consecutiveItems = 0;
|
|
493
|
+
for (let i = startIndex; i < blocks.length; i++) {
|
|
494
|
+
const block = blocks[i];
|
|
495
|
+
if (!block) break;
|
|
496
|
+
if (block.type === `${type}_list_item`) {
|
|
497
|
+
consecutiveItems++;
|
|
498
|
+
} else {
|
|
499
|
+
break;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
const listItems = blocks.slice(startIndex, startIndex + consecutiveItems);
|
|
503
|
+
return /* @__PURE__ */ jsx6(
|
|
504
|
+
List,
|
|
505
|
+
{
|
|
506
|
+
as: type === "numbered" ? "ol" : "ul",
|
|
507
|
+
type,
|
|
508
|
+
role: "list",
|
|
509
|
+
"aria-label": type === "bulleted" ? "Bulleted list" : "Numbered list",
|
|
510
|
+
children: listItems.map((block, index) => /* @__PURE__ */ jsx6(
|
|
511
|
+
RecursiveListItem,
|
|
512
|
+
{
|
|
513
|
+
block,
|
|
514
|
+
index: startIndex + index
|
|
515
|
+
},
|
|
516
|
+
block.id
|
|
517
|
+
))
|
|
518
|
+
}
|
|
519
|
+
);
|
|
520
|
+
};
|
|
521
|
+
var ListBlocksRenderer_default = ListBlocksRenderer;
|
|
522
|
+
|
|
523
|
+
// src/components/Renderer/components/Code/CodeBlock.tsx
|
|
524
|
+
import { useMemo } from "react";
|
|
525
|
+
|
|
526
|
+
// src/components/Renderer/components/Code/styles.css.ts
|
|
527
|
+
var codeBlock = "styles_codeBlock__1qn42yc0";
|
|
528
|
+
|
|
529
|
+
// src/components/Renderer/components/Code/CodeBlock.tsx
|
|
530
|
+
import Prism from "prismjs";
|
|
531
|
+
import "prismjs/themes/prism.css";
|
|
532
|
+
import "prismjs/components/prism-typescript";
|
|
533
|
+
import "prismjs/components/prism-javascript";
|
|
534
|
+
import "prismjs/components/prism-jsx";
|
|
535
|
+
import "prismjs/components/prism-tsx";
|
|
536
|
+
import { Fragment as Fragment2, jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
537
|
+
if (typeof window !== "undefined") {
|
|
538
|
+
window.Prism = Prism;
|
|
539
|
+
}
|
|
540
|
+
var CodeBlock = ({ code, language, caption: caption2 }) => {
|
|
541
|
+
const highlightedCode = useMemo(() => {
|
|
542
|
+
const prismLanguage = Prism.languages[language] || Prism.languages.plaintext;
|
|
543
|
+
return Prism.highlight(code, prismLanguage, language);
|
|
544
|
+
}, [code, language]);
|
|
545
|
+
return /* @__PURE__ */ jsxs5(Fragment2, { children: [
|
|
546
|
+
/* @__PURE__ */ jsx7("pre", { className: codeBlock, children: /* @__PURE__ */ jsx7("code", { dangerouslySetInnerHTML: { __html: highlightedCode } }) }),
|
|
547
|
+
caption2 && /* @__PURE__ */ jsx7("figcaption", { children: /* @__PURE__ */ jsx7(MemoizedRichText, { richTexts: caption2 }) })
|
|
548
|
+
] });
|
|
549
|
+
};
|
|
550
|
+
var CodeBlock_default = CodeBlock;
|
|
551
|
+
|
|
552
|
+
// src/components/Renderer/components/Typography/styles.css.ts
|
|
553
|
+
var heading1 = "styles_heading1__90a95g1";
|
|
554
|
+
var heading2 = "styles_heading2__90a95g2";
|
|
555
|
+
var heading3 = "styles_heading3__90a95g3";
|
|
556
|
+
var paragraph = "styles_paragraph__90a95g0";
|
|
557
|
+
|
|
558
|
+
// src/components/Renderer/components/Typography/Typography.tsx
|
|
559
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
560
|
+
var Paragraph = ({
|
|
561
|
+
className,
|
|
562
|
+
children,
|
|
563
|
+
...props
|
|
564
|
+
}) => {
|
|
565
|
+
return /* @__PURE__ */ jsx8("p", { className: paragraph, ...props, children });
|
|
566
|
+
};
|
|
567
|
+
var Heading1 = ({
|
|
568
|
+
className,
|
|
569
|
+
children,
|
|
570
|
+
...props
|
|
571
|
+
}) => {
|
|
572
|
+
return /* @__PURE__ */ jsx8("h1", { className: heading1, ...props, children });
|
|
573
|
+
};
|
|
574
|
+
var Heading2 = ({
|
|
575
|
+
className,
|
|
576
|
+
children,
|
|
577
|
+
...props
|
|
578
|
+
}) => {
|
|
579
|
+
return /* @__PURE__ */ jsx8("h2", { className: heading2, ...props, children });
|
|
580
|
+
};
|
|
581
|
+
var Heading3 = ({
|
|
582
|
+
className,
|
|
583
|
+
children,
|
|
584
|
+
...props
|
|
585
|
+
}) => {
|
|
586
|
+
return /* @__PURE__ */ jsx8("h3", { className: heading3, ...props, children });
|
|
587
|
+
};
|
|
588
|
+
|
|
589
|
+
// src/components/Renderer/components/Block/BlockRenderer.tsx
|
|
590
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
591
|
+
var BlockRenderer = ({ block, onFocus, index }) => {
|
|
592
|
+
if (!block) return null;
|
|
593
|
+
const blockProps = {
|
|
594
|
+
tabIndex: 0,
|
|
595
|
+
onFocus,
|
|
596
|
+
"data-block-id": block.id
|
|
597
|
+
};
|
|
598
|
+
switch (block.type) {
|
|
599
|
+
case "link_preview":
|
|
600
|
+
return /* @__PURE__ */ jsx9(
|
|
601
|
+
MemoizedLinkPreview,
|
|
602
|
+
{
|
|
603
|
+
url: block.link_preview.url,
|
|
604
|
+
...blockProps
|
|
605
|
+
}
|
|
606
|
+
);
|
|
607
|
+
case "paragraph":
|
|
608
|
+
return /* @__PURE__ */ jsx9(Paragraph, { ...blockProps, children: /* @__PURE__ */ jsx9(MemoizedRichText, { richTexts: block.paragraph.rich_text }) });
|
|
609
|
+
case "heading_1":
|
|
610
|
+
return /* @__PURE__ */ jsx9(Heading1, { ...blockProps, children: /* @__PURE__ */ jsx9(MemoizedRichText, { richTexts: block.heading_1.rich_text }) });
|
|
611
|
+
case "heading_2":
|
|
612
|
+
return /* @__PURE__ */ jsx9(Heading2, { ...blockProps, children: /* @__PURE__ */ jsx9(MemoizedRichText, { richTexts: block.heading_2.rich_text }) });
|
|
613
|
+
case "heading_3":
|
|
614
|
+
return /* @__PURE__ */ jsx9(Heading3, { ...blockProps, children: /* @__PURE__ */ jsx9(MemoizedRichText, { richTexts: block.heading_3.rich_text }) });
|
|
615
|
+
case "code":
|
|
616
|
+
return /* @__PURE__ */ jsx9("div", { ...blockProps, children: /* @__PURE__ */ jsx9(
|
|
617
|
+
CodeBlock_default,
|
|
618
|
+
{
|
|
619
|
+
code: block.code.rich_text[0].text.content,
|
|
620
|
+
language: block.code.language,
|
|
621
|
+
caption: block.code.caption?.[0]?.plain_text
|
|
622
|
+
}
|
|
623
|
+
) });
|
|
624
|
+
case "image":
|
|
625
|
+
return /* @__PURE__ */ jsx9("figure", { ...blockProps, children: /* @__PURE__ */ jsx9(
|
|
626
|
+
MemoizedImage,
|
|
627
|
+
{
|
|
628
|
+
src: block.image.file?.url || block.image.external?.url,
|
|
629
|
+
alt: block.image.caption?.[0]?.plain_text || "",
|
|
630
|
+
caption: block.image.caption,
|
|
631
|
+
format: block.image.format
|
|
632
|
+
}
|
|
633
|
+
) });
|
|
634
|
+
case "bookmark":
|
|
635
|
+
return /* @__PURE__ */ jsx9(MemoizedBookmark, { url: block.bookmark.url });
|
|
636
|
+
default:
|
|
637
|
+
return null;
|
|
638
|
+
}
|
|
639
|
+
};
|
|
640
|
+
var BlockRenderer_default = BlockRenderer;
|
|
641
|
+
|
|
642
|
+
// src/styles/theme.css.ts
|
|
643
|
+
var darkTheme = "theme_darkTheme__sq3jkb15";
|
|
644
|
+
var lightTheme = "theme_lightTheme__sq3jkb14";
|
|
645
|
+
|
|
646
|
+
// src/components/Title/index.tsx
|
|
647
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
648
|
+
var Title = ({ title: title3 }) => {
|
|
649
|
+
return /* @__PURE__ */ jsx10(Heading1, { children: title3 });
|
|
650
|
+
};
|
|
651
|
+
var Title_default = Title;
|
|
652
|
+
|
|
653
|
+
// src/components/Cover/styles.css.ts
|
|
654
|
+
var cover = "styles_cover__p0cp8d0";
|
|
655
|
+
|
|
656
|
+
// src/components/Cover/index.tsx
|
|
657
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
658
|
+
var Cover = ({ src, alt }) => {
|
|
659
|
+
return /* @__PURE__ */ jsx11("img", { src, alt, className: cover });
|
|
660
|
+
};
|
|
661
|
+
var Cover_default = Cover;
|
|
662
|
+
|
|
663
|
+
// src/components/Renderer/index.tsx
|
|
664
|
+
import { Fragment as Fragment3, jsx as jsx12, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
665
|
+
var Renderer = React6.memo(
|
|
666
|
+
({ blocks, isDarkMode = false, title: title3, cover: cover2, onBlockFocus }) => {
|
|
667
|
+
const theme = isDarkMode ? darkTheme : lightTheme;
|
|
668
|
+
const [focusedIndex, setFocusedIndex] = useState4(-1);
|
|
669
|
+
const handleBlockFocus = useCallback(
|
|
670
|
+
(index) => {
|
|
671
|
+
setFocusedIndex(index);
|
|
672
|
+
onBlockFocus?.(index);
|
|
673
|
+
},
|
|
674
|
+
[onBlockFocus]
|
|
675
|
+
);
|
|
676
|
+
const renderedBlocks = useMemo2(() => {
|
|
677
|
+
const result = [];
|
|
678
|
+
for (let i = 0; i < blocks.length; i++) {
|
|
679
|
+
const block = blocks[i];
|
|
680
|
+
if (!block) break;
|
|
681
|
+
const handleListItem = (listType) => {
|
|
682
|
+
const listItemType = `${listType}_list_item`;
|
|
683
|
+
if (block.type === listItemType && (i === 0 || blocks[i - 1]?.type !== listItemType)) {
|
|
684
|
+
result.push(
|
|
685
|
+
/* @__PURE__ */ jsx12(
|
|
686
|
+
ListBlocksRenderer_default,
|
|
687
|
+
{
|
|
688
|
+
blocks,
|
|
689
|
+
startIndex: i,
|
|
690
|
+
type: listType
|
|
691
|
+
},
|
|
692
|
+
block.id
|
|
693
|
+
)
|
|
694
|
+
);
|
|
695
|
+
while (i + 1 < blocks.length && blocks[i + 1] && blocks[i + 1]?.type === listItemType) {
|
|
696
|
+
i++;
|
|
697
|
+
}
|
|
698
|
+
return true;
|
|
699
|
+
}
|
|
700
|
+
return false;
|
|
701
|
+
};
|
|
702
|
+
if (handleListItem("bulleted") || handleListItem("numbered")) {
|
|
703
|
+
continue;
|
|
704
|
+
} else {
|
|
705
|
+
result.push(
|
|
706
|
+
/* @__PURE__ */ jsx12(
|
|
707
|
+
BlockRenderer_default,
|
|
708
|
+
{
|
|
709
|
+
block,
|
|
710
|
+
index: i,
|
|
711
|
+
onFocus: () => handleBlockFocus(i)
|
|
712
|
+
},
|
|
713
|
+
block.id
|
|
714
|
+
)
|
|
715
|
+
);
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
return result;
|
|
719
|
+
}, [blocks, handleBlockFocus]);
|
|
720
|
+
return /* @__PURE__ */ jsxs6(Fragment3, { children: [
|
|
721
|
+
cover2 && /* @__PURE__ */ jsx12(Cover_default, { src: cover2, alt: title3 || "Notion page content" }),
|
|
722
|
+
/* @__PURE__ */ jsxs6(
|
|
723
|
+
"article",
|
|
724
|
+
{
|
|
725
|
+
className: `${theme} ${container}`,
|
|
726
|
+
"aria-label": title3 || "Notion page content",
|
|
727
|
+
children: [
|
|
728
|
+
title3 && /* @__PURE__ */ jsx12(Title_default, { title: title3 }),
|
|
729
|
+
renderedBlocks
|
|
730
|
+
]
|
|
731
|
+
}
|
|
732
|
+
)
|
|
733
|
+
] });
|
|
734
|
+
}
|
|
735
|
+
);
|
|
736
|
+
Renderer.displayName = "Renderer";
|
|
737
|
+
export {
|
|
738
|
+
Renderer
|
|
739
|
+
};
|
|
740
|
+
//# sourceMappingURL=index.mjs.map
|