diff --git a/frontend/apps/site/publication-page.tsx b/frontend/apps/site/publication-page.tsx
index 283ba9be54..a125102d51 100644
--- a/frontend/apps/site/publication-page.tsx
+++ b/frontend/apps/site/publication-page.tsx
@@ -140,6 +140,10 @@ export default function PublicationPage({
e.stopPropagation()
router.push(href)
}}
+ saveCidAsFile={async () => {
+ alert('Not implemented yet.')
+ }}
+ ipfsBlobPrefix="/"
>
diff --git a/frontend/packages/app/pages/group.tsx b/frontend/packages/app/pages/group.tsx
index 76ac37b2e4..d71c4cb031 100644
--- a/frontend/packages/app/pages/group.tsx
+++ b/frontend/packages/app/pages/group.tsx
@@ -72,6 +72,7 @@ import {useOpenDraft} from '../utils/open-draft'
import {pathNameify} from '../utils/path'
import {hostnameStripProtocol} from '../utils/site-hostname'
import {useNavigate} from '../utils/useNavigate'
+import {AppStaticPublicationProvider} from './publication'
export function RenamePubDialog({
input: {groupId, pathName, docTitle},
@@ -271,20 +272,9 @@ function PublicationDisplay({urlWithVersion}: {urlWithVersion: string}) {
paddingHorizontal="$5"
alignSelf="center"
>
- {
- e.preventDefault()
- e.stopPropagation()
- openUrl(href)
- }}
- >
+
-
+
) : null
}
diff --git a/frontend/packages/app/pages/publication.tsx b/frontend/packages/app/pages/publication.tsx
index a494a976c0..cfb72c97de 100644
--- a/frontend/packages/app/pages/publication.tsx
+++ b/frontend/packages/app/pages/publication.tsx
@@ -30,6 +30,32 @@ import {VersionChangesInfo} from '../components/version-changes-info'
import {usePublicationInContext} from '../models/publication'
import {useOpenUrl} from '../open-url'
import {DocumentPlaceholder} from './document-placeholder'
+import {useAppContext} from '../app-context'
+
+export function AppStaticPublicationProvider({
+ children,
+}: React.PropsWithChildren<{}>) {
+ const {saveCidAsFile} = useAppContext()
+ const openUrl = useOpenUrl()
+ return (
+ {
+ e.preventDefault()
+ e.stopPropagation()
+ openUrl(href)
+ }}
+ ipfsBlobPrefix={`${BACKEND_FILE_URL}/`}
+ saveCidAsFile={saveCidAsFile}
+ >
+ {children}
+
+ )
+}
export default function PublicationPage() {
const route = useNavRoute()
@@ -85,21 +111,9 @@ export default function PublicationPage() {
paddingHorizontal="10vw"
alignSelf="center"
>
- {
- e.preventDefault()
- e.stopPropagation()
- openUrl(href)
- }}
- ipfsBlobPrefix={`${BACKEND_FILE_URL}/`}
- >
+
-
+
{route.versionId && (
diff --git a/frontend/packages/shared/src/static/static-renderer.tsx b/frontend/packages/shared/src/static/static-renderer.tsx
index 919fe70f75..c2518b637a 100644
--- a/frontend/packages/shared/src/static/static-renderer.tsx
+++ b/frontend/packages/shared/src/static/static-renderer.tsx
@@ -16,6 +16,7 @@ import {
unpackHmId,
} from '@mintter/shared'
import {
+ Button,
ColorProp,
File,
FontSizeTokens,
@@ -50,6 +51,7 @@ export type StaticPublicationContextValue = {
entityComponents: EntityComponentsRecord
onLinkClick: (dest: string, e: any) => void
ipfsBlobPrefix: string
+ saveCidAsFile: (cid: string, name: string) => Promise
}
export const staticPublicationContext =
@@ -309,6 +311,10 @@ function StaticBlock(props: StaticBlockProps) {
return
}
+ if (props.block.type == 'file') {
+ return
+ }
+
if (props.block.type == 'embed') {
return (
Something is wrong with the video file.
@@ -704,53 +710,59 @@ export function getBlockNodeById(
}
export function StaticFileBlock({block}: {block: HMBlockFile}) {
- let cid = useMemo(() => getCIDFromIPFSUrl(block.ref), [block.ref])
+ const {saveCidAsFile} = useStaticPublicationContext()
return (
-
- console.log('OPEN FILE', cid)}
+
+
-
+
+
-
-
+ {block.attributes.name}
+
+ {block.attributes.size && (
- {block.attributes.name}
+ {formatBytes(parseInt(block.attributes.size))}
- {block.attributes.size && (
-
- {formatBytes(parseInt(block.attributes.size))}
-
- )}
-
-
-
+ )}
+
+
+
+
+
)
}