@btst/stack 1.0.1 → 1.1.1
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/README.md +156 -709
- package/dist/api/index.cjs +2 -1
- package/dist/api/index.d.cts +4 -3
- package/dist/api/index.d.mts +4 -3
- package/dist/api/index.d.ts +4 -3
- package/dist/api/index.mjs +1 -1
- package/dist/client/components/compose.cjs +68 -0
- package/dist/client/components/compose.mjs +65 -0
- package/dist/client/components/error-boundary.cjs +24 -0
- package/dist/client/components/error-boundary.mjs +22 -0
- package/dist/client/components/index.cjs +10 -0
- package/dist/client/components/index.d.cts +52 -0
- package/dist/client/components/index.d.mts +52 -0
- package/dist/client/components/index.d.ts +52 -0
- package/dist/client/components/index.mjs +2 -0
- package/dist/client/index.cjs +24 -5
- package/dist/client/index.d.cts +125 -8
- package/dist/client/index.d.mts +125 -8
- package/dist/client/index.d.ts +125 -8
- package/dist/client/index.mjs +21 -4
- package/dist/client/meta-utils.cjs +162 -0
- package/dist/client/meta-utils.mjs +160 -0
- package/dist/client/path-utils.cjs +15 -0
- package/dist/client/path-utils.mjs +13 -0
- package/dist/client/sitemap-utils.cjs +14 -0
- package/dist/client/sitemap-utils.mjs +12 -0
- package/dist/context/index.cjs +6 -63
- package/dist/context/index.d.cts +21 -24
- package/dist/context/index.d.mts +21 -24
- package/dist/context/index.d.ts +21 -24
- package/dist/context/index.mjs +1 -61
- package/dist/context/provider.cjs +51 -0
- package/dist/context/provider.mjs +46 -0
- package/dist/index.cjs +2 -3
- package/dist/index.d.cts +3 -2
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.mjs +1 -2
- package/dist/plugins/api/index.cjs +13 -0
- package/dist/plugins/api/index.d.cts +40 -0
- package/dist/plugins/api/index.d.mts +40 -0
- package/dist/plugins/api/index.d.ts +40 -0
- package/dist/plugins/api/index.mjs +8 -0
- package/dist/plugins/blog/api/index.cjs +11 -0
- package/dist/plugins/blog/api/index.d.cts +7 -0
- package/dist/plugins/blog/api/index.d.mts +7 -0
- package/dist/plugins/blog/api/index.d.ts +7 -0
- package/dist/plugins/blog/api/index.mjs +2 -0
- package/dist/plugins/blog/api/plugin.cjs +569 -0
- package/dist/plugins/blog/api/plugin.mjs +565 -0
- package/dist/plugins/blog/client/components/forms/image-field.cjs +133 -0
- package/dist/plugins/blog/client/components/forms/image-field.mjs +131 -0
- package/dist/plugins/blog/client/components/forms/markdown-editor-styles.css +30 -0
- package/dist/plugins/blog/client/components/forms/markdown-editor.cjs +106 -0
- package/dist/plugins/blog/client/components/forms/markdown-editor.mjs +104 -0
- package/dist/plugins/blog/client/components/forms/post-forms.cjs +401 -0
- package/dist/plugins/blog/client/components/forms/post-forms.mjs +398 -0
- package/dist/plugins/blog/client/components/forms/tags-multiselect.cjs +71 -0
- package/dist/plugins/blog/client/components/forms/tags-multiselect.mjs +65 -0
- package/dist/plugins/blog/client/components/index.cjs +17 -0
- package/dist/plugins/blog/client/components/index.d.cts +22 -0
- package/dist/plugins/blog/client/components/index.d.mts +22 -0
- package/dist/plugins/blog/client/components/index.d.ts +22 -0
- package/dist/plugins/blog/client/components/index.mjs +12 -0
- package/dist/plugins/blog/client/components/loading/form-page-skeleton.cjs +62 -0
- package/dist/plugins/blog/client/components/loading/form-page-skeleton.mjs +60 -0
- package/dist/plugins/blog/client/components/loading/index.cjs +20 -0
- package/dist/plugins/blog/client/components/loading/index.mjs +16 -0
- package/dist/plugins/blog/client/components/loading/list-page-skeleton.cjs +26 -0
- package/dist/plugins/blog/client/components/loading/list-page-skeleton.mjs +24 -0
- package/dist/plugins/blog/client/components/loading/page-header-skeleton.cjs +13 -0
- package/dist/plugins/blog/client/components/loading/page-header-skeleton.mjs +11 -0
- package/dist/plugins/blog/client/components/loading/post-card-skeleton.cjs +22 -0
- package/dist/plugins/blog/client/components/loading/post-card-skeleton.mjs +20 -0
- package/dist/plugins/blog/client/components/loading/post-page-skeleton.cjs +56 -0
- package/dist/plugins/blog/client/components/loading/post-page-skeleton.mjs +54 -0
- package/dist/plugins/blog/client/components/pages/404-page.cjs +19 -0
- package/dist/plugins/blog/client/components/pages/404-page.mjs +17 -0
- package/dist/plugins/blog/client/components/pages/edit-post-page.cjs +41 -0
- package/dist/plugins/blog/client/components/pages/edit-post-page.internal.cjs +57 -0
- package/dist/plugins/blog/client/components/pages/edit-post-page.internal.mjs +55 -0
- package/dist/plugins/blog/client/components/pages/edit-post-page.mjs +39 -0
- package/dist/plugins/blog/client/components/pages/home-page.cjs +41 -0
- package/dist/plugins/blog/client/components/pages/home-page.internal.cjs +61 -0
- package/dist/plugins/blog/client/components/pages/home-page.internal.mjs +59 -0
- package/dist/plugins/blog/client/components/pages/home-page.mjs +39 -0
- package/dist/plugins/blog/client/components/pages/new-post-page.cjs +37 -0
- package/dist/plugins/blog/client/components/pages/new-post-page.internal.cjs +53 -0
- package/dist/plugins/blog/client/components/pages/new-post-page.internal.mjs +51 -0
- package/dist/plugins/blog/client/components/pages/new-post-page.mjs +35 -0
- package/dist/plugins/blog/client/components/pages/post-page.cjs +39 -0
- package/dist/plugins/blog/client/components/pages/post-page.internal.cjs +101 -0
- package/dist/plugins/blog/client/components/pages/post-page.internal.mjs +99 -0
- package/dist/plugins/blog/client/components/pages/post-page.mjs +37 -0
- package/dist/plugins/blog/client/components/pages/tag-page.cjs +39 -0
- package/dist/plugins/blog/client/components/pages/tag-page.internal.cjs +61 -0
- package/dist/plugins/blog/client/components/pages/tag-page.internal.mjs +59 -0
- package/dist/plugins/blog/client/components/pages/tag-page.mjs +37 -0
- package/dist/plugins/blog/client/components/shared/better-blog-attribution.cjs +24 -0
- package/dist/plugins/blog/client/components/shared/better-blog-attribution.mjs +22 -0
- package/dist/plugins/blog/client/components/shared/default-error.cjs +18 -0
- package/dist/plugins/blog/client/components/shared/default-error.mjs +16 -0
- package/dist/plugins/blog/client/components/shared/defaults.cjs +13 -0
- package/dist/plugins/blog/client/components/shared/defaults.mjs +10 -0
- package/dist/plugins/blog/client/components/shared/empty-list.cjs +21 -0
- package/dist/plugins/blog/client/components/shared/empty-list.mjs +19 -0
- package/dist/plugins/blog/client/components/shared/error-placeholder.cjs +24 -0
- package/dist/plugins/blog/client/components/shared/error-placeholder.mjs +22 -0
- package/dist/plugins/blog/client/components/shared/highlight-text.cjs +53 -0
- package/dist/plugins/blog/client/components/shared/highlight-text.mjs +51 -0
- package/dist/plugins/blog/client/components/shared/markdown-content-styles.css +328 -0
- package/dist/plugins/blog/client/components/shared/markdown-content.cjs +324 -0
- package/dist/plugins/blog/client/components/shared/markdown-content.mjs +315 -0
- package/dist/plugins/blog/client/components/shared/on-this-page.cjs +161 -0
- package/dist/plugins/blog/client/components/shared/on-this-page.mjs +158 -0
- package/dist/plugins/blog/client/components/shared/page-header.cjs +40 -0
- package/dist/plugins/blog/client/components/shared/page-header.mjs +38 -0
- package/dist/plugins/blog/client/components/shared/page-layout.cjs +24 -0
- package/dist/plugins/blog/client/components/shared/page-layout.mjs +22 -0
- package/dist/plugins/blog/client/components/shared/page-wrapper.cjs +23 -0
- package/dist/plugins/blog/client/components/shared/page-wrapper.mjs +21 -0
- package/dist/plugins/blog/client/components/shared/post-card.cjs +279 -0
- package/dist/plugins/blog/client/components/shared/post-card.mjs +277 -0
- package/dist/plugins/blog/client/components/shared/post-navigation.cjs +74 -0
- package/dist/plugins/blog/client/components/shared/post-navigation.mjs +72 -0
- package/dist/plugins/blog/client/components/shared/posts-list.cjs +48 -0
- package/dist/plugins/blog/client/components/shared/posts-list.mjs +46 -0
- package/dist/plugins/blog/client/components/shared/recent-posts-carousel.cjs +59 -0
- package/dist/plugins/blog/client/components/shared/recent-posts-carousel.mjs +57 -0
- package/dist/plugins/blog/client/components/shared/search-input.cjs +136 -0
- package/dist/plugins/blog/client/components/shared/search-input.mjs +117 -0
- package/dist/plugins/blog/client/components/shared/search-modal.cjs +135 -0
- package/dist/plugins/blog/client/components/shared/search-modal.mjs +116 -0
- package/dist/plugins/blog/client/components/shared/tags-list.cjs +22 -0
- package/dist/plugins/blog/client/components/shared/tags-list.mjs +20 -0
- package/dist/plugins/blog/client/components/shared/use-route-lifecycle.cjs +50 -0
- package/dist/plugins/blog/client/components/shared/use-route-lifecycle.mjs +48 -0
- package/dist/plugins/blog/client/hooks/blog-hooks.cjs +380 -0
- package/dist/plugins/blog/client/hooks/blog-hooks.mjs +368 -0
- package/dist/plugins/blog/client/hooks/index.cjs +17 -0
- package/dist/plugins/blog/client/hooks/index.d.cts +150 -0
- package/dist/plugins/blog/client/hooks/index.d.mts +150 -0
- package/dist/plugins/blog/client/hooks/index.d.ts +150 -0
- package/dist/plugins/blog/client/hooks/index.mjs +1 -0
- package/dist/plugins/blog/client/hooks/use-debounce.cjs +16 -0
- package/dist/plugins/blog/client/hooks/use-debounce.mjs +14 -0
- package/dist/plugins/blog/client/index.cjs +7 -0
- package/dist/plugins/blog/client/index.d.cts +414 -0
- package/dist/plugins/blog/client/index.d.mts +414 -0
- package/dist/plugins/blog/client/index.d.ts +414 -0
- package/dist/plugins/blog/client/index.mjs +1 -0
- package/dist/plugins/blog/client/localization/blog-card.cjs +7 -0
- package/dist/plugins/blog/client/localization/blog-card.mjs +5 -0
- package/dist/plugins/blog/client/localization/blog-common.cjs +10 -0
- package/dist/plugins/blog/client/localization/blog-common.mjs +8 -0
- package/dist/plugins/blog/client/localization/blog-forms.cjs +40 -0
- package/dist/plugins/blog/client/localization/blog-forms.mjs +38 -0
- package/dist/plugins/blog/client/localization/blog-list.cjs +18 -0
- package/dist/plugins/blog/client/localization/blog-list.mjs +16 -0
- package/dist/plugins/blog/client/localization/blog-post.cjs +13 -0
- package/dist/plugins/blog/client/localization/blog-post.mjs +11 -0
- package/dist/plugins/blog/client/localization/index.cjs +17 -0
- package/dist/plugins/blog/client/localization/index.mjs +15 -0
- package/dist/plugins/blog/client/plugin.cjs +462 -0
- package/dist/plugins/blog/client/plugin.mjs +460 -0
- package/dist/plugins/blog/client.css +3 -0
- package/dist/plugins/blog/db.cjs +90 -0
- package/dist/plugins/blog/db.mjs +88 -0
- package/dist/plugins/blog/query-keys.cjs +181 -0
- package/dist/plugins/blog/query-keys.d.cts +530 -0
- package/dist/plugins/blog/query-keys.d.mts +530 -0
- package/dist/plugins/blog/query-keys.d.ts +530 -0
- package/dist/plugins/blog/query-keys.mjs +179 -0
- package/dist/plugins/blog/schemas.cjs +39 -0
- package/dist/plugins/blog/schemas.mjs +35 -0
- package/dist/plugins/blog/style.css +22 -0
- package/dist/plugins/blog/utils.cjs +97 -0
- package/dist/plugins/blog/utils.mjs +87 -0
- package/dist/plugins/client/index.cjs +15 -0
- package/dist/plugins/client/index.d.cts +57 -0
- package/dist/plugins/client/index.d.mts +57 -0
- package/dist/plugins/client/index.d.ts +57 -0
- package/dist/plugins/client/index.mjs +9 -0
- package/dist/{shared/stack.3OUyGp_E.mjs → plugins/utils.mjs} +1 -1
- package/dist/shared/{stack.DORw_1ps.d.cts → stack.ByOugz9d.d.cts} +17 -1
- package/dist/shared/{stack.DORw_1ps.d.mts → stack.ByOugz9d.d.mts} +17 -1
- package/dist/shared/{stack.DORw_1ps.d.ts → stack.ByOugz9d.d.ts} +17 -1
- package/dist/shared/stack.CoPoHVfV.d.cts +76 -0
- package/dist/shared/stack.CoPoHVfV.d.mts +76 -0
- package/dist/shared/stack.CoPoHVfV.d.ts +76 -0
- package/package.json +102 -14
- package/src/__tests__/plugins.test.tsx +539 -0
- package/src/__tests__/sitemap.test.ts +60 -0
- package/src/api/index.ts +75 -0
- package/src/client/components/compose.tsx +116 -0
- package/src/client/components/error-boundary.tsx +30 -0
- package/src/client/components/index.tsx +2 -0
- package/src/client/index.ts +109 -0
- package/src/client/meta-utils.ts +228 -0
- package/src/client/path-utils.ts +38 -0
- package/src/client/sitemap-utils.ts +46 -0
- package/src/context/index.ts +1 -0
- package/src/context/provider.tsx +157 -0
- package/src/index.ts +1 -0
- package/src/plugins/api/index.ts +50 -0
- package/src/plugins/blog/api/index.ts +2 -0
- package/src/plugins/blog/api/plugin.ts +759 -0
- package/src/plugins/blog/client/components/forms/image-field.tsx +165 -0
- package/src/plugins/blog/client/components/forms/markdown-editor-styles.css +30 -0
- package/src/plugins/blog/client/components/forms/markdown-editor.tsx +136 -0
- package/src/plugins/blog/client/components/forms/post-forms.tsx +531 -0
- package/src/plugins/blog/client/components/forms/tags-multiselect.tsx +79 -0
- package/src/plugins/blog/client/components/index.tsx +11 -0
- package/src/plugins/blog/client/components/loading/form-page-skeleton.tsx +75 -0
- package/src/plugins/blog/client/components/loading/index.tsx +27 -0
- package/src/plugins/blog/client/components/loading/list-page-skeleton.tsx +38 -0
- package/src/plugins/blog/client/components/loading/page-header-skeleton.tsx +10 -0
- package/src/plugins/blog/client/components/loading/post-card-skeleton.tsx +30 -0
- package/src/plugins/blog/client/components/loading/post-page-skeleton.tsx +75 -0
- package/src/plugins/blog/client/components/pages/404-page.tsx +23 -0
- package/src/plugins/blog/client/components/pages/edit-post-page.internal.tsx +60 -0
- package/src/plugins/blog/client/components/pages/edit-post-page.tsx +40 -0
- package/src/plugins/blog/client/components/pages/home-page.internal.tsx +71 -0
- package/src/plugins/blog/client/components/pages/home-page.tsx +42 -0
- package/src/plugins/blog/client/components/pages/new-post-page.internal.tsx +59 -0
- package/src/plugins/blog/client/components/pages/new-post-page.tsx +36 -0
- package/src/plugins/blog/client/components/pages/post-page.internal.tsx +142 -0
- package/src/plugins/blog/client/components/pages/post-page.tsx +38 -0
- package/src/plugins/blog/client/components/pages/tag-page.internal.tsx +74 -0
- package/src/plugins/blog/client/components/pages/tag-page.tsx +38 -0
- package/src/plugins/blog/client/components/shared/better-blog-attribution.tsx +19 -0
- package/src/plugins/blog/client/components/shared/default-error.tsx +20 -0
- package/src/plugins/blog/client/components/shared/defaults.tsx +9 -0
- package/src/plugins/blog/client/components/shared/empty-list.tsx +25 -0
- package/src/plugins/blog/client/components/shared/error-placeholder.tsx +20 -0
- package/src/plugins/blog/client/components/shared/highlight-text.tsx +80 -0
- package/src/plugins/blog/client/components/shared/markdown-content-styles.css +328 -0
- package/src/plugins/blog/client/components/shared/markdown-content.tsx +448 -0
- package/src/plugins/blog/client/components/shared/on-this-page.tsx +234 -0
- package/src/plugins/blog/client/components/shared/page-header.tsx +35 -0
- package/src/plugins/blog/client/components/shared/page-layout.tsx +23 -0
- package/src/plugins/blog/client/components/shared/page-wrapper.tsx +32 -0
- package/src/plugins/blog/client/components/shared/post-card.tsx +308 -0
- package/src/plugins/blog/client/components/shared/post-navigation.tsx +98 -0
- package/src/plugins/blog/client/components/shared/posts-list.tsx +67 -0
- package/src/plugins/blog/client/components/shared/recent-posts-carousel.tsx +79 -0
- package/src/plugins/blog/client/components/shared/search-input.tsx +146 -0
- package/src/plugins/blog/client/components/shared/search-modal.tsx +162 -0
- package/src/plugins/blog/client/components/shared/tags-list.tsx +34 -0
- package/src/plugins/blog/client/components/shared/use-route-lifecycle.tsx +68 -0
- package/src/plugins/blog/client/hooks/blog-hooks.tsx +623 -0
- package/src/plugins/blog/client/hooks/index.tsx +1 -0
- package/src/plugins/blog/client/hooks/use-debounce.ts +43 -0
- package/src/plugins/blog/client/index.ts +9 -0
- package/src/plugins/blog/client/localization/blog-card.ts +3 -0
- package/src/plugins/blog/client/localization/blog-common.ts +7 -0
- package/src/plugins/blog/client/localization/blog-forms.ts +45 -0
- package/src/plugins/blog/client/localization/blog-list.ts +14 -0
- package/src/plugins/blog/client/localization/blog-post.ts +9 -0
- package/src/plugins/blog/client/localization/index.ts +15 -0
- package/src/plugins/blog/client/overrides.ts +123 -0
- package/src/plugins/blog/client/plugin.tsx +672 -0
- package/src/plugins/blog/client.css +3 -0
- package/src/plugins/blog/db.ts +90 -0
- package/src/plugins/blog/query-keys.ts +267 -0
- package/src/plugins/blog/schemas.ts +39 -0
- package/src/plugins/blog/style.css +22 -0
- package/src/plugins/blog/types.ts +37 -0
- package/src/plugins/blog/utils.ts +144 -0
- package/src/plugins/client/index.ts +53 -0
- package/src/plugins/index.ts +0 -0
- package/src/plugins/utils.ts +35 -0
- package/src/types.ts +209 -0
- package/dist/plugins/index.cjs +0 -15
- package/dist/plugins/index.d.cts +0 -64
- package/dist/plugins/index.d.mts +0 -64
- package/dist/plugins/index.d.ts +0 -64
- package/dist/plugins/index.mjs +0 -11
- package/dist/shared/stack.DrUAVfIH.d.cts +0 -17
- package/dist/shared/stack.DrUAVfIH.d.mts +0 -17
- package/dist/shared/stack.DrUAVfIH.d.ts +0 -17
- /package/dist/{shared/stack.CktCg4PJ.cjs → plugins/utils.cjs} +0 -0
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
.milkdown-custom .milkdown .milkdown-content {
|
|
2
|
+
font-family: var(--crepe-font-default);
|
|
3
|
+
color: var(--crepe-color-on-background);
|
|
4
|
+
background: var(--crepe-color-background);
|
|
5
|
+
padding: 0px;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.milkdown-custom .milkdown .milkdown-content img {
|
|
9
|
+
vertical-align: bottom;
|
|
10
|
+
max-width: 100%;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.milkdown-custom .milkdown .milkdown-content .markdown-image-wrapper {
|
|
14
|
+
display: block;
|
|
15
|
+
position: relative;
|
|
16
|
+
width: 100%;
|
|
17
|
+
aspect-ratio: 16 / 9;
|
|
18
|
+
min-height: 200px;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.milkdown-custom .milkdown .milkdown-content .markdown-image-wrapper > div {
|
|
22
|
+
width: 100%;
|
|
23
|
+
height: 100%;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.milkdown-custom .milkdown .milkdown-content .markdown-image-wrapper img {
|
|
27
|
+
object-fit: contain;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.milkdown-custom .milkdown .milkdown-content h1,
|
|
31
|
+
.milkdown-custom .milkdown .milkdown-content h2,
|
|
32
|
+
.milkdown-custom .milkdown .milkdown-content h3,
|
|
33
|
+
.milkdown-custom .milkdown .milkdown-content h4,
|
|
34
|
+
.milkdown-custom .milkdown .milkdown-content h5,
|
|
35
|
+
.milkdown-custom .milkdown .milkdown-content h6 {
|
|
36
|
+
font-family: var(--crepe-font-title);
|
|
37
|
+
font-weight: 400;
|
|
38
|
+
padding: 2px 0;
|
|
39
|
+
scroll-margin-top: 56px;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.milkdown-custom .milkdown .milkdown-content h1 .heading-anchor,
|
|
43
|
+
.milkdown-custom .milkdown .milkdown-content h2 .heading-anchor,
|
|
44
|
+
.milkdown-custom .milkdown .milkdown-content h3 .heading-anchor,
|
|
45
|
+
.milkdown-custom .milkdown .milkdown-content h4 .heading-anchor,
|
|
46
|
+
.milkdown-custom .milkdown .milkdown-content h5 .heading-anchor,
|
|
47
|
+
.milkdown-custom .milkdown .milkdown-content h6 .heading-anchor {
|
|
48
|
+
opacity: 0;
|
|
49
|
+
margin-left: 8px;
|
|
50
|
+
color: var(--crepe-color-on-surface-variant);
|
|
51
|
+
text-decoration: none;
|
|
52
|
+
transition: opacity 0.15s ease-in-out;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.milkdown-custom .milkdown .milkdown-content h1:hover .heading-anchor,
|
|
56
|
+
.milkdown-custom .milkdown .milkdown-content h2:hover .heading-anchor,
|
|
57
|
+
.milkdown-custom .milkdown .milkdown-content h3:hover .heading-anchor,
|
|
58
|
+
.milkdown-custom .milkdown .milkdown-content h4:hover .heading-anchor,
|
|
59
|
+
.milkdown-custom .milkdown .milkdown-content h5:hover .heading-anchor,
|
|
60
|
+
.milkdown-custom .milkdown .milkdown-content h6:hover .heading-anchor {
|
|
61
|
+
opacity: 1;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.milkdown-custom .milkdown .milkdown-content h1 {
|
|
65
|
+
font-size: 42px;
|
|
66
|
+
line-height: 50px;
|
|
67
|
+
margin-top: 32px;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.milkdown-custom .milkdown .milkdown-content h2 {
|
|
71
|
+
font-size: 36px;
|
|
72
|
+
line-height: 44px;
|
|
73
|
+
margin-top: 28px;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.milkdown-custom .milkdown .milkdown-content h3 {
|
|
77
|
+
font-size: 32px;
|
|
78
|
+
line-height: 40px;
|
|
79
|
+
margin-top: 24px;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.milkdown-custom .milkdown .milkdown-content h4 {
|
|
83
|
+
font-size: 28px;
|
|
84
|
+
line-height: 36px;
|
|
85
|
+
margin-top: 20px;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.milkdown-custom .milkdown .milkdown-content h5 {
|
|
89
|
+
font-size: 24px;
|
|
90
|
+
line-height: 32px;
|
|
91
|
+
margin-top: 16px;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.milkdown-custom .milkdown .milkdown-content h6 {
|
|
95
|
+
font-size: 18px;
|
|
96
|
+
font-weight: 700;
|
|
97
|
+
line-height: 28px;
|
|
98
|
+
margin-top: 16px;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.milkdown-custom .milkdown .milkdown-content p {
|
|
102
|
+
font-size: 16px;
|
|
103
|
+
line-height: 24px;
|
|
104
|
+
padding: 4px 0;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.milkdown-custom .milkdown .milkdown-content a {
|
|
108
|
+
color: var(--crepe-color-primary);
|
|
109
|
+
text-decoration: underline;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.milkdown-custom .milkdown .milkdown-content code {
|
|
113
|
+
color: var(--crepe-color-inline-code);
|
|
114
|
+
background: color-mix(
|
|
115
|
+
in srgb,
|
|
116
|
+
var(--crepe-color-inline-area),
|
|
117
|
+
transparent 40%
|
|
118
|
+
);
|
|
119
|
+
font-family: var(--crepe-font-code);
|
|
120
|
+
padding: 0 2px;
|
|
121
|
+
border-radius: 4px;
|
|
122
|
+
font-size: 87.5%;
|
|
123
|
+
display: inline-block;
|
|
124
|
+
line-height: 1.4286;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.milkdown-custom .milkdown .milkdown-content pre {
|
|
128
|
+
background: color-mix(
|
|
129
|
+
in srgb,
|
|
130
|
+
var(--crepe-color-inline-area),
|
|
131
|
+
transparent 40%
|
|
132
|
+
);
|
|
133
|
+
padding: 10px;
|
|
134
|
+
border-radius: 4px;
|
|
135
|
+
overflow-x: auto;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.milkdown-custom .milkdown .milkdown-content pre code {
|
|
139
|
+
padding: 0;
|
|
140
|
+
background: transparent;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/* Ensure highlight.js themes color tokens inside our containers */
|
|
144
|
+
.milkdown-custom .milkdown .milkdown-content pre code.hljs,
|
|
145
|
+
.milkdown-custom .milkdown .milkdown-content code.hljs {
|
|
146
|
+
display: block;
|
|
147
|
+
overflow-x: auto;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.milkdown-custom .milkdown .milkdown-code-block {
|
|
151
|
+
display: block;
|
|
152
|
+
position: relative;
|
|
153
|
+
padding: 40px 8px 20px 20px;
|
|
154
|
+
margin: 4px 0;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.milkdown-custom .milkdown .milkdown-code-block pre {
|
|
158
|
+
background: transparent;
|
|
159
|
+
padding: 0;
|
|
160
|
+
border-radius: 0;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/* Layout wrapper to host gutter and code content side-by-side */
|
|
164
|
+
.milkdown-custom .milkdown .milkdown-code-block .code-content {
|
|
165
|
+
display: grid;
|
|
166
|
+
grid-template-columns: var(--code-gutter-width, 3ch) 1fr;
|
|
167
|
+
gap: 0.35rem;
|
|
168
|
+
align-items: stretch;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/* Gutter line numbers */
|
|
172
|
+
.milkdown-custom .milkdown .milkdown-code-block .line-numbers {
|
|
173
|
+
list-style: none;
|
|
174
|
+
margin: 0;
|
|
175
|
+
user-select: none;
|
|
176
|
+
color: var(--crepe-color-on-surface-variant);
|
|
177
|
+
text-align: end;
|
|
178
|
+
display: flex;
|
|
179
|
+
flex-direction: column;
|
|
180
|
+
justify-content: space-between;
|
|
181
|
+
align-items: center;
|
|
182
|
+
height: 100%;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.milkdown-custom .milkdown .milkdown-code-block .line-numbers li {
|
|
186
|
+
font-family: var(--crepe-font-code);
|
|
187
|
+
font-size: 12px;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.milkdown-custom .milkdown .milkdown-code-block .code-toolbar {
|
|
191
|
+
position: absolute;
|
|
192
|
+
top: 8px;
|
|
193
|
+
left: 18px;
|
|
194
|
+
right: 18px;
|
|
195
|
+
display: flex;
|
|
196
|
+
align-items: center;
|
|
197
|
+
justify-content: space-between;
|
|
198
|
+
pointer-events: none;
|
|
199
|
+
opacity: 0;
|
|
200
|
+
transition: opacity 0.15s ease-in-out;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.milkdown-custom .milkdown .milkdown-code-block:hover .code-toolbar {
|
|
204
|
+
opacity: 1;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/* Also reveal toolbar when focused via keyboard for accessibility */
|
|
208
|
+
.milkdown-custom .milkdown .milkdown-code-block:focus-within .code-toolbar {
|
|
209
|
+
opacity: 1;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.milkdown-custom .milkdown .milkdown-code-block .language-label {
|
|
213
|
+
pointer-events: auto;
|
|
214
|
+
font-family: var(--crepe-font-default);
|
|
215
|
+
font-size: 12px;
|
|
216
|
+
font-weight: 600;
|
|
217
|
+
line-height: 16px;
|
|
218
|
+
color: var(--crepe-color-on-surface-variant);
|
|
219
|
+
background: var(--crepe-color-surface-low);
|
|
220
|
+
padding: 2px 8px;
|
|
221
|
+
border-radius: 4px;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.milkdown-custom .milkdown .milkdown-code-block .copy-button {
|
|
225
|
+
pointer-events: auto;
|
|
226
|
+
display: inline-flex;
|
|
227
|
+
align-items: center;
|
|
228
|
+
justify-content: center;
|
|
229
|
+
background: var(--crepe-color-surface-low);
|
|
230
|
+
color: var(--crepe-color-on-surface-variant);
|
|
231
|
+
border-radius: 4px;
|
|
232
|
+
padding: 4px 8px;
|
|
233
|
+
height: 26px;
|
|
234
|
+
width: 32px;
|
|
235
|
+
cursor: pointer;
|
|
236
|
+
transition: background-color 0.2s ease-in-out;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
.milkdown-custom .milkdown .milkdown-code-block .copy-button:hover {
|
|
240
|
+
background: var(--crepe-color-hover);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
.milkdown-custom .milkdown .milkdown-content blockquote {
|
|
244
|
+
position: relative;
|
|
245
|
+
padding-left: 40px;
|
|
246
|
+
padding-top: 0;
|
|
247
|
+
padding-bottom: 0;
|
|
248
|
+
box-sizing: content-box;
|
|
249
|
+
margin: 4px 0;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.milkdown-custom .milkdown .milkdown-content blockquote::before {
|
|
253
|
+
content: "";
|
|
254
|
+
width: 4px;
|
|
255
|
+
left: 0;
|
|
256
|
+
top: 4px;
|
|
257
|
+
bottom: 4px;
|
|
258
|
+
position: absolute;
|
|
259
|
+
background: var(--crepe-color-selected);
|
|
260
|
+
border-radius: 100px;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.milkdown-custom .milkdown .milkdown-content hr {
|
|
264
|
+
border: none;
|
|
265
|
+
background-color: color-mix(
|
|
266
|
+
in srgb,
|
|
267
|
+
var(--crepe-color-outline),
|
|
268
|
+
transparent 80%
|
|
269
|
+
);
|
|
270
|
+
background-clip: content-box;
|
|
271
|
+
padding: 6px 0;
|
|
272
|
+
height: 13px;
|
|
273
|
+
position: relative;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.milkdown-custom .milkdown .milkdown-content ul:not(.contains-task-list) {
|
|
277
|
+
padding: 0;
|
|
278
|
+
list-style-type: disc;
|
|
279
|
+
margin-left: 26px;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
.milkdown-custom
|
|
283
|
+
.milkdown
|
|
284
|
+
.milkdown-content
|
|
285
|
+
ul:not(.contains-task-list)
|
|
286
|
+
li::marker {
|
|
287
|
+
color: var(--crepe-color-outline);
|
|
288
|
+
font-size: 1.2em;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
.milkdown-custom .milkdown .milkdown-content ol {
|
|
292
|
+
padding: 0;
|
|
293
|
+
list-style-type: decimal;
|
|
294
|
+
margin-left: 20px;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
.milkdown-custom .milkdown .milkdown-content li.task-list-item {
|
|
298
|
+
position: relative;
|
|
299
|
+
list-style: none;
|
|
300
|
+
padding-left: 28px;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
.milkdown-custom
|
|
304
|
+
.milkdown
|
|
305
|
+
.milkdown-content
|
|
306
|
+
li.task-list-item
|
|
307
|
+
input[type="checkbox"] {
|
|
308
|
+
width: 20px;
|
|
309
|
+
height: 20px;
|
|
310
|
+
position: absolute;
|
|
311
|
+
left: 0;
|
|
312
|
+
margin: 0;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
.milkdown-custom .milkdown .milkdown-content table {
|
|
316
|
+
border-collapse: collapse;
|
|
317
|
+
table-layout: fixed;
|
|
318
|
+
width: 100%;
|
|
319
|
+
margin: 4px 0;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
.milkdown-custom .milkdown .milkdown-content th,
|
|
323
|
+
.milkdown-custom .milkdown .milkdown-content td {
|
|
324
|
+
border: 1px solid
|
|
325
|
+
color-mix(in srgb, var(--crepe-color-outline), transparent 80%);
|
|
326
|
+
padding: 4px 16px;
|
|
327
|
+
overflow-wrap: anywhere;
|
|
328
|
+
}
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
const utils = require('../../../utils.cjs');
|
|
6
|
+
const React = require('react');
|
|
7
|
+
const ReactMarkdown = require('react-markdown');
|
|
8
|
+
const rehypeHighlight = require('rehype-highlight');
|
|
9
|
+
const rehypeRaw = require('rehype-raw');
|
|
10
|
+
const remarkGfm = require('remark-gfm');
|
|
11
|
+
require('highlight.js/styles/panda-syntax-light.css');
|
|
12
|
+
const lucideReact = require('lucide-react');
|
|
13
|
+
const context = require('@btst/stack/context');
|
|
14
|
+
const defaults = require('./defaults.cjs');
|
|
15
|
+
|
|
16
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
17
|
+
|
|
18
|
+
const ReactMarkdown__default = /*#__PURE__*/_interopDefaultCompat(ReactMarkdown);
|
|
19
|
+
const rehypeHighlight__default = /*#__PURE__*/_interopDefaultCompat(rehypeHighlight);
|
|
20
|
+
const rehypeRaw__default = /*#__PURE__*/_interopDefaultCompat(rehypeRaw);
|
|
21
|
+
const remarkGfm__default = /*#__PURE__*/_interopDefaultCompat(remarkGfm);
|
|
22
|
+
|
|
23
|
+
function containsMath(markdown) {
|
|
24
|
+
return /\$\$[\s\S]+?\$\$/.test(markdown) || // Display math
|
|
25
|
+
/(?<!\$)\$(?!\$)[^\$\n]+?\$(?!\$)/.test(markdown) || // Inline math (not $$)
|
|
26
|
+
/\\begin\{(equation|align|gather|math)\}/.test(markdown);
|
|
27
|
+
}
|
|
28
|
+
function getNodeText(node) {
|
|
29
|
+
if (node == null) return "";
|
|
30
|
+
if (typeof node === "string" || typeof node === "number") return String(node);
|
|
31
|
+
if (Array.isArray(node)) return node.map(getNodeText).join("");
|
|
32
|
+
if (React.isValidElement(node)) {
|
|
33
|
+
const props = node.props;
|
|
34
|
+
return getNodeText(props.children);
|
|
35
|
+
}
|
|
36
|
+
return "";
|
|
37
|
+
}
|
|
38
|
+
function simpleHash(str) {
|
|
39
|
+
let hash = 0;
|
|
40
|
+
for (let i = 0; i < str.length; i++) {
|
|
41
|
+
const char = str.charCodeAt(i);
|
|
42
|
+
hash = (hash << 5) - hash + char;
|
|
43
|
+
hash = hash & hash;
|
|
44
|
+
}
|
|
45
|
+
return Math.abs(hash).toString(36).slice(0, 6);
|
|
46
|
+
}
|
|
47
|
+
function isCheckboxElement(node) {
|
|
48
|
+
return React.isValidElement(node) && node.type === "input" && node.props.type === "checkbox";
|
|
49
|
+
}
|
|
50
|
+
function createTaskListItemRenderer() {
|
|
51
|
+
return function LiRenderer(props) {
|
|
52
|
+
const { className, children, ...rest } = props;
|
|
53
|
+
const isTaskItem = (className ?? "").split(" ").includes("task-list-item");
|
|
54
|
+
if (!isTaskItem) {
|
|
55
|
+
return /* @__PURE__ */ jsxRuntime.jsx("li", { className, ...rest, children });
|
|
56
|
+
}
|
|
57
|
+
const childArray = Array.isArray(children) ? children : [children];
|
|
58
|
+
const checkboxNode = childArray.find(isCheckboxElement);
|
|
59
|
+
const nonCheckboxChildren = childArray.filter((c) => !isCheckboxElement(c));
|
|
60
|
+
const labelText = getNodeText(nonCheckboxChildren);
|
|
61
|
+
const baseId = utils.slugify(labelText || "task-item");
|
|
62
|
+
const hashSuffix = simpleHash(labelText || "task-item");
|
|
63
|
+
const uniqueId = `${baseId}-${hashSuffix}`;
|
|
64
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("li", { className, ...rest, children: [
|
|
65
|
+
checkboxNode ? React.createElement(checkboxNode.type, {
|
|
66
|
+
...checkboxNode.props,
|
|
67
|
+
id: uniqueId,
|
|
68
|
+
"aria-label": labelText || "Task item"
|
|
69
|
+
}) : null,
|
|
70
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: uniqueId, children: nonCheckboxChildren })
|
|
71
|
+
] });
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function createHeadingRenderer(tag) {
|
|
75
|
+
return function HeadingRenderer(props) {
|
|
76
|
+
const { children, ...rest } = props;
|
|
77
|
+
const text = getNodeText(children);
|
|
78
|
+
const id = utils.slugify(text);
|
|
79
|
+
return React.createElement(
|
|
80
|
+
tag,
|
|
81
|
+
{ id, ...rest },
|
|
82
|
+
children,
|
|
83
|
+
text ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
84
|
+
"a",
|
|
85
|
+
{
|
|
86
|
+
className: "heading-anchor",
|
|
87
|
+
href: `#${id}`,
|
|
88
|
+
"aria-label": "Link to heading",
|
|
89
|
+
children: "#"
|
|
90
|
+
}
|
|
91
|
+
) : null
|
|
92
|
+
);
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function AnchorRenderer(props) {
|
|
96
|
+
const { Link } = context.usePluginOverrides("blog", {
|
|
97
|
+
Link: defaults.DefaultLink
|
|
98
|
+
});
|
|
99
|
+
const { href = "", children, className: anchorClassName, ...rest } = props;
|
|
100
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Link, { href, className: anchorClassName, ...rest, children });
|
|
101
|
+
}
|
|
102
|
+
function ImgRenderer(props) {
|
|
103
|
+
const { Image } = context.usePluginOverrides("blog", {
|
|
104
|
+
Image: defaults.DefaultImage
|
|
105
|
+
});
|
|
106
|
+
const {
|
|
107
|
+
src = "",
|
|
108
|
+
alt = "",
|
|
109
|
+
className: imgClassName,
|
|
110
|
+
width,
|
|
111
|
+
height,
|
|
112
|
+
style,
|
|
113
|
+
...rest
|
|
114
|
+
} = props;
|
|
115
|
+
const imageProps = {
|
|
116
|
+
src,
|
|
117
|
+
alt,
|
|
118
|
+
className: imgClassName,
|
|
119
|
+
style,
|
|
120
|
+
...rest
|
|
121
|
+
};
|
|
122
|
+
if (width != null && height != null) {
|
|
123
|
+
imageProps.width = width;
|
|
124
|
+
imageProps.height = height;
|
|
125
|
+
} else {
|
|
126
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "markdown-image-wrapper", children: /* @__PURE__ */ jsxRuntime.jsx(Image, { ...imageProps }) });
|
|
127
|
+
}
|
|
128
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Image, { ...imageProps });
|
|
129
|
+
}
|
|
130
|
+
function CodeRenderer({ inline, className, children, ...rest }) {
|
|
131
|
+
const hasLanguage = /language-([a-z0-9-]+)/i.test(className ?? "");
|
|
132
|
+
const isInline = inline ?? !hasLanguage;
|
|
133
|
+
if (isInline) {
|
|
134
|
+
return /* @__PURE__ */ jsxRuntime.jsx("code", { className, ...rest, children });
|
|
135
|
+
}
|
|
136
|
+
return /* @__PURE__ */ jsxRuntime.jsx("code", { className, ...rest, children });
|
|
137
|
+
}
|
|
138
|
+
function PreRenderer(props) {
|
|
139
|
+
const { children, ...rest } = props;
|
|
140
|
+
const child = Array.isArray(children) ? children[0] : children;
|
|
141
|
+
let language;
|
|
142
|
+
if (React.isValidElement(child)) {
|
|
143
|
+
const className = child.props.className;
|
|
144
|
+
const match = /language-([a-z0-9-]+)/i.exec(className ?? "");
|
|
145
|
+
language = match?.[1];
|
|
146
|
+
}
|
|
147
|
+
const label = (language ?? "text").toUpperCase();
|
|
148
|
+
const preRef = React.useRef(null);
|
|
149
|
+
const [copied, setCopied] = React.useState(false);
|
|
150
|
+
const resetTimerRef = React.useRef(null);
|
|
151
|
+
let codeText = "";
|
|
152
|
+
if (React.isValidElement(child)) {
|
|
153
|
+
const childProps = child.props;
|
|
154
|
+
codeText = getNodeText(childProps.children);
|
|
155
|
+
}
|
|
156
|
+
const normalized = codeText.endsWith("\n") ? codeText.slice(0, -1) : codeText;
|
|
157
|
+
const lineCount = Math.max(1, normalized.split("\n").length);
|
|
158
|
+
const digitCount = String(lineCount).length;
|
|
159
|
+
const onCopy = async (e) => {
|
|
160
|
+
e.preventDefault();
|
|
161
|
+
e.stopPropagation();
|
|
162
|
+
try {
|
|
163
|
+
const text = preRef.current?.textContent ?? "";
|
|
164
|
+
if (text && typeof navigator !== "undefined" && navigator.clipboard?.writeText) {
|
|
165
|
+
await navigator.clipboard.writeText(text);
|
|
166
|
+
setCopied(true);
|
|
167
|
+
if (resetTimerRef.current) window.clearTimeout(resetTimerRef.current);
|
|
168
|
+
resetTimerRef.current = window.setTimeout(() => {
|
|
169
|
+
setCopied(false);
|
|
170
|
+
resetTimerRef.current = null;
|
|
171
|
+
}, 2e3);
|
|
172
|
+
}
|
|
173
|
+
} catch {
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
177
|
+
"div",
|
|
178
|
+
{
|
|
179
|
+
className: "milkdown-code-block",
|
|
180
|
+
style: {
|
|
181
|
+
["--code-gutter-width"]: `${digitCount + 1}ch`
|
|
182
|
+
},
|
|
183
|
+
children: [
|
|
184
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "code-toolbar", children: [
|
|
185
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "language-label", children: label }),
|
|
186
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
187
|
+
"button",
|
|
188
|
+
{
|
|
189
|
+
type: "button",
|
|
190
|
+
className: "copy-button",
|
|
191
|
+
onClick: onCopy,
|
|
192
|
+
"aria-label": copied ? "Copied" : "Copy code",
|
|
193
|
+
children: copied ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CheckIcon, { size: 16 }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CopyIcon, { size: 16 })
|
|
194
|
+
}
|
|
195
|
+
)
|
|
196
|
+
] }),
|
|
197
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "code-content", children: [
|
|
198
|
+
/* @__PURE__ */ jsxRuntime.jsx("ol", { className: "line-numbers", "aria-hidden": true, children: Array.from({ length: lineCount }).map((_, idx) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: idx + 1 }, idx + 1)) }),
|
|
199
|
+
/* @__PURE__ */ jsxRuntime.jsx("pre", { ref: preRef, ...rest, children })
|
|
200
|
+
] })
|
|
201
|
+
]
|
|
202
|
+
}
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
function MarkdownContent({ markdown, className }) {
|
|
206
|
+
const [mathPlugins, setMathPlugins] = React.useState(null);
|
|
207
|
+
const [isLoadingMath, setIsLoadingMath] = React.useState(false);
|
|
208
|
+
const hasMath = React.useMemo(() => containsMath(markdown), [markdown]);
|
|
209
|
+
React.useEffect(() => {
|
|
210
|
+
if (!hasMath || mathPlugins || isLoadingMath) return;
|
|
211
|
+
setIsLoadingMath(true);
|
|
212
|
+
const katexCSSId = "katex-css";
|
|
213
|
+
if (!document.getElementById(katexCSSId)) {
|
|
214
|
+
const link = document.createElement("link");
|
|
215
|
+
link.id = katexCSSId;
|
|
216
|
+
link.rel = "stylesheet";
|
|
217
|
+
link.href = "https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/katex.min.css";
|
|
218
|
+
link.integrity = "sha384-nB0miv6/jRmo5UMMR1wu3Gz6NLsoTkbqJghGIsx//Rlm+ZU03BU6SQNC66uf4l5+";
|
|
219
|
+
link.crossOrigin = "anonymous";
|
|
220
|
+
document.head.appendChild(link);
|
|
221
|
+
const fontDisplayStyleId = "katex-font-display-override";
|
|
222
|
+
if (!document.getElementById(fontDisplayStyleId)) {
|
|
223
|
+
const style = document.createElement("style");
|
|
224
|
+
style.id = fontDisplayStyleId;
|
|
225
|
+
style.textContent = `
|
|
226
|
+
/* Override KaTeX font-face declarations to add font-display: swap */
|
|
227
|
+
@font-face {
|
|
228
|
+
font-family: 'KaTeX_Main';
|
|
229
|
+
font-style: normal;
|
|
230
|
+
font-weight: normal;
|
|
231
|
+
font-display: swap;
|
|
232
|
+
src: url('https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/fonts/KaTeX_Main-Regular.woff2') format('woff2');
|
|
233
|
+
}
|
|
234
|
+
@font-face {
|
|
235
|
+
font-family: 'KaTeX_Math';
|
|
236
|
+
font-style: italic;
|
|
237
|
+
font-weight: normal;
|
|
238
|
+
font-display: swap;
|
|
239
|
+
src: url('https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/fonts/KaTeX_Math-Italic.woff2') format('woff2');
|
|
240
|
+
}
|
|
241
|
+
@font-face {
|
|
242
|
+
font-family: 'KaTeX_Size1';
|
|
243
|
+
font-style: normal;
|
|
244
|
+
font-weight: normal;
|
|
245
|
+
font-display: swap;
|
|
246
|
+
src: url('https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/fonts/KaTeX_Size1-Regular.woff2') format('woff2');
|
|
247
|
+
}
|
|
248
|
+
@font-face {
|
|
249
|
+
font-family: 'KaTeX_Size2';
|
|
250
|
+
font-style: normal;
|
|
251
|
+
font-weight: normal;
|
|
252
|
+
font-display: swap;
|
|
253
|
+
src: url('https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/fonts/KaTeX_Size2-Regular.woff2') format('woff2');
|
|
254
|
+
}
|
|
255
|
+
@font-face {
|
|
256
|
+
font-family: 'KaTeX_Size3';
|
|
257
|
+
font-style: normal;
|
|
258
|
+
font-weight: normal;
|
|
259
|
+
font-display: swap;
|
|
260
|
+
src: url('https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/fonts/KaTeX_Size3-Regular.woff2') format('woff2');
|
|
261
|
+
}
|
|
262
|
+
@font-face {
|
|
263
|
+
font-family: 'KaTeX_Size4';
|
|
264
|
+
font-style: normal;
|
|
265
|
+
font-weight: normal;
|
|
266
|
+
font-display: swap;
|
|
267
|
+
src: url('https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/fonts/KaTeX_Size4-Regular.woff2') format('woff2');
|
|
268
|
+
}
|
|
269
|
+
`;
|
|
270
|
+
document.head.appendChild(style);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
Promise.all([import('remark-math'), import('rehype-katex')]).then(([remarkMathModule, rehypeKatexModule]) => {
|
|
274
|
+
setMathPlugins({
|
|
275
|
+
remarkMath: remarkMathModule.default,
|
|
276
|
+
rehypeKatex: rehypeKatexModule.default
|
|
277
|
+
});
|
|
278
|
+
}).catch((error) => {
|
|
279
|
+
console.error("Failed to load math plugins:", error);
|
|
280
|
+
}).finally(() => {
|
|
281
|
+
setIsLoadingMath(false);
|
|
282
|
+
});
|
|
283
|
+
}, [hasMath, mathPlugins, isLoadingMath]);
|
|
284
|
+
const components = React.useMemo(() => {
|
|
285
|
+
return {
|
|
286
|
+
a: AnchorRenderer,
|
|
287
|
+
img: ImgRenderer,
|
|
288
|
+
code: CodeRenderer,
|
|
289
|
+
pre: PreRenderer,
|
|
290
|
+
h1: createHeadingRenderer("h1"),
|
|
291
|
+
h2: createHeadingRenderer("h2"),
|
|
292
|
+
h3: createHeadingRenderer("h3"),
|
|
293
|
+
h4: createHeadingRenderer("h4"),
|
|
294
|
+
h5: createHeadingRenderer("h5"),
|
|
295
|
+
h6: createHeadingRenderer("h6"),
|
|
296
|
+
li: createTaskListItemRenderer()
|
|
297
|
+
};
|
|
298
|
+
}, []);
|
|
299
|
+
const remarkPlugins = React.useMemo(() => {
|
|
300
|
+
const plugins = [remarkGfm__default];
|
|
301
|
+
if (hasMath && mathPlugins?.remarkMath) {
|
|
302
|
+
plugins.push(mathPlugins.remarkMath);
|
|
303
|
+
}
|
|
304
|
+
return plugins;
|
|
305
|
+
}, [hasMath, mathPlugins]);
|
|
306
|
+
const rehypePlugins = React.useMemo(() => {
|
|
307
|
+
const plugins = [rehypeRaw__default, rehypeHighlight__default];
|
|
308
|
+
if (hasMath && mathPlugins?.rehypeKatex) {
|
|
309
|
+
plugins.push(mathPlugins.rehypeKatex);
|
|
310
|
+
}
|
|
311
|
+
return plugins;
|
|
312
|
+
}, [hasMath, mathPlugins]);
|
|
313
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: utils.cn("milkdown-custom", className), children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "milkdown", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "milkdown-content", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
314
|
+
ReactMarkdown__default,
|
|
315
|
+
{
|
|
316
|
+
remarkPlugins,
|
|
317
|
+
rehypePlugins,
|
|
318
|
+
components,
|
|
319
|
+
children: markdown
|
|
320
|
+
}
|
|
321
|
+
) }) }) });
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
exports.MarkdownContent = MarkdownContent;
|