-
{title}
- {previewable && (
+ {markdown && (
- {load.status === 'loading' &&
{t('loading')}
}
- {load.status === 'error' &&
{load.message}
}
- {load.status === 'binary' && (
-
- )}
{editable && (
<>
- {load.truncated && mode === 'edit' &&
{t('truncation')}
}
+ {truncated === true && mode === 'edit' &&
{t('truncation')}
}
>
)}
- {load.status === 'ready' && load.viewer !== undefined && createElement(load.viewer.component, {
- ctx, store, scope, path, title,
- content: load.content,
- truncated: load.truncated,
- mediaUrl: load.mediaUrl,
- customData: load.customData,
- })}
- {previewable && mode === 'preview' && (
+ {markdown && mode === 'preview' && (
-
+
)}
-
+ >
)
}
-
-/** The lowercased file extension of a path ('' when none). */
-function extOfPath(path: string): string {
- const at = path.lastIndexOf('.')
- if (at === -1) return ''
- const base = path.slice(at).toLowerCase()
- return base.includes('/') || base.includes('\\') ? '' : base
-}
diff --git a/src/client/api.ts b/src/client/api.ts
index 5583565..8fd943c 100644
--- a/src/client/api.ts
+++ b/src/client/api.ts
@@ -54,8 +54,9 @@ export interface GitLogEntry {
/** Text read result. */
export interface FsTextResult { kind: 'text'; content: string; truncated: boolean }
-/** Binary read result (no content; images load through the media route). */
-export interface FsBinaryResult { kind: 'binary'; size: number; truncated: boolean }
+/** Binary read result (no content; images load through the media route).
+ * `head` carries the first bytes (base64) for viewer detect sniffing. */
+export interface FsBinaryResult { kind: 'binary'; size: number; truncated: boolean; head: string }
async function call