diff --git a/src/blocks/Document/Component.tsx b/src/blocks/Document/Component.tsx index 219161e50..5f934e842 100644 --- a/src/blocks/Document/Component.tsx +++ b/src/blocks/Document/Component.tsx @@ -5,13 +5,16 @@ import { getMediaURL } from '@/utilities/getURL' import { isValidRelationship } from '@/utilities/relationships' import { getHostnameFromTenant } from '@/utilities/tenancy/getHostnameFromTenant' import { cn } from '@/utilities/ui' +import { FileDown } from 'lucide-react' type Props = DocumentBlockProps & { isLayoutBlock: boolean + // layout is present in the block config but absent from generated types until pnpm generate:types is run + layout?: 'download' | 'embed' | null } export const DocumentBlockComponent = (props: Props) => { - const { document, isLayoutBlock = true } = props + const { document, layout, isLayoutBlock = true } = props const { tenant } = useTenant() if (!isValidRelationship(document) || !document.url) { @@ -19,10 +22,29 @@ export const DocumentBlockComponent = (props: Props) => { } const src = getMediaURL(document.url, null, getHostnameFromTenant(tenant)) + const filename = document.filename ?? 'Download' + + // Treat missing layout as 'embed' so existing blocks keep their current behavior + const resolvedLayout = layout ?? 'embed' + + if (resolvedLayout === 'download') { + return ( +
+ + + {filename} + +
+ ) + } return (
-