;
bskyPostData: AppBskyFeedDefs.PostView[];
@@ -123,14 +130,16 @@ let Block = ({
switch (true) {
case PubLeafletBlocksPage.isMain(b.block): {
let id = b.block.id;
+ let page = pages.find((p) => p.id === id);
+ if (!page) return;
return (
-
{
- openPage(pageId, id);
- }}
- >
- ITS A BLOCK
-
+
);
}
case PubLeafletBlocksBskyPost.isMain(b.block): {
@@ -159,6 +168,7 @@ let Block = ({
{b.block.children.map((child, i) => (
{props.item.children.map((child, index) => (
({
pages: [] as string[],
}));
@@ -73,6 +74,7 @@ export function PostPages({
let hasPageBackground = !!pubRecord.theme?.showPageBackground;
let fullPageScroll = !hasPageBackground && !drawerOpen && pages.length === 0;
+ let record = document.data as PubLeafletDocument.Record;
return (
<>
{!fullPageScroll && }
@@ -88,6 +90,7 @@ export function PostPages({
preferences={preferences}
/>
{
- let record = document.data as PubLeafletDocument.Record;
let page = record.pages.find(
(page) => (page as PubLeafletPagesLinearDocument.Main).id === p,
) as PubLeafletPagesLinearDocument.Main | undefined;
if (!page) return null;
return (
- <>
+
- >
+
);
})}
{!fullPageScroll && }
diff --git a/app/lish/[did]/[publication]/[rkey]/PublishedPageBlock.tsx b/app/lish/[did]/[publication]/[rkey]/PublishedPageBlock.tsx
new file mode 100644
index 00000000..3a66db80
--- /dev/null
+++ b/app/lish/[did]/[publication]/[rkey]/PublishedPageBlock.tsx
@@ -0,0 +1,159 @@
+"use client";
+
+import { useEntity, useReplicache } from "src/replicache";
+import { useUIState } from "src/useUIState";
+import { CSSProperties, useContext, useRef } from "react";
+import { useCardBorderHidden } from "components/Pages/useCardBorderHidden";
+import { PostContent } from "./PostContent";
+import {
+ PubLeafletBlocksHeader,
+ PubLeafletBlocksText,
+ PubLeafletPagesLinearDocument,
+ PubLeafletPublication,
+} from "lexicons/api";
+import { AppBskyFeedDefs } from "@atproto/api";
+import { TextBlock } from "./TextBlock";
+import { PostPageContext } from "./PostPageContext";
+import { openPage, usePostPageUIState } from "./PostPages";
+
+export function PublishedPageLinkBlock(props: {
+ blocks: PubLeafletPagesLinearDocument.Block[];
+ parentPageId: string | undefined;
+ pageId: string;
+ did: string;
+ preview?: boolean;
+ className?: string;
+ prerenderedCodeBlocks?: Map;
+ bskyPostData: AppBskyFeedDefs.PostView[];
+}) {
+ //switch to use actually state
+ let isOpen = usePostPageUIState((s) => s.pages.includes(props.pageId));
+ return (
+ {
+ if (e.isDefaultPrevented()) return;
+ if (e.shiftKey) return;
+ e.preventDefault();
+ e.stopPropagation();
+
+ console.log("yoo@");
+
+ openPage(props.parentPageId, props.pageId);
+ //open the damn thing somehow
+ }}
+ >
+
+
+ );
+}
+export function DocLinkBlock(props: {
+ blocks: PubLeafletPagesLinearDocument.Block[];
+ pageId?: string;
+ did: string;
+ preview?: boolean;
+ className?: string;
+ prerenderedCodeBlocks?: Map;
+ bskyPostData: AppBskyFeedDefs.PostView[];
+}) {
+ let { rep } = useReplicache();
+ let [title, description] = props.blocks
+ .map((b) => b.block)
+ .filter(
+ (b) => PubLeafletBlocksText.isMain(b) || PubLeafletBlocksHeader.isMain(b),
+ );
+
+ return (
+
+ <>
+
+
+ {title && (
+
+
+
+ )}
+ {description && (
+
+
+
+ )}
+
+ {!props.preview && (
+
+ )}
+
+ >
+
+ );
+}
+
+export function PagePreview(props: {
+ did: string;
+ blocks: PubLeafletPagesLinearDocument.Block[];
+}) {
+ let previewRef = useRef(null);
+ let { rootEntity } = useReplicache();
+ let data = useContext(PostPageContext);
+ let theme = data?.documents_in_publications[0]?.publications
+ ?.record as PubLeafletPublication.Record;
+ let pageWidth = `var(--page-width-unitless)`;
+ let cardBorderHidden = !theme.theme?.showPageBackground;
+ return (
+
+
+ {!cardBorderHidden && (
+
+ )}
+
+
+
+ );
+}