feat: add packer

This commit is contained in:
2026-10-03 23:11:51 +02:00
parent e82561862a
commit 5452f72087
14 changed files with 976 additions and 25 deletions
+3 -24
View File
@@ -14,14 +14,8 @@ const EDUCATION: (CvType | null)[] = ['Student', 'Pupil']
const { data: entries, error, status } = useFetch<CvEntry[]>('/api/cv', { key: 'cv-entries', default: () => [] })
// Opens the browser's print dialog, which offers "Save as PDF"
function savePdf() {
window.print()
}
// Browsers name the PDF after the page title, so it is "joaquin_gottlebe_cv" while printing (also with ⌘ P)
// The PDF is named "joaquin_gottlebe_cv"
const pdfName = `${(profile.name || 'cv').toLowerCase().trim().replace(/\s+/g, '_')}${profile.name ? '_cv' : ''}`
let screenTitle = ''
// The date under the CV is the day it is printed
const printDate = ref(new Date())
const signedOn = computed(() => {
@@ -30,21 +24,8 @@ const signedOn = computed(() => {
: printDate.value.toLocaleDateString('en-GB', { day: 'numeric', month: 'long', year: 'numeric' })
return [profile.city, date].filter(Boolean).join(', ')
})
function onBeforePrint() {
const { savePdf } = usePdfExport(pdfName, () => {
printDate.value = new Date()
screenTitle = document.title
document.title = pdfName
}
function onAfterPrint() {
if (screenTitle) document.title = screenTitle
}
onMounted(() => {
window.addEventListener('beforeprint', onBeforePrint)
window.addEventListener('afterprint', onAfterPrint)
})
onBeforeUnmount(() => {
window.removeEventListener('beforeprint', onBeforePrint)
window.removeEventListener('afterprint', onAfterPrint)
})
const education = computed(() => entries.value.filter(entry => EDUCATION.includes(entry.type)))
@@ -122,9 +103,7 @@ const experience = computed(() => entries.value.filter(entry => !EDUCATION.inclu
{{ signedOn }}
</p>
<div v-if="entries.length" class="mt-16 flex justify-center print:hidden">
<UButton :label="t.savePdf" icon="i-lucide-download" color="primary" variant="outline" @click="savePdf" />
</div>
<SavePdfButton v-if="entries.length" :label="t.savePdf" @click="savePdf" />
</UContainer>
</UMain>
</template>