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.

Add download button on preview page and fix download button for all files types

Smaug6739aa9464d47ec8
diff --git a/frontend/app/composables/useApi.ts b/frontend/app/composables/useApi.ts
index f979ab3f..6dc8f727 100644
--- a/frontend/app/composables/useApi.ts
+++ b/frontend/app/composables/useApi.ts
@@ -10,9 +10,11 @@ export function useApi() {
return user?.avatar ? CDN + cdnEndpoint + user.id + `/avatar?v=${user.avatar}` : '/default_avatar.avif';
}
- function resourceURL(resource?: Node): string {
+ function resourceURL(resource?: Node, download = false): string {
if (!resource) return '';
- return `${CDN}${cdnEndpoint}${resource.user_id}/${resource.metadata?.transformed_path || resource.content}`;
+ return `${CDN}${cdnEndpoint}${resource.user_id}/${resource.metadata?.transformed_path || resource.content}${
+ download ? '?response-content-disposition=attachment' : ''
+ }`;
}
return { CDN, API, avatarURL, resourceURL };
diff --git a/frontend/app/pages/dashboard/cdn/[id]/preview.vue b/frontend/app/pages/dashboard/cdn/[id]/preview.vue
index 4927bcff..9c63b658 100644
--- a/frontend/app/pages/dashboard/cdn/[id]/preview.vue
+++ b/frontend/app/pages/dashboard/cdn/[id]/preview.vue
@@ -7,6 +7,9 @@
<AppSelect v-if="isPdfFile(mimeType)" v-model="zoom" :items="PDF_SCALES" :searchable="false" label="Scale" style="width: 200px" />
<NuxtLink :to="`/dashboard/cdn/${resource.id}`"><AppButton type="primary">Edit</AppButton></NuxtLink>
<AppButton type="secondary" class="no-mobile" @click="copyLink">Copy link</AppButton>
+ <NuxtLink :href="resourceURL(resource, true)" download rel="noopener" class="btn-icon">
+ <Icon name="download" display="lg" />
+ </NuxtLink>
</div>
</header>
<div class="preview">
@@ -15,7 +18,7 @@
<div v-else class="no-preview">
<p>Preview not available for this file type.</p>
<p>
- <NuxtLink :href="resourceURL(resource)" download rel="noopener">
+ <NuxtLink :href="resourceURL(resource, true)" download rel="noopener">
<AppButton type="primary">Download file</AppButton>
</NuxtLink>
</p>