diff --git a/.changeset/svg-file-attachment-previews.md b/.changeset/svg-file-attachment-previews.md new file mode 100644 index 000000000..b3e3c166b --- /dev/null +++ b/.changeset/svg-file-attachment-previews.md @@ -0,0 +1,5 @@ +--- +"gitbook": patch +--- + +Show image thumbnails, including SVG previews, for file attachments on published sites. diff --git a/packages/gitbook/src/components/DocumentView/File.tsx b/packages/gitbook/src/components/DocumentView/File.tsx index 1f4ac18dd..f3187c558 100644 --- a/packages/gitbook/src/components/DocumentView/File.tsx +++ b/packages/gitbook/src/components/DocumentView/File.tsx @@ -1,12 +1,12 @@ -import { type DocumentBlockFile, SiteInsightsLinkPosition } from '@gitbook/api'; - import { t } from '@/intl/translate'; import { getSimplifiedContentType } from '@/lib/files'; import { resolveContentRefInDocument } from '@/lib/references'; +import { type DocumentBlockFile, SiteInsightsLinkPosition } from '@gitbook/api'; import { getSpaceLanguage } from '@/intl/server'; import { Button, Link } from '../primitives'; import { DownloadButton } from '../primitives/DownloadButton'; +import { Image } from '../utils'; import type { BlockProps } from './Block'; import { Caption } from './Caption'; import { FileIcon } from './FileIcon'; @@ -42,9 +42,24 @@ export async function File(props: BlockProps) { return (
-
- -
{getHumanFileSize(file.size)}
+
+ {contentType === 'image' ? ( + {file.name} + ) : ( + + )}
@@ -57,7 +72,11 @@ export async function File(props: BlockProps) { {file.name}
-
{contentType}
+
+ {contentType + ? `${contentType} ยท ${getHumanFileSize(file.size)}` + : getHumanFileSize(file.size)} +