Skip to content

πŸ“š The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.

Also show preview on CDN file edit page

Dedmen Miller3719d88d5cba
diff --git a/frontend/app/helpers/resources.ts b/frontend/app/helpers/resources.ts
index ac5b97db..d8fb9918 100644
--- a/frontend/app/helpers/resources.ts
+++ b/frontend/app/helpers/resources.ts
@@ -17,8 +17,7 @@ const readableFileSize = (bytes: number): string => {
const isImageFile = (filetype: string): boolean => filetype.startsWith('image/');
/** Check if a filetype MIME string represents a video */
-const isImageFile = (filetype: string): boolean => filetype.startsWith('video/');
-
+const isVideoFile = (filetype: string): boolean => filetype.startsWith('video/');
/** Check if a filetype MIME string represents a PDF */
const isPdfFile = (filetype: string): boolean => filetype.startsWith('application/pdf');
diff --git a/frontend/app/pages/dashboard/cdn/[id]/index.vue b/frontend/app/pages/dashboard/cdn/[id]/index.vue
index 0b7c1dc9..0a4cd2b7 100644
--- a/frontend/app/pages/dashboard/cdn/[id]/index.vue
+++ b/frontend/app/pages/dashboard/cdn/[id]/index.vue
@@ -35,7 +35,8 @@
</div>
<h4>Preview</h4>
<div class="preview">
- <img v-if="(resource.metadata?.filetype as string)?.startsWith('image/')" :src="resourceURL(resource)" alt="Preview" />
+ <img v-if="isImageFile(mimeType)" :src="resourceURL(resource)" alt="Preview" />
+ <video v-else-if="isVideoFile(mimeType)" :src="resourceURL(resource)" controls />
<p v-else>Preview not available for this file type.</p>
</div>
</form>
@@ -44,7 +45,7 @@
<script lang="ts" setup>
import DeleteResourceModal from '../_modals/DeleteResourceModal.vue';
-import { readableFileSize } from '~/helpers/resources';
+import { readableFileSize, isImageFile, isVideoFile } from '~/helpers/resources';
definePageMeta({ breadcrumb: 'Edit' });
@@ -53,6 +54,7 @@ const route = useRoute();
const { resourceURL } = useApi();
const resource = computed(() => nodeStore.getById(route.params.id as string));
+const mimeType = computed(() => resource.value?.metadata?.filetype || '');
const defaultItem: ANode = {
id: '',