@publish.os/nextjs 0.0.1-alpha.90 → 0.0.1-alpha.91
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/compiler-assets/nextjs/defaults/group/layout.tsx +1 -5
- package/compiler-assets/nextjs/defaults/group/page.tsx +31 -22
- package/compiler-assets/nextjs/defaults/project/next.config.mjs +19 -10
- package/compiler-assets/nextjs/defaults/project/tsconfig.json.template +10 -0
- package/compiler-assets/nextjs/defaults/root/css/components/code-block.css +18 -0
- package/compiler-assets/nextjs/shims/document.tsx +38 -0
- package/compiler-assets/nextjs/shims/generated-leaf-page.tsx +2 -0
- package/compiler-assets/nextjs/shims/global-layout.tsx +8 -42
- package/compiler-assets/nextjs/shims/global-not-found.tsx +69 -0
- package/compiler-assets/nextjs/shims/markdown-route.ts +2 -0
- package/compiler-assets/nextjs/shims/metadata-icons.tsx +39 -0
- package/compiler-assets/nextjs/shims/not-found-content.tsx +53 -0
- package/compiler-assets/nextjs/shims/not-found-navigation.tsx +60 -0
- package/compiler-assets/nextjs/shims/proxy.ts +126 -60
- package/compiler-assets/nextjs/shims/site-fenced-code-block.tsx +2 -6
- package/compiler-assets/nextjs/shims/site-mdx-components.tsx +28 -16
- package/compiler-assets/nextjs/shims/site-mdx.tsx +6 -1
- package/dist/{build-operation-2JAYBSKF.js → build-operation-5QMLXF7N.js} +29 -23
- package/dist/{button-c3WGnxIj.d.ts → button-BdCScEKi.d.ts} +3 -3
- package/dist/capture-local-source-WGGDIUU2.js +258 -0
- package/dist/chunk-22RSSUNV.js +13 -0
- package/dist/{chunk-WKTEO6RS.js → chunk-4BC2L2KA.js} +46 -12
- package/dist/{chunk-WDY4IK6Z.js → chunk-5J3YUNRY.js} +3 -10
- package/dist/chunk-5KAD7W53.js +248 -0
- package/dist/{chunk-DWA3ZRGW.js → chunk-6C65KV7O.js} +2 -2
- package/dist/{chunk-GGKFQ3MA.js → chunk-6D2E6UMD.js} +144 -70
- package/dist/{chunk-7OGTPSKI.js → chunk-7NY22B5U.js} +8 -3
- package/dist/chunk-EFO6AWXN.js +19 -0
- package/dist/{chunk-726GV2NF.js → chunk-F3AGNDF4.js} +100 -67
- package/dist/chunk-GBPLER5H.js +426 -0
- package/dist/chunk-IL4RJOKI.js +186 -0
- package/dist/{chunk-DLDFHU7Y.js → chunk-NNBJZPFM.js} +4 -2
- package/dist/{chunk-VO2I7MTM.js → chunk-ORIUWJBQ.js} +8 -6
- package/dist/{chunk-H6XILMZX.js → chunk-OXOFRXEI.js} +1806 -831
- package/dist/chunk-UYGCOWRF.js +1709 -0
- package/dist/{chunk-YLTOLYWM.js → chunk-WL75GQ5M.js} +6 -18
- package/dist/compiler.d.ts +15 -2
- package/dist/compiler.js +90 -21
- package/dist/components/blocks/agent-actions.d.ts +81 -0
- package/dist/components/blocks/agent-actions.js +594 -0
- package/dist/components/blocks/toc.d.ts +43 -0
- package/dist/components/blocks/toc.js +136 -0
- package/dist/components/ui/button.d.ts +5 -0
- package/dist/components/ui/button.js +94 -0
- package/dist/compose-CVBJRAF6.js +16 -0
- package/dist/config/createNextConfig.js +17 -3
- package/dist/{dev-operation-TZDVJCN7.js → dev-operation-OSHHWRWK.js} +121 -81
- package/dist/{framework-selection-X4U6Y6QC.js → framework-selection-ZVO323PK.js} +3 -2
- package/dist/ide-support-CU6Z5PVR.js +16 -0
- package/dist/index.d.ts +40 -1
- package/dist/jsx-dev-runtime.d.ts +6 -0
- package/dist/jsx-dev-runtime.js +100 -0
- package/dist/jsx-runtime.d.ts +7 -0
- package/dist/jsx-runtime.js +97 -0
- package/dist/kernel/components/blocks/AgentActions.d.ts +35 -6
- package/dist/kernel/components/blocks/AgentActions.js +383 -142
- package/dist/kernel/components/blocks/agent-actions.d.ts +5 -0
- package/dist/kernel/components/blocks/agent-actions.js +594 -0
- package/dist/kernel/components/blocks/animated-icon-swap.js +1 -1
- package/dist/kernel/components/blocks/color-palette.js +4 -4
- package/dist/kernel/components/blocks/logo-block.js +1 -1
- package/dist/kernel/components/blocks/nav-breadcrumb.js +2 -2
- package/dist/kernel/components/blocks/navbar.js +17 -17
- package/dist/kernel/components/blocks/navigation-progress.js +2 -2
- package/dist/kernel/components/blocks/next-prev.js +1 -1
- package/dist/kernel/components/blocks/page-list.js +2 -2
- package/dist/kernel/components/blocks/search.d.ts +1 -1
- package/dist/kernel/components/blocks/search.js +16 -17
- package/dist/kernel/components/blocks/sidebar-node.js +1 -1
- package/dist/kernel/components/blocks/sidebar.js +7 -4
- package/dist/kernel/components/blocks/theme-toggle.d.ts +1 -1
- package/dist/kernel/components/blocks/theme-toggle.js +5 -5
- package/dist/kernel/components/blocks/toc-client.d.ts +40 -0
- package/dist/kernel/components/blocks/toc-client.js +495 -0
- package/dist/kernel/components/blocks/toc.d.ts +19 -1
- package/dist/kernel/components/blocks/toc.js +121 -179
- package/dist/kernel/components/mdx/components/blockquote.js +1 -1
- package/dist/kernel/components/mdx/components/callout.js +1 -1
- package/dist/kernel/components/mdx/components/code-block.js +2 -2
- package/dist/kernel/components/mdx/components/copy-code-button.js +5 -4
- package/dist/kernel/components/mdx/components/figure-caption.d.ts +1 -1
- package/dist/kernel/components/mdx/components/figure-caption.js +3 -2
- package/dist/kernel/components/mdx/components/figure.d.ts +6 -2
- package/dist/kernel/components/mdx/components/figure.js +23 -13
- package/dist/kernel/components/mdx/components/footnotes.js +1 -1
- package/dist/kernel/components/mdx/components/heading-copy-link.js +1 -1
- package/dist/kernel/components/mdx/components/heading.js +6 -3
- package/dist/kernel/components/mdx/components/hr.js +2 -2
- package/dist/kernel/components/mdx/components/image-zoom.js +1 -1
- package/dist/kernel/components/mdx/components/image.d.ts +1 -1
- package/dist/kernel/components/mdx/components/image.js +21 -16
- package/dist/kernel/components/mdx/components/inline-code.js +1 -1
- package/dist/kernel/components/mdx/components/kbd.js +2 -2
- package/dist/kernel/components/mdx/components/link.d.ts +3 -3
- package/dist/kernel/components/mdx/components/link.js +2 -2
- package/dist/kernel/components/mdx/components/paragraph.js +1 -1
- package/dist/kernel/components/mdx/components/strikethrough.js +1 -1
- package/dist/kernel/components/mdx/components/table.js +2 -2
- package/dist/kernel/components/mdx/components/task-list.js +1 -1
- package/dist/kernel/components/mdx/components/video-player.d.ts +6 -2
- package/dist/kernel/components/mdx/components/video-player.js +6 -2
- package/dist/kernel/components/mdx/components/video.d.ts +5 -3
- package/dist/kernel/components/mdx/components/video.js +7 -5
- package/dist/kernel/components/mdx/error-boundary.d.ts +1 -1
- package/dist/kernel/components/mdx/error-boundary.js +2 -2
- package/dist/kernel/components/mdx/error-fallback.js +1 -1
- package/dist/kernel/components/mdx/mdx.d.ts +20 -10
- package/dist/kernel/components/mdx/mdx.js +231 -34
- package/dist/kernel/components/mdx/rehype-heading-ids.d.ts +1 -0
- package/dist/kernel/components/mdx/rehype-heading-ids.js +5 -3
- package/dist/kernel/components/mdx/types.d.ts +1 -1
- package/dist/kernel/components/next-image.d.ts +12 -0
- package/dist/kernel/components/next-image.js +61 -0
- package/dist/kernel/components/ui/accordion.js +1 -1
- package/dist/kernel/components/ui/breadcrumb-trail.d.ts +2 -2
- package/dist/kernel/components/ui/breadcrumb-trail.js +2 -2
- package/dist/kernel/components/ui/breadcrumb.d.ts +1 -1
- package/dist/kernel/components/ui/breadcrumb.js +4 -4
- package/dist/kernel/components/ui/button-group.d.ts +1 -1
- package/dist/kernel/components/ui/button-group.js +3 -3
- package/dist/kernel/components/ui/button.d.ts +56 -4
- package/dist/kernel/components/ui/button.js +43 -39
- package/dist/kernel/components/ui/card.js +1 -1
- package/dist/kernel/components/ui/dialog.js +1 -1
- package/dist/kernel/components/ui/drawer.js +1 -1
- package/dist/kernel/components/ui/input.d.ts +2 -2
- package/dist/kernel/components/ui/input.js +1 -1
- package/dist/kernel/components/ui/kbd.d.ts +1 -1
- package/dist/kernel/components/ui/kbd.js +1 -1
- package/dist/kernel/components/ui/link.d.ts +8 -2
- package/dist/kernel/components/ui/link.js +2 -2
- package/dist/kernel/components/ui/menu.js +1 -1
- package/dist/kernel/components/ui/mod-key.js +2 -2
- package/dist/kernel/components/ui/navigation-menu.js +1 -1
- package/dist/kernel/components/ui/popover.js +1 -1
- package/dist/kernel/components/ui/progress.js +1 -1
- package/dist/kernel/components/ui/scroll-area.d.ts +8 -8
- package/dist/kernel/components/ui/scroll-area.js +1 -1
- package/dist/kernel/components/ui/select.js +1 -1
- package/dist/kernel/components/ui/separator.js +1 -1
- package/dist/kernel/components/ui/table.js +1 -1
- package/dist/kernel/components/ui/tabs.js +1 -1
- package/dist/kernel/components/ui/tag.js +1 -1
- package/dist/kernel/components/ui/text.d.ts +1 -1
- package/dist/kernel/components/ui/text.js +1 -1
- package/dist/kernel/components/ui/toast.js +1 -1
- package/dist/kernel/components/ui/tooltip.js +1 -1
- package/dist/kernel/defaults.registry.d.ts +2 -15
- package/dist/kernel/defaults.registry.js +2 -17
- package/dist/kernel/routes/agent/markdown.d.ts +3 -0
- package/dist/kernel/routes/agent/markdown.js +219 -48
- package/dist/kernel/routes/layouts/group.d.ts +1 -1
- package/dist/kernel/routes/layouts/group.js +5 -7
- package/dist/kernel/routes/metadata/feed.d.ts +1 -1
- package/dist/kernel/routes/metadata/feed.js +109 -83
- package/dist/kernel/routes/metadata/llms.d.ts +11 -3
- package/dist/kernel/routes/metadata/llms.js +154 -57
- package/dist/kernel/routes/metadata/og-image.js +1 -1
- package/dist/kernel/routes/metadata/robots.d.ts +1 -1
- package/dist/kernel/routes/metadata/sitemap.d.ts +22 -3
- package/dist/kernel/routes/metadata/sitemap.js +183 -43
- package/dist/kernel/routes/not-found.d.ts +34 -0
- package/dist/kernel/routes/not-found.js +213 -0
- package/dist/kernel/routes/pages/group.d.ts +2 -2
- package/dist/kernel/routes/pages/group.js +1 -1
- package/dist/kernel/routes/pages/leaf.d.ts +30 -3
- package/dist/kernel/routes/pages/leaf.js +5 -4
- package/dist/kernel/routes/pages/root.d.ts +2 -2
- package/dist/kernel/routes/pages/root.js +1 -1
- package/dist/keyboard-shortcuts.js +1 -1
- package/dist/route-metadata-og-image-BeKKFHg7.d.ts +58 -0
- package/dist/search.js +7 -9
- package/dist/theme-scope.js +1 -1
- package/dist/{types-BzkZty3r.d.ts → types-J2w_puPF.d.ts} +1 -20
- package/dist/types-sM2g9nW0.d.ts +12 -0
- package/dist/types.d.ts +1 -0
- package/dist/utils/heading-ids.js +30 -11
- package/dist/utils/toc-selection.d.ts +7 -0
- package/dist/utils/toc-selection.js +14 -0
- package/dist/validate-local-source-SV44DBQT.js +16 -0
- package/dist/validate-publish-os-source-NZJF3TB2.js +14 -0
- package/init/seed/minimal/publish.os/assets/blog/hello-world.svg +13 -0
- package/init/seed/minimal/publish.os/assets/favicon.dark.svg +13 -0
- package/init/seed/minimal/publish.os/assets/favicon.svg +13 -0
- package/init/seed/minimal/publish.os/blog/content/hello-world.mdx +48 -0
- package/init/seed/minimal/publish.os/blog/content/series-a.mdx +11 -0
- package/init/seed/minimal/publish.os/blog/index.tsx +82 -0
- package/init/seed/minimal/publish.os/blog/layout.tsx +13 -0
- package/init/seed/minimal/publish.os/blog/page.tsx +76 -0
- package/init/seed/minimal/publish.os/components/blog/copy-link.tsx +64 -0
- package/init/seed/minimal/publish.os/docs/content/get-started.mdx +2 -3
- package/init/seed/minimal/publish.os/docs/content/groups.mdx +5 -6
- package/init/seed/minimal/publish.os/publish.os.config.json +6 -2
- package/init/seed/minimal/publish.os/theme.css +3 -3
- package/init/seed/minimal/seed.json +11 -4
- package/init/seed/scratch/publish.os/docs/content/get-started.mdx +1 -1
- package/init/seed/scratch/publish.os/publish.os.config.json +1 -1
- package/package.json +45 -20
- package/release/app/phosphor/package.json +3 -3
- package/release/app/phosphor/pnpm-lock.yaml.template +88 -75
- package/release/compiler/package.json +5 -3
- package/release/compiler/pnpm-lock.yaml.template +118 -74
- package/release/release.json +6 -6
- package/dist/button-CtzUJB8u.d.ts +0 -11
- package/dist/chunk-535TM4A5.js +0 -1455
- package/dist/chunk-B2V22WRT.js +0 -297
- package/dist/chunk-NECL5IBJ.js +0 -318
- package/dist/chunk-SVYGXXYR.js +0 -36
- package/dist/chunk-UF6ATARM.js +0 -1100
- package/dist/compose-NN23UJGC.js +0 -13
- package/dist/ide-support-ZNW7ODFY.js +0 -15
- package/dist/kernel/components/blocks/design-system-preview.d.ts +0 -61
- package/dist/kernel/components/blocks/design-system-preview.js +0 -667
- package/dist/kernel/components/blocks/link-playground.d.ts +0 -5
- package/dist/kernel/components/blocks/link-playground.js +0 -744
- package/dist/kernel/components/blocks/navigation-progress-playground.d.ts +0 -5
- package/dist/kernel/components/blocks/navigation-progress-playground.js +0 -629
- package/dist/kernel/components/ui/theme-toggle.d.ts +0 -24
- package/dist/kernel/components/ui/theme-toggle.js +0 -53
- package/dist/validate-local-source-XRL2Y7XE.js +0 -14
- package/dist/validate-publish-os-source-DAPZ4QGE.js +0 -12
- package/init/seed/minimal/publish.os/assets/favicon/favicon.dark.png +0 -0
- package/init/seed/minimal/publish.os/assets/favicon/favicon.png +0 -0
|
@@ -1,194 +1,136 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
1
|
// src/components/block/toc/toc.tsx
|
|
4
|
-
import { cn } from "@publish.os/nextjs/utils/cn";
|
|
5
2
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
3
|
+
TocClientProvider,
|
|
4
|
+
TocDesktop,
|
|
5
|
+
TocLinksSlot,
|
|
6
|
+
TocMobile,
|
|
7
|
+
TocMobileHeader,
|
|
8
|
+
TocTitle
|
|
9
|
+
} from "@publish.os/nextjs/kernel/components/blocks/toc-client";
|
|
10
|
+
import { cn } from "@publish.os/nextjs/utils/cn";
|
|
11
|
+
|
|
12
|
+
// src/components/block/toc/extract-headings.ts
|
|
13
|
+
import remarkGfm from "remark-gfm";
|
|
14
|
+
import remarkMdx from "remark-mdx";
|
|
15
|
+
import remarkParse from "remark-parse";
|
|
16
|
+
import { unified } from "unified";
|
|
17
|
+
|
|
18
|
+
// src/components/mdx/heading-string.ts
|
|
19
|
+
var SELF_CLOSING_TAG_RE = /<[^>]+\/>/g, PAIRED_TAG_RE = /<\/?\w[^>]*>/g, MDX_BOLD_RE = /\*\*(.*?)\*\*/g, MDX_ITALIC_RE = /\*(.*?)\*/g, MDX_UNDERLINE_BOLD_RE = /__(.*?)__/g, MDX_UNDERLINE_ITALIC_RE = /_(.*?)_/g, MDX_STRIKETHROUGH_RE = /~~(.*?)~~/g, MDX_INLINE_CODE_RE = /`(.*?)`/g, MDX_LINK_RE = /\[(.*?)\]\(.*?\)/g, NON_ALPHANUMERIC_RE = /[^a-z0-9]+/g, LEADING_TRAILING_HYPHEN_RE = /^-+|-+$/g, LEADING_DIGIT_RE = /^(\d)/;
|
|
20
|
+
function cleanHeadingString(input) {
|
|
21
|
+
return input.replace(SELF_CLOSING_TAG_RE, "").replace(PAIRED_TAG_RE, "").replace(MDX_BOLD_RE, "$1").replace(MDX_ITALIC_RE, "$1").replace(MDX_UNDERLINE_BOLD_RE, "$1").replace(MDX_UNDERLINE_ITALIC_RE, "$1").replace(MDX_STRIKETHROUGH_RE, "$1").replace(MDX_INLINE_CODE_RE, "$1").replace(MDX_LINK_RE, "$1").trim();
|
|
22
22
|
}
|
|
23
|
-
function
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
for (let element of elements)
|
|
27
|
-
if (element.getBoundingClientRect().top <= ACTIVATION_OFFSET)
|
|
28
|
-
nextActiveId = element.id;
|
|
29
|
-
else
|
|
30
|
-
break;
|
|
31
|
-
return nextActiveId;
|
|
23
|
+
function headingStringToHTMLId(input) {
|
|
24
|
+
let text = cleanHeadingString(input);
|
|
25
|
+
return text ? text.toLowerCase().replace(NON_ALPHANUMERIC_RE, "-").replace(LEADING_TRAILING_HYPHEN_RE, "").replace(LEADING_DIGIT_RE, "id-$1") || "heading" : "empty-heading";
|
|
32
26
|
}
|
|
33
|
-
function
|
|
34
|
-
let
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}, []), updateActiveHeading = useCallback(() => {
|
|
43
|
-
if (clickedIdRef.current) {
|
|
44
|
-
setActiveId(
|
|
45
|
-
(current) => current === clickedIdRef.current ? current : clickedIdRef.current ?? ""
|
|
46
|
-
);
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
let elements = headingIds.map((id) => document.getElementById(id)).filter((element) => !!element);
|
|
50
|
-
if (elements.length === 0) return;
|
|
51
|
-
let nextActiveId = resolveActiveHeading(elements);
|
|
52
|
-
setActiveId(
|
|
53
|
-
(current) => current === nextActiveId ? current : nextActiveId
|
|
54
|
-
);
|
|
55
|
-
}, [headingIds]), updateIndicator = useCallback(() => {
|
|
56
|
-
let container = contentRef.current;
|
|
57
|
-
if (!container || !activeId) {
|
|
58
|
-
setIndicatorStyle({ height: 0, transform: 0 });
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
let activeLink = Array.from(
|
|
62
|
-
container.querySelectorAll("[data-toc-link]")
|
|
63
|
-
).find((link) => link.dataset.tocId === activeId);
|
|
64
|
-
if (!activeLink) {
|
|
65
|
-
setIndicatorStyle({ height: 0, transform: 0 });
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
let containerRect = container.getBoundingClientRect(), activeRect = activeLink.getBoundingClientRect(), nextStyle = {
|
|
69
|
-
height: activeRect.height,
|
|
70
|
-
transform: activeRect.top - containerRect.top
|
|
71
|
-
};
|
|
72
|
-
setIndicatorStyle(
|
|
73
|
-
(current) => current.height === nextStyle.height && current.transform === nextStyle.transform ? current : nextStyle
|
|
74
|
-
);
|
|
75
|
-
}, [activeId]), updateViewport = useCallback(() => {
|
|
76
|
-
updateIndicator();
|
|
77
|
-
let viewport = viewportRef.current;
|
|
78
|
-
if (!viewport) return;
|
|
79
|
-
let hasOverflow = viewport.scrollHeight > viewport.clientHeight + 1, nextMask = {
|
|
80
|
-
bottom: hasOverflow && viewport.scrollTop + viewport.clientHeight < viewport.scrollHeight - 1,
|
|
81
|
-
top: hasOverflow && viewport.scrollTop > 0
|
|
82
|
-
};
|
|
83
|
-
setScrollMask(
|
|
84
|
-
(current) => current.top === nextMask.top && current.bottom === nextMask.bottom ? current : nextMask
|
|
85
|
-
);
|
|
86
|
-
}, [updateIndicator]);
|
|
87
|
-
useEffect(() => {
|
|
88
|
-
let scheduleUpdate = () => {
|
|
89
|
-
frameRef.current === null && (frameRef.current = window.requestAnimationFrame(() => {
|
|
90
|
-
frameRef.current = null, updateActiveHeading(), updateViewport();
|
|
91
|
-
}));
|
|
92
|
-
}, handleKeyDown = (event) => {
|
|
93
|
-
SCROLL_KEYS.has(event.key) && clearClickedId();
|
|
94
|
-
};
|
|
95
|
-
return scheduleUpdate(), window.addEventListener("scroll", scheduleUpdate, { passive: !0 }), window.addEventListener("resize", scheduleUpdate), window.addEventListener("hashchange", scheduleUpdate), window.addEventListener("wheel", clearClickedId, { passive: !0 }), window.addEventListener("touchstart", clearClickedId, { passive: !0 }), window.addEventListener("keydown", handleKeyDown), () => {
|
|
96
|
-
window.removeEventListener("scroll", scheduleUpdate), window.removeEventListener("resize", scheduleUpdate), window.removeEventListener("hashchange", scheduleUpdate), window.removeEventListener("wheel", clearClickedId), window.removeEventListener("touchstart", clearClickedId), window.removeEventListener("keydown", handleKeyDown), frameRef.current !== null && (window.cancelAnimationFrame(frameRef.current), frameRef.current = null);
|
|
97
|
-
};
|
|
98
|
-
}, [clearClickedId, updateActiveHeading, updateViewport]), useEffect(() => {
|
|
99
|
-
updateViewport();
|
|
100
|
-
}, [updateViewport]);
|
|
101
|
-
let handleTocClick = useCallback((id) => {
|
|
102
|
-
clickedIdRef.current = id, setActiveId(id);
|
|
103
|
-
}, []);
|
|
104
|
-
return {
|
|
105
|
-
activeId,
|
|
106
|
-
contentRef,
|
|
107
|
-
handleTocClick,
|
|
108
|
-
indicatorStyle,
|
|
109
|
-
scrollMask,
|
|
110
|
-
updateViewport,
|
|
111
|
-
viewportRef
|
|
27
|
+
function createHeadingStringIdGenerator() {
|
|
28
|
+
let nextSuffix = /* @__PURE__ */ new Map(), usedIds = /* @__PURE__ */ new Set();
|
|
29
|
+
return (input) => {
|
|
30
|
+
let baseId = headingStringToHTMLId(input);
|
|
31
|
+
if (baseId === "empty-heading") return baseId;
|
|
32
|
+
let suffix = nextSuffix.get(baseId) ?? 0, id = suffix === 0 ? baseId : `${baseId}-${suffix}`;
|
|
33
|
+
for (; usedIds.has(id); )
|
|
34
|
+
suffix += 1, id = `${baseId}-${suffix}`;
|
|
35
|
+
return nextSuffix.set(baseId, suffix + 1), usedIds.add(id), id;
|
|
112
36
|
};
|
|
113
37
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
),
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
return
|
|
133
|
-
|
|
38
|
+
|
|
39
|
+
// src/components/block/toc/extract-headings.ts
|
|
40
|
+
var parser = unified().use(remarkParse).use(remarkMdx).use(remarkGfm);
|
|
41
|
+
function nodeText(node) {
|
|
42
|
+
return node.type === "text" || node.type === "inlineCode" ? typeof node.value == "string" ? node.value : "" : node.type === "image" || node.type === "imageReference" ? node.alt ?? "" : node.type === "break" || node.name === "br" ? " " : node.type === "mdxTextExpression" || node.type === "mdxFlowExpression" ? "" : (node.children ?? []).map(nodeText).join("");
|
|
43
|
+
}
|
|
44
|
+
function extractTocHeadings(content, levels) {
|
|
45
|
+
let [minDepth, maxDepth] = levels, headingId = createHeadingStringIdGenerator(), headings = [], tree = parser.parse(content);
|
|
46
|
+
function visit(node) {
|
|
47
|
+
if (node.type === "heading" && node.depth) {
|
|
48
|
+
let text = nodeText(node).trim();
|
|
49
|
+
if (text) {
|
|
50
|
+
let id = headingId(text);
|
|
51
|
+
node.depth >= minDepth && node.depth <= maxDepth && headings.push({ id, level: node.depth, text });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
for (let child of node.children ?? []) visit(child);
|
|
55
|
+
}
|
|
56
|
+
return visit(tree), headings;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// src/components/block/toc/toc.tsx
|
|
60
|
+
import { Fragment, jsx, jsxs } from "@publish.os/nextjs/jsx-runtime";
|
|
61
|
+
var DEFAULT_LEVELS = [2, 3];
|
|
62
|
+
function TocRoot({
|
|
63
|
+
className,
|
|
64
|
+
content = "",
|
|
65
|
+
desktopClassName,
|
|
66
|
+
desktopListClassName,
|
|
67
|
+
levels = DEFAULT_LEVELS,
|
|
68
|
+
listClassName,
|
|
69
|
+
mobileClassName,
|
|
70
|
+
mobileQuery = "(max-width: 1279px)",
|
|
71
|
+
readingOffset,
|
|
72
|
+
title = "On this page",
|
|
73
|
+
children
|
|
74
|
+
}) {
|
|
75
|
+
let headings = extractTocHeadings(content, levels);
|
|
76
|
+
return headings.length <= 1 ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
134
77
|
/* @__PURE__ */ jsx(
|
|
135
|
-
|
|
78
|
+
TocClientProvider,
|
|
136
79
|
{
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
className: "absolute left-0 w-px rounded-full bg-accent-1 transition-all duration-300 ease-out will-change-transform",
|
|
151
|
-
style: {
|
|
152
|
-
height: indicatorStyle.height,
|
|
153
|
-
transform: `translateY(${indicatorStyle.transform}px) scaleY(${activeId ? 1 : 0.5})`,
|
|
154
|
-
transformOrigin: "top"
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
),
|
|
158
|
-
/* @__PURE__ */ jsx("ol", { className: "flex min-w-0 flex-col gap-0.5 pl-3", children: headings.map((heading, index) => {
|
|
159
|
-
let active = activeId === heading.id;
|
|
160
|
-
return /* @__PURE__ */ jsx(
|
|
161
|
-
"li",
|
|
162
|
-
{
|
|
163
|
-
style: {
|
|
164
|
-
marginLeft: Math.max(heading.level - levels[0], 0) * 12,
|
|
165
|
-
marginTop: heading.level === levels[0] && index > 0 ? 4 : 0
|
|
166
|
-
},
|
|
167
|
-
children: /* @__PURE__ */ jsx(
|
|
168
|
-
"a",
|
|
169
|
-
{
|
|
170
|
-
"aria-current": active ? "location" : void 0,
|
|
171
|
-
className: cn(
|
|
172
|
-
"block rounded-button px-2 py-1 text-[13px] leading-snug text-foreground-3 no-underline transition-[background-color,color,font-weight] duration-200 hover:bg-surface-hover hover:text-foreground-1 hover:no-underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus-stroke",
|
|
173
|
-
active && "bg-surface-active font-medium text-accent-1 shadow-xs"
|
|
174
|
-
),
|
|
175
|
-
"data-state": active ? "heading-active" : void 0,
|
|
176
|
-
"data-toc-id": heading.id,
|
|
177
|
-
"data-toc-link": "",
|
|
178
|
-
href: `#${heading.id}`,
|
|
179
|
-
onClick: () => handleTocClick(heading.id),
|
|
180
|
-
children: /* @__PURE__ */ jsx("span", { className: "block min-w-0 text-wrap wrap-break-word", children: heading.text })
|
|
181
|
-
}
|
|
182
|
-
)
|
|
183
|
-
},
|
|
184
|
-
heading.id
|
|
185
|
-
);
|
|
186
|
-
}) })
|
|
80
|
+
className: cn("text-xs leading-5", className),
|
|
81
|
+
desktopClassName: cn("hidden xl:block", desktopClassName),
|
|
82
|
+
desktopListClassName,
|
|
83
|
+
headings,
|
|
84
|
+
levels,
|
|
85
|
+
listClassName,
|
|
86
|
+
mobileClassName: cn("xl:hidden", mobileClassName),
|
|
87
|
+
mobileQuery,
|
|
88
|
+
readingOffset,
|
|
89
|
+
title,
|
|
90
|
+
children: children ?? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
91
|
+
/* @__PURE__ */ jsx(TocDesktop, {}),
|
|
92
|
+
/* @__PURE__ */ jsx(TocMobile, {})
|
|
187
93
|
] })
|
|
188
94
|
}
|
|
189
|
-
)
|
|
95
|
+
),
|
|
96
|
+
/* @__PURE__ */ jsxs("noscript", { children: [
|
|
97
|
+
/* @__PURE__ */ jsx("style", { children: "[data-toc-mobile-trigger]{display:none}" }),
|
|
98
|
+
/* @__PURE__ */ jsx(
|
|
99
|
+
"nav",
|
|
100
|
+
{
|
|
101
|
+
"aria-label": title,
|
|
102
|
+
className: cn(
|
|
103
|
+
"xl:hidden max-h-[calc(100dvh-2rem)] overflow-y-auto overscroll-contain border-b border-stroke-3 px-6 py-4 text-xs leading-5",
|
|
104
|
+
mobileClassName
|
|
105
|
+
),
|
|
106
|
+
children: /* @__PURE__ */ jsx("ol", { className: cn("space-y-1", listClassName), children: headings.map((heading) => /* @__PURE__ */ jsx(
|
|
107
|
+
"li",
|
|
108
|
+
{
|
|
109
|
+
className: heading.level === levels[0] + 1 ? "ps-3" : void 0,
|
|
110
|
+
children: /* @__PURE__ */ jsx(
|
|
111
|
+
"a",
|
|
112
|
+
{
|
|
113
|
+
className: "block min-h-6 whitespace-normal break-words text-foreground-3 no-underline hover:text-foreground-1 hover:no-underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus-stroke",
|
|
114
|
+
href: `#${heading.id}`,
|
|
115
|
+
children: heading.text
|
|
116
|
+
}
|
|
117
|
+
)
|
|
118
|
+
},
|
|
119
|
+
heading.id
|
|
120
|
+
)) })
|
|
121
|
+
}
|
|
122
|
+
)
|
|
123
|
+
] })
|
|
190
124
|
] });
|
|
191
125
|
}
|
|
126
|
+
var Toc = Object.assign(TocRoot, {
|
|
127
|
+
Desktop: TocDesktop,
|
|
128
|
+
Links: TocLinksSlot,
|
|
129
|
+
Mobile: TocMobile,
|
|
130
|
+
MobileHeader: TocMobileHeader,
|
|
131
|
+
Root: TocRoot,
|
|
132
|
+
Title: TocTitle
|
|
133
|
+
});
|
|
192
134
|
export {
|
|
193
135
|
Toc
|
|
194
136
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/components/mdx/blockquote.tsx
|
|
2
2
|
import { cn } from "@publish.os/nextjs/utils/cn";
|
|
3
|
-
import { jsx } from "
|
|
3
|
+
import { jsx } from "@publish.os/nextjs/jsx-runtime";
|
|
4
4
|
function Blockquote({ className, ...props }) {
|
|
5
5
|
return /* @__PURE__ */ jsx(
|
|
6
6
|
"blockquote",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { cn } from "@publish.os/nextjs/utils/cn";
|
|
3
3
|
import { cva } from "class-variance-authority";
|
|
4
4
|
import { useId } from "react";
|
|
5
|
-
import { jsx, jsxs } from "
|
|
5
|
+
import { jsx, jsxs } from "@publish.os/nextjs/jsx-runtime";
|
|
6
6
|
var calloutVariants = cva(
|
|
7
7
|
"not-markdown-prose my-6 grid min-w-0 items-start gap-2.5 rounded-callout p-3 [&_[data-slot=callout-icon]_svg]:size-[1.125em]",
|
|
8
8
|
{
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// src/components/mdx/code-block/code-block.tsx
|
|
2
|
-
import { CopyCodeButton } from "@
|
|
2
|
+
import { CopyCodeButton } from "@components/mdx/components/copy-code-button";
|
|
3
3
|
import { cn } from "@publish.os/nextjs/utils/cn";
|
|
4
4
|
import { isValidElement } from "react";
|
|
5
5
|
import {
|
|
6
6
|
bundledLanguages,
|
|
7
7
|
codeToHtml
|
|
8
8
|
} from "shiki";
|
|
9
|
-
import { jsx, jsxs } from "
|
|
9
|
+
import { jsx, jsxs } from "@publish.os/nextjs/jsx-runtime";
|
|
10
10
|
var copyButtonRadius = "rounded-[max(calc(var(--radius-codeblock)-0.5rem),0px)]";
|
|
11
11
|
function codeChild(children) {
|
|
12
12
|
if (!isValidElement(children))
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
// src/components/mdx/code-block/copy-code-button.tsx
|
|
4
|
-
import { AnimatedIconSwap } from "@
|
|
5
|
-
import { Button } from "@
|
|
4
|
+
import { AnimatedIconSwap } from "@components/blocks/animated-icon-swap";
|
|
5
|
+
import { Button } from "@components/ui/button";
|
|
6
6
|
import { CheckIcon, CopyIcon } from "@phosphor-icons/react/ssr";
|
|
7
7
|
import { cn } from "@publish.os/nextjs/utils/cn";
|
|
8
8
|
import { useEffect, useRef, useState } from "react";
|
|
9
|
-
import { jsx, jsxs } from "
|
|
9
|
+
import { jsx, jsxs } from "@publish.os/nextjs/jsx-runtime";
|
|
10
10
|
function CopyCodeButton({
|
|
11
11
|
className,
|
|
12
12
|
code
|
|
@@ -30,9 +30,10 @@ function CopyCodeButton({
|
|
|
30
30
|
{
|
|
31
31
|
"aria-label": copied ? "Copied code" : "Copy code",
|
|
32
32
|
className: cn(
|
|
33
|
-
"relative z-content touch-manipulation after:absolute after:-inset-2 after:content-['']
|
|
33
|
+
"relative z-content touch-manipulation after:absolute after:-inset-2 after:content-['']",
|
|
34
34
|
className
|
|
35
35
|
),
|
|
36
|
+
"data-copied": copied ? "true" : void 0,
|
|
36
37
|
"data-slot": "copy-code-button",
|
|
37
38
|
iconOnly: !0,
|
|
38
39
|
onClick: copy,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
|
|
3
|
-
type FigureCaptionProps = React.
|
|
3
|
+
type FigureCaptionProps = React.ComponentProps<"figcaption">;
|
|
4
4
|
declare function FigureCaption({ className, ...props }: FigureCaptionProps): react_jsx_runtime.JSX.Element;
|
|
5
5
|
|
|
6
6
|
export { FigureCaption, type FigureCaptionProps };
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
// src/components/mdx/figure/figure-caption.tsx
|
|
2
2
|
import { cn } from "@publish.os/nextjs/utils/cn";
|
|
3
|
-
import { jsx } from "
|
|
3
|
+
import { jsx } from "@publish.os/nextjs/jsx-runtime";
|
|
4
4
|
function FigureCaption({ className, ...props }) {
|
|
5
5
|
return /* @__PURE__ */ jsx(
|
|
6
6
|
"figcaption",
|
|
7
7
|
{
|
|
8
|
+
"data-slot": "figure-caption",
|
|
8
9
|
className: cn(
|
|
9
|
-
"
|
|
10
|
+
"my-2 px-1 text-start text-xs leading-relaxed text-foreground-3 first:mt-0 last:mb-0 [&>p]:my-0 [&>p]:text-inherit [&>p+p]:mt-2",
|
|
10
11
|
className
|
|
11
12
|
),
|
|
12
13
|
...props
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { FigureCaption } from './figure-caption.js';
|
|
2
3
|
import { ReactNode } from 'react';
|
|
3
4
|
|
|
4
|
-
type FigureProps = React.
|
|
5
|
+
type FigureProps = React.ComponentProps<"figure"> & {
|
|
6
|
+
/** A fallback caption after the children. An authored caption takes precedence. */
|
|
5
7
|
caption?: ReactNode;
|
|
6
|
-
frame?: boolean | "default" | "none";
|
|
7
8
|
};
|
|
8
9
|
declare function Figure({ caption, children, className, ...props }: FigureProps): react_jsx_runtime.JSX.Element;
|
|
10
|
+
declare namespace Figure {
|
|
11
|
+
var Caption: typeof FigureCaption;
|
|
12
|
+
}
|
|
9
13
|
|
|
10
14
|
export { Figure, type FigureProps };
|
|
@@ -1,26 +1,36 @@
|
|
|
1
1
|
// src/components/mdx/figure/figure.tsx
|
|
2
|
-
import { FigureCaption } from "@
|
|
2
|
+
import { FigureCaption } from "@components/mdx/components/figure-caption";
|
|
3
3
|
import { cn } from "@publish.os/nextjs/utils/cn";
|
|
4
|
-
import { Children, isValidElement } from "react";
|
|
5
|
-
import { jsx, jsxs } from "
|
|
4
|
+
import { Children, Fragment, isValidElement } from "react";
|
|
5
|
+
import { jsx, jsxs } from "@publish.os/nextjs/jsx-runtime";
|
|
6
|
+
function containsCaption(children) {
|
|
7
|
+
return Children.toArray(children).some(
|
|
8
|
+
(child) => isValidElement(child) && (child.type === "figcaption" || child.type === FigureCaption || child.type === Fragment && containsCaption(child.props.children))
|
|
9
|
+
);
|
|
10
|
+
}
|
|
6
11
|
function Figure({
|
|
7
12
|
caption,
|
|
8
13
|
children,
|
|
9
14
|
className,
|
|
10
15
|
...props
|
|
11
16
|
}) {
|
|
12
|
-
let
|
|
13
|
-
return
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
let showFallbackCaption = caption != null && caption !== !1 && !containsCaption(children);
|
|
18
|
+
return /* @__PURE__ */ jsxs(
|
|
19
|
+
"figure",
|
|
20
|
+
{
|
|
21
|
+
className: cn(
|
|
22
|
+
"not-markdown-prose my-8 [&>*:has(+figcaption)]:mb-0 [&>figcaption+*]:mt-0",
|
|
23
|
+
className
|
|
24
|
+
),
|
|
25
|
+
...props,
|
|
26
|
+
children: [
|
|
27
|
+
children,
|
|
28
|
+
showFallbackCaption ? /* @__PURE__ */ jsx(FigureCaption, { children: caption }) : null
|
|
29
|
+
]
|
|
17
30
|
}
|
|
18
|
-
|
|
19
|
-
}), /* @__PURE__ */ jsxs("figure", { className: cn("not-markdown-prose my-8", className), ...props, children: [
|
|
20
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col items-center gap-3", children: mediaChildren }),
|
|
21
|
-
authoredCaption ? /* @__PURE__ */ jsx(FigureCaption, { className: "mx-auto max-w-prose text-center", children: authoredCaption }) : null
|
|
22
|
-
] });
|
|
31
|
+
);
|
|
23
32
|
}
|
|
33
|
+
Figure.Caption = FigureCaption;
|
|
24
34
|
export {
|
|
25
35
|
Figure
|
|
26
36
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/components/mdx/footnotes.tsx
|
|
2
2
|
import { cn } from "@publish.os/nextjs/utils/cn";
|
|
3
|
-
import { jsx } from "
|
|
3
|
+
import { jsx } from "@publish.os/nextjs/jsx-runtime";
|
|
4
4
|
function Footnotes({ className, ...props }) {
|
|
5
5
|
return /* @__PURE__ */ jsx(
|
|
6
6
|
"section",
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// src/components/mdx/heading-copy-link.tsx
|
|
4
4
|
import { LinkIcon } from "@phosphor-icons/react/ssr";
|
|
5
5
|
import { cn } from "@publish.os/nextjs/utils/cn";
|
|
6
|
-
import { jsx, jsxs } from "
|
|
6
|
+
import { jsx, jsxs } from "@publish.os/nextjs/jsx-runtime";
|
|
7
7
|
function headingCopyUrl({ href, id }) {
|
|
8
8
|
let url = new URL(href);
|
|
9
9
|
return url.hash = id, url.toString();
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// src/components/mdx/heading.tsx
|
|
2
|
-
import { HeadingCopyLink } from "@
|
|
2
|
+
import { HeadingCopyLink } from "@components/mdx/components/heading-copy-link";
|
|
3
3
|
import { cn } from "@publish.os/nextjs/utils/cn";
|
|
4
4
|
import { headingToHTMLId } from "@publish.os/nextjs/utils/heading-ids";
|
|
5
5
|
import {
|
|
6
6
|
Children,
|
|
7
7
|
isValidElement
|
|
8
8
|
} from "react";
|
|
9
|
-
import { jsx, jsxs } from "
|
|
9
|
+
import { jsx, jsxs } from "@publish.os/nextjs/jsx-runtime";
|
|
10
10
|
function isBrElement(node) {
|
|
11
11
|
return isValidElement(node) && node.type === "br";
|
|
12
12
|
}
|
|
@@ -33,7 +33,10 @@ function Heading({
|
|
|
33
33
|
id,
|
|
34
34
|
...props
|
|
35
35
|
}) {
|
|
36
|
-
let cleaned = cleanHeadingChildren(children), headingId = id ?? headingToHTMLId(cleaned), isEmpty = !headingId || headingId === "empty-heading", classes = cn(
|
|
36
|
+
let cleaned = cleanHeadingChildren(children), headingId = id ?? headingToHTMLId(cleaned), isEmpty = !headingId || headingId === "empty-heading", classes = cn(
|
|
37
|
+
"scroll-mt-[calc(var(--layout-global-nav-height)_+_1.5rem)] supports-[scroll-margin-top:anchor-size(--global-navbar_height)]:scroll-mt-[calc(anchor-size(--global-navbar_height,3.5rem)_+_1.5rem)]",
|
|
38
|
+
className
|
|
39
|
+
);
|
|
37
40
|
return isEmpty ? (
|
|
38
41
|
// @ts-expect-error — polymorphic `as` prop with spread is safe at runtime
|
|
39
42
|
/* @__PURE__ */ jsx(Tag, { className, ...props, children: cleaned })
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/components/mdx/hr.tsx
|
|
2
|
-
import { Separator } from "@
|
|
3
|
-
import { jsx } from "
|
|
2
|
+
import { Separator } from "@components/ui/separator";
|
|
3
|
+
import { jsx } from "@publish.os/nextjs/jsx-runtime";
|
|
4
4
|
function Hr({ className, ...props }) {
|
|
5
5
|
return /* @__PURE__ */ jsx(Separator, { className, ...props });
|
|
6
6
|
}
|
|
@@ -16,6 +16,6 @@ type ImageProps = Omit<React.ComponentPropsWithoutRef<"img">, "height" | "sizes"
|
|
|
16
16
|
width?: number;
|
|
17
17
|
zoom?: boolean;
|
|
18
18
|
};
|
|
19
|
-
declare function Image({ alt, aspect, caption, className, decorative, fill, frame, height, intrinsicHeight, intrinsicWidth, optimized, priority, quality, sizes, src, width, zoom, ...props }: ImageProps): react_jsx_runtime.JSX.Element | null;
|
|
19
|
+
declare function Image({ alt, aspect, caption, className, decorative: authoredDecorative, fill: authoredFill, frame, height, intrinsicHeight, intrinsicWidth, optimized: authoredOptimized, priority: authoredPriority, quality, sizes, src, width, zoom: authoredZoom, ...props }: ImageProps): react_jsx_runtime.JSX.Element | null;
|
|
20
20
|
|
|
21
21
|
export { Image, type ImageProps };
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
// src/components/mdx/image/image.tsx
|
|
2
|
-
import { FigureCaption } from "@
|
|
3
|
-
import { ImageZoom } from "@
|
|
2
|
+
import { FigureCaption } from "@components/mdx/components/figure-caption";
|
|
3
|
+
import { ImageZoom } from "@components/mdx/components/image-zoom";
|
|
4
4
|
import { cn } from "@publish.os/nextjs/utils/cn";
|
|
5
5
|
import NextImage from "next/image";
|
|
6
|
-
import { jsx, jsxs } from "
|
|
6
|
+
import { jsx, jsxs } from "@publish.os/nextjs/jsx-runtime";
|
|
7
|
+
function resolveImageBoolean(value) {
|
|
8
|
+
if (value === !0 || value === "true") return !0;
|
|
9
|
+
if (value === !1 || value === "false") return !1;
|
|
10
|
+
}
|
|
7
11
|
function parseAspect(value) {
|
|
8
12
|
if (typeof value == "number" && Number.isFinite(value) && value > 0)
|
|
9
13
|
return value;
|
|
@@ -41,7 +45,7 @@ function renderImage({
|
|
|
41
45
|
sizes,
|
|
42
46
|
width
|
|
43
47
|
}) {
|
|
44
|
-
if (optimized && (fill || width && height)) {
|
|
48
|
+
if (optimized && imageProps.src && (fill || width && height)) {
|
|
45
49
|
let maxWidth = fill ? "var(--publish-content-width, 72rem)" : `${width}px`;
|
|
46
50
|
return /* @__PURE__ */ jsx(
|
|
47
51
|
NextImage,
|
|
@@ -50,7 +54,8 @@ function renderImage({
|
|
|
50
54
|
priority,
|
|
51
55
|
quality,
|
|
52
56
|
sizes: sizes ?? `(max-width: 768px) 100vw, min(${maxWidth}, 100vw)`,
|
|
53
|
-
...imageProps
|
|
57
|
+
...imageProps,
|
|
58
|
+
src: imageProps.src
|
|
54
59
|
}
|
|
55
60
|
);
|
|
56
61
|
}
|
|
@@ -74,30 +79,30 @@ function Image({
|
|
|
74
79
|
aspect,
|
|
75
80
|
caption,
|
|
76
81
|
className,
|
|
77
|
-
decorative
|
|
78
|
-
fill
|
|
82
|
+
decorative: authoredDecorative,
|
|
83
|
+
fill: authoredFill,
|
|
79
84
|
frame = "default",
|
|
80
85
|
height,
|
|
81
86
|
intrinsicHeight,
|
|
82
87
|
intrinsicWidth,
|
|
83
|
-
optimized
|
|
84
|
-
priority,
|
|
88
|
+
optimized: authoredOptimized,
|
|
89
|
+
priority: authoredPriority,
|
|
85
90
|
quality,
|
|
86
91
|
sizes,
|
|
87
92
|
src,
|
|
88
93
|
width,
|
|
89
|
-
zoom
|
|
94
|
+
zoom: authoredZoom,
|
|
90
95
|
...props
|
|
91
96
|
}) {
|
|
92
|
-
if (!src) return null;
|
|
93
|
-
let layout = resolveImageLayout({
|
|
97
|
+
if (!src && !props.srcSet) return null;
|
|
98
|
+
let decorative = resolveImageBoolean(authoredDecorative) ?? !1, fill = resolveImageBoolean(authoredFill) ?? !1, optimized = resolveImageBoolean(authoredOptimized) ?? !1, priority = resolveImageBoolean(authoredPriority), zoom = resolveImageBoolean(authoredZoom) ?? !0, layout = resolveImageLayout({
|
|
94
99
|
aspect,
|
|
95
100
|
fill,
|
|
96
101
|
height,
|
|
97
102
|
intrinsicHeight,
|
|
98
103
|
intrinsicWidth,
|
|
99
104
|
width
|
|
100
|
-
}), imageAlt = decorative ? "" : alt ?? "", framed = frame
|
|
105
|
+
}), imageAlt = decorative ? "" : alt ?? "", framed = resolveImageBoolean(frame) ?? frame !== "none", stringSrc = src ? String(src) : void 0, useNextImage = !!(optimized && stringSrc?.startsWith("/")), imageClassName = cn(
|
|
101
106
|
"block h-full w-full transition-opacity duration-200",
|
|
102
107
|
fill ? "object-cover" : "object-contain",
|
|
103
108
|
zoom && "cursor-zoom-in hover:opacity-90",
|
|
@@ -128,10 +133,10 @@ function Image({
|
|
|
128
133
|
children: /* @__PURE__ */ jsx(ImageZoom, { enabled: zoom, children: image })
|
|
129
134
|
}
|
|
130
135
|
);
|
|
131
|
-
return caption ? /* @__PURE__ */ jsxs("figure", { className: "not-markdown-prose my-8", children: [
|
|
136
|
+
return caption ? /* @__PURE__ */ jsxs("figure", { className: "not-markdown-prose my-8 w-full", children: [
|
|
132
137
|
content,
|
|
133
|
-
/* @__PURE__ */ jsx(FigureCaption, {
|
|
134
|
-
] }) : /* @__PURE__ */ jsx("div", { className: "not-markdown-prose my-6 flex justify-center", children: content });
|
|
138
|
+
/* @__PURE__ */ jsx(FigureCaption, { children: caption })
|
|
139
|
+
] }) : /* @__PURE__ */ jsx("div", { className: "not-markdown-prose my-6 flex w-full justify-center", children: content });
|
|
135
140
|
}
|
|
136
141
|
export {
|
|
137
142
|
Image
|