Skip to content

Commit

Permalink
Merge pull request #65 from devtobi/64-modify-filename-of-pdf-when-us…
Browse files Browse the repository at this point in the history
…ing-download-functionality

feat: added custom file name for download feature
  • Loading branch information
devtobi authored Jun 14, 2024
2 parents 161835c + cbba05f commit a79dcaa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"private": true,
"scripts": {
"build": "bun --filter '*' build && bun post-build",
"post-build": "mkdir dist && concurrently --kill-others-on-fail -n copy-content,copy-wrapper 'ncp packages/cv-content/dist dist/' 'ncp packages/cv-wrapper/dist dist/'",
"post-build": "mkdir -p dist && concurrently --kill-others-on-fail -n copy-content,copy-wrapper 'ncp packages/cv-content/dist dist/' 'ncp packages/cv-wrapper/dist dist/'",
"setup": "bun --filter cv-content setup",
"format": "bun --filter cv-content format",
"validate": "bun --filter cv-content validate",
Expand Down
8 changes: 6 additions & 2 deletions packages/cv-wrapper/src/components/CvPdfDownloadButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import { useI18n } from 'vue-i18n';
import { useSelectedLanguage } from '@/composables/useSelectedLanguage';
import { pdfFilename } from '@/config/constants';
import { authorName, pdfFilename } from '@/config/constants';
const { t } = useI18n();
const { selectedLanguage } = useSelectedLanguage();
Expand All @@ -22,11 +22,15 @@
() => `./${selectedLanguage.value}/${pdfFilename}`,
);
const downloadFileName = computed(
() => `cv-${authorName.replace(/\s/g, '')}-${selectedLanguage.value}.pdf`,
);
const downloadPdf = () => {
const link = document.createElement('a');
link.href = downloadUrl.value;
link.target = '_blank';
link.download = pdfFilename;
link.download = downloadFileName.value;
document.body.appendChild(link);
link.click();
Expand Down

0 comments on commit a79dcaa

Please sign in to comment.