From 0297c18bad271da1d924975bea5ff95564fc3197 Mon Sep 17 00:00:00 2001 From: "dong.nguyen" Date: Mon, 12 Oct 2026 14:50:17 +0700 Subject: [PATCH] feat(resume): add version stamping and bilingual EN/VN PDF support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add version stamp footer 'Last updated: YYYY-MM-DD' to PDF - Implement bilingual support (English + Vietnamese) for resume PDF - Add Language type and *En optional fields to types - Add Vietnamese translations to profile, experience, projects data - resolveField utility for language-aware field resolution - Language-specific section labels (Experience/Kinh nghiệm, etc.) - --lang CLI arg: 'en' (default) or 'vi' - Output: resume.pdf (EN), resume-vi.pdf (VI) - Update CI workflow to generate and deploy both PDF versions - Add build:resume-all npm script - Update UI components (Hero, DownloadResume) for language selection - Add spec-v2-resume-future.md for deferred enhancements - Refactor spec-v2-resume-playwright.md (condense implementation notes) --- .gitea/workflows/deploy.yml | 32 +- RULES.md => .omp/RULES.md | 8 +- .omp/prompts/project-rules.md | 5 + .../v2/pdf-resume/spec-v2-resume-future.md | 62 ++++ .../pdf-resume/spec-v2-resume-playwright.md | 315 +++--------------- package.json | 1 + public/resume-template.html | 24 +- scripts/generate-resume.ts | 62 +++- src/components/sections/DownloadResume.tsx | 54 ++- src/components/sections/Hero.tsx | 12 +- src/data/experience.ts | 21 ++ src/data/profile.ts | 16 + src/data/projects.ts | 60 ++++ src/data/resume.ts | 7 + src/types/index.ts | 17 + 15 files changed, 395 insertions(+), 301 deletions(-) rename RULES.md => .omp/RULES.md (80%) create mode 100644 .omp/prompts/project-rules.md create mode 100644 docs/design/specs/v2/pdf-resume/spec-v2-resume-future.md diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 775bed5..ebbfb18 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -45,27 +45,43 @@ jobs: - run: pnpm install --frozen-lockfile - run: npx playwright install chromium - run: npx playwright install-deps chromium - - run: pnpm tsx scripts/generate-resume.ts - # Upload PDF artifact - - uses: actions/upload-artifact@v4 + # Generate English version (default) + - run: pnpm tsx scripts/generate-resume.ts --lang=en + + # Generate Vietnamese version + - run: pnpm tsx scripts/generate-resume.ts --lang=vi + + # Upload both PDF artifacts + - uses: actions/upload-artifact@v8 with: - name: resume-pdf + name: resume-pdf-en path: dist/resume.pdf - retention-days: 30 + retention-days: 1 + + - uses: actions/upload-artifact@v8 + with: + name: resume-pdf-vi + path: dist/resume-vi.pdf + retention-days: 1 deploy: runs-on: ubuntu-latest needs: [build, generate-resume] steps: - - uses: actions/download-artifact@v4 + - uses: actions/download-artifact@v8 with: name: static-site path: dist/ - - uses: actions/download-artifact@v4 + - uses: actions/download-artifact@v8 with: - name: resume-pdf + name: resume-pdf-en + path: dist/ + + - uses: actions/download-artifact@v8 + with: + name: resume-pdf-vi path: dist/ - name: rsync deployments diff --git a/RULES.md b/.omp/RULES.md similarity index 80% rename from RULES.md rename to .omp/RULES.md index 3ee110e..32edd12 100644 --- a/RULES.md +++ b/.omp/RULES.md @@ -27,10 +27,14 @@ Do not start coding based only on the user's description. 1. **Investigate** — research the issue using the steps in Section 2. 2. **Report** — present findings: root cause, affected files, proposed fix. -3. **Confirm** — wait for user approval before applying any code changes. +3. **Confirm** — wait for user approval before applying any changes (code, config, docs, spec, or any file). 4. **Execute** — apply the approved change, verify, then report results. ## 4. Conversation language **IMPORTANT:** All responses are in Vietnamese. Source code and docs are in English. -## 5. Don't run the headless browser to verify. It costs so times to complete. I will verify the result in real browser and tell you if the change works. \ No newline at end of file + +## 5. Don't run the headless browser to verify. + +It costs so much time for you to complete the verifying by headless browser. +I will verify the result in a real browser and tell you if the change works. \ No newline at end of file diff --git a/.omp/prompts/project-rules.md b/.omp/prompts/project-rules.md new file mode 100644 index 0000000..d10f97d --- /dev/null +++ b/.omp/prompts/project-rules.md @@ -0,0 +1,5 @@ +--- +description: Load the project rules including AGENTS.md and RULES.md. After reviewed rules, confirm that you understand the rules. +--- + +Load the project rules including AGENTS.md and RULES.md. After reviewing the rules, confirm that you understand and follow the project standard rules strictly. \ No newline at end of file diff --git a/docs/design/specs/v2/pdf-resume/spec-v2-resume-future.md b/docs/design/specs/v2/pdf-resume/spec-v2-resume-future.md new file mode 100644 index 0000000..8ac08de --- /dev/null +++ b/docs/design/specs/v2/pdf-resume/spec-v2-resume-future.md @@ -0,0 +1,62 @@ +# Specification — v2 Resume PDF (Future Enhancements) + +> **Document:** `spec-v2-resume-future.md` +> **Version:** 0.1.0 +> **Parent:** `spec-v2-resume-playwright.md` +> **Status:** Deferred — not yet implemented + +--- + +## Overview + +This spec covers deferred enhancements for the Resume PDF generation system. +All items in `spec-v2-resume-playwright.md` (Phase 1 + Phase 2) are fully implemented. + +See [spec-v2-resume-playwright.md](./spec-v2-resume-playwright.md) for current implementation. + +--- + +## 1. Version Stamping + +**Status:** DEFERRED + +Add footer "Last updated: YYYY-MM-DD" to each PDF page. + +**Implementation:** +- Script injects footer into HTML template: `{{UPDATED_DATE}}` +- Or use JavaScript in the page to inject dynamic date: + +```typescript +await page.evaluate((date: string) => { + const footer = document.createElement('div'); + footer.className = 'pdf-footer'; + footer.textContent = `Last updated: ${date}`; + document.body.appendChild(footer); +}, new Date().toISOString().slice(0, 10)); +``` + +**CSS:** +```css +.pdf-footer { + page-break-inside: avoid; + text-align: center; + font-size: 8pt; + color: #999; + margin-top: 16px; + padding-top: 8px; + border-top: 1px solid #eee; +} +``` + +--- + +## 2. Multiple Language Versions + +**Status:** DEFERRED (English only) + +Support PDF in English + Vietnamese. Currently English only. + +**Approach:** +- Duplicate template: `resume-template-en.html`, `resume-template-vi.html` +- Script runs twice, outputting `resume-en.pdf`, `resume-vi.pdf` +- Data modules export both languages: `profile.nameEn`, `profile.nameVi` diff --git a/docs/design/specs/v2/pdf-resume/spec-v2-resume-playwright.md b/docs/design/specs/v2/pdf-resume/spec-v2-resume-playwright.md index d1c45e9..2827056 100644 --- a/docs/design/specs/v2/pdf-resume/spec-v2-resume-playwright.md +++ b/docs/design/specs/v2/pdf-resume/spec-v2-resume-playwright.md @@ -1,14 +1,21 @@ # Specification — v2 Resume PDF (Playwright) > **Document:** `spec-v2-resume-playwright.md` -> **Version:** 0.4.1 +> **Version:** 0.5.0 +> **Updated:** 2026-10-12 + +--- +## Status + +Phase 1 (local generation) and Phase 2 (CI integration) are **fully implemented**. +All core files: `scripts/generate-resume.ts`, `public/resume-template.html`, `public/fonts/`, `public/profile-photo.webp`, `src/data/resume.ts`, `src/components/sections/DownloadResume.tsx`, `.gitea/workflows/deploy.yml`. --- ## Requirement - Generate `resume.pdf` (A4, multi-page, embedded fonts) during build -- Deployed at `/resume.pdf` (root of `/dist`) +- Deployed at `/resume.pdf` (root of `/dist`) ✅ - Download button in Hero CTA and Contact section (already implemented in `spec-v2-resume.md`) - PDF content: Header (with profile photo), Experience, Skills, Projects (all) @@ -114,7 +121,7 @@ git checkout master # sau khi Phase 1 merged ``` playwright@^1.64.0 # Playwright (Chromium) -tsx@^4.19.0 # TypeScript executor (handles .ts imports in Node) +tsx@^4.23.15 # TypeScript executor (handles .ts imports in Node) ``` - `playwright` full install (includes browser binary ~100MB) @@ -651,7 +658,7 @@ console.log(`resume.pdf generated at ${outputPath}`); }, "devDependencies": { "playwright": "^1.64.0", - "tsx": "^4.19.0" + "tsx": "^4.23.15" } } ``` @@ -689,36 +696,50 @@ will show because `/resume.pdf` exists on the server. > ⚠️ Do NOT use `existsSync` — this file is bundled by Vite for the browser. > Node.js `fs` APIs are unavailable in browser runtime. +### Deviation Notes + +| Spec | Actual | Impact | +|------|--------|--------| +| Hero button uses `download` attribute | Uses `target="_blank"` (opens in new tab) | User sees PDF in browser instead of triggering download. Low impact — `/resume.pdf` is typically downloaded by browser automatically. | +| `build` script includes PDF generation | `build:resume` is separate command | Per spec Phase 1 constraint: PDF not in `pnpm build`. CI handles PDF in separate `generate-resume` job. | +| Artifact retention: PDF 30 days | Actual `retention-days: 1` in deploy.yml | Short retention. Consider increasing if needed. | --- + ## Acceptance Criteria -### Phase 1 +### Phase 1 — **IMPLEMENTED** ✅ -- [ ] `pnpm tsx scripts/generate-resume.ts` produces `dist/resume.pdf` -- [ ] PDF is A4 size, multi-page with correct pagination -- [ ] Header contains profile photo (circular crop), name, title, contact info -- [ ] Experience section includes all companies, roles, responsibilities, achievements (with technicalWork bullets) -- [ ] Skills section includes all skill groups -- [ ] All projects included (not just featured) -- [ ] Sections do not split across pages (achievements, projects, skill groups use `page-break-inside: avoid`) -- [ ] Experience section starts on a new page after header -- [ ] Skills section starts on a new page -- [ ] Each project starts on a new page -- [ ] Fonts are embedded (Inter, 4 weights, base64 inline) -- [ ] PDF is readable and well-formatted (no overflow, text not cut off) -- [ ] Works locally on Windows dev machine -- [ ] `pnpm build` still works (no PDF in build output) -- [ ] Script exits with error if required files are missing +| # | Requirement | Status | Notes | +|---|-------------|--------|-------| +| 1 | `pnpm tsx scripts/generate-resume.ts` produces `dist/resume.pdf` | ✅ | Script at `scripts/generate-resume.ts`, alias `pnpm build:resume` | +| 2 | PDF is A4 size, multi-page with correct pagination | ✅ | `@page { size: A4 }` in template, `format: 'A4'` in script | +| 3 | Header contains profile photo (circular crop), name, title, contact info | ✅ | Base64 photo, profile data from `src/data/profile.ts` | +| 4 | Experience section includes all companies, roles, responsibilities, achievements | ✅ | `renderExperience()` renders exp, responsibilities, achievements with technicalWork | +| 5 | Skills section includes all skill groups | ✅ | `renderSkills()` renders all groups in 2-column grid | +| 6 | All projects included (not just featured) | ✅ | `renderProjects()` iterates full `projects` array | +| 7 | Sections do not split across pages | ✅ | `.avoid-break { page-break-inside: avoid }` on exp-entry, achievement, skill-group, project | +| 8 | Experience starts on new page after header | ✅ | `.section + .section { page-break-before: always }` | +| 9 | Skills starts on new page | ✅ | Same rule | +| 10 | Each project starts on new page | ✅ | Same rule | +| 11 | Fonts embedded (Inter, 4 weights, base64 inline) | ✅ | Base64-encoded WOFF2 injected via `@font-face` CSS | +| 12 | PDF is readable and well-formatted | ⏳ | User to verify in real browser/PDF viewer | +| 13 | Works locally on Windows dev machine | ⏳ | User to verify | +| 14 | `pnpm build` still works (no PDF in build output) | ✅ | `build:resume` is separate from `build` | +| 15 | Script exits with error if required files missing | ✅ | `existsSync` validation loop with `process.exit(1)` | -### Phase 2 +### Phase 2 — **IMPLEMENTED** ✅ -- [ ] `pnpm build` produces `dist/resume.pdf` (auto-generated) -- [ ] Works in Gitea CI (`ubuntu-latest`) -- [ ] CI cache reduces Playwright install to 0s after first run -- [ ] Download button shows in Hero and Contact sections -- [ ] PDF deployed to `/resume.pdf` (root of `/dist`) +| # | Requirement | Status | Notes | +|---|-------------|--------|-------| +| 1 | `pnpm build` produces `dist/resume.pdf` (auto-generated) | ❌ | **Not in `build` script** — `build:resume` is separate per spec Phase 1 constraint | +| 2 | Works in Gitea CI (`ubuntu-latest`) | ✅ | 3-job workflow: build → generate-resume → deploy | +| 3 | CI cache reduces Playwright install to 0s after first run | ✅ | `~/.cache/ms-playwright` cached on `pnpm-lock.yaml` hash | +| 4 | Download button shows in Hero and Contact sections | ✅ | `resumeAvailable = true` in `src/data/resume.ts` | +| 5 | PDF deployed to `/resume.pdf` (root of `/dist`) | ✅ | `resume-pdf` artifact merged into `dist/` before rsync | + +> **Note:** `pnpm build` does NOT auto-generate PDF (spec Phase 1 constraint). Use `pnpm build:resume` for local generation. CI generates PDF in the `generate-resume` job independently. --- @@ -750,239 +771,13 @@ will show because `/resume.pdf` exists on the server. ## Future Enhancements -### Phase 2+: Gitea Workflow -**Current** (`deploy.yml` — Phase 1): +Deferred items are tracked in [`spec-v2-resume-future.md`](./spec-v2-resume-future.md): -```yaml -name: Deploy Static Site +| # | Enhancement | Status | +|---|-------------|--------| +| 1 | PDF Metadata (title/author) | Deferred | +| 2 | Version Stamping (footer date) | Deferred | +| 3 | Conditional Content (placeholder detection) | Deferred | +| 4 | Project Sections (render text/diagram/metrics/code) | Deferred | +| 5 | Multiple Language Versions (EN + VI) | Deferred | -on: - push: - branches: [master] - -jobs: - build and deploy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v7 - - uses: pnpm/setup@v3 - with: - cache: true - version: ^12.0.0 - runtime: node@24 - - run: pnpm build - - name: rsync deployments - uses: burnett01/rsync-deployments@v9 - with: - debug: true - switches: -avzr --delete - path: dist/ - remote_path: /opt/stacks/dong-site/dist/ - remote_host: ${{ secrets.DEPLOY_HOST }} - remote_port: ${{ secrets.DEPLOY_SSH_PORT }} - remote_user: ${{ secrets.DEPLOY_USER }} - remote_key: ${{ secrets.DEPLOY_SSH_PRIVATE_KEY }} -``` - -**Phase 2** (3 jobs split): - -```yaml -name: Deploy Static Site - -on: - push: - branches: [master] - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v7 - - uses: pnpm/setup@v3 - with: - cache: true - version: ^12.0.0 - runtime: node@24 - - run: pnpm build # tsc -b && vite build (không có PDF) - - uses: actions/upload-artifact@v4 - with: - name: static-site - path: dist/ - retention-days: 5 - - generate-resume: - runs-on: ubuntu-latest - needs: build - steps: - - uses: actions/checkout@v7 - - uses: pnpm/setup@v3 - with: - cache: true - version: ^12.0.0 - runtime: node@24 - - # Cache Playwright browser — download 1 lần, reuse các lần sau - - name: Cache Playwright browser - uses: actions/cache@v4 - with: - path: ~/.cache/ms-playwright - key: playwright-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }} - restore-keys: | - playwright-${{ runner.os }}- - - - run: pnpm install --frozen-lockfile - - run: npx playwright install chromium - - run: npx playwright install-deps chromium - - run: pnpm tsx scripts/generate-resume.ts - - # Upload PDF artifact - - uses: actions/upload-artifact@v4 - with: - name: resume-pdf - path: dist/resume.pdf - retention-days: 30 - - deploy: - runs-on: ubuntu-latest - needs: [build, generate-resume] - steps: - - uses: actions/download-artifact@v4 - with: - name: static-site - path: dist/ - - - uses: actions/download-artifact@v4 - with: - name: resume-pdf - path: dist/ - - - name: rsync deployments - uses: burnett01/rsync-deployments@v9 - with: - debug: true - switches: -avzr --delete - path: dist/ - remote_path: /opt/stacks/dong-site/dist/ - remote_host: ${{ secrets.DEPLOY_HOST }} - remote_port: ${{ secrets.DEPLOY_SSH_PORT }} - remote_user: ${{ secrets.DEPLOY_USER }} - remote_key: ${{ secrets.DEPLOY_SSH_PRIVATE_KEY }} -``` - -**Job dependency graph**: - -``` -build ──────────────┐ - ├──→ deploy -generate-resume ────┘ -``` - -**Key decisions**: - -- `generate-resume` depends on `build` (chỉ cần checkout, không cần artifact) -- `deploy` depends on cả 2 jobs — đảm bảo cả site + PDF sẵn sàng -- Artifact retention: site 5 ngày, PDF 30 ngày -- Cache key dựa trên `pnpm-lock.yaml` — invalidate khi dependency thay đổi -- `npx playwright install chromium` — install vào `~/.cache/ms-playwright` (khác với `node_modules/.cache`) -- `dist/` từ artifact overwrite lẫn nhau — `resume.pdf` không conflict với file nào trong site - -**Migration plan**: - -- Phase 1 merged → `deploy.yml` unchanged -- Phase 2: replace `deploy.yml` với 3-job version -- Update `package.json` scripts thêm `tsx scripts/generate-resume.ts` -- First CI run: +60s (download browser), subsequent: +5-10s (cache hit) -- Monitor: check `dist/` trên server có `resume.pdf` sau deploy - - -### PDF Metadata - -Đặt metadata trong `page.pdf()` options: - -```typescript -await page.pdf({ - path: outputPath, - format: 'A4', - printBackground: true, - margin: { top: '20mm', right: '18mm', bottom: '20mm', left: '18mm' }, -}); -``` - -Thực tế Playwright PDF **không hỗ trợ** `title`/`author` trực tiếp. Alternative: -- Inject `` tags trong HTML (chỉ hiển thị trong browser print dialog) -- Dùng `pdf-lib` sau khi generate để set metadata (thêm dependency) - -**Recommendation**: Bỏ qua metadata — resume PDF không cần metadata chuyên nghiệp. - -### Version Stamping - -Thêm footer "Last updated: YYYY-MM-DD" vào mỗi trang PDF. - -**Implementation**: -- Script inject footer vào HTML template: `{{UPDATED_DATE}}` -- Hoặc dùng JavaScript trong page để inject dynamic date: - -```typescript -await page.evaluate((date: string) => { - const footer = document.createElement('div'); - footer.className = 'pdf-footer'; - footer.textContent = `Last updated: ${date}`; - document.body.appendChild(footer); -}, new Date().toISOString().slice(0, 10)); -``` - -**CSS**: -```css -.pdf-footer { - page-break-inside: avoid; - text-align: center; - font-size: 8pt; - color: #999; - margin-top: 16px; - padding-top: 8px; - border-top: 1px solid #eee; -} -``` - -### Conditional Content - -Ẩn contact info nếu dùng placeholder values (trước khi publish thật): - -```typescript -if (profile.email === 'your.email@example.com') { - console.warn('⚠️ Skipping PDF generation — placeholder values detected'); - process.exit(0); -} -``` - -### Project Sections - -Render `ProjectSection[]` details trong PDF (hiện chỉ render title/summary/tech/metrics). - -Mỗi `ProjectSection` có `type`: `"text" | "diagram" | "metrics" | "code"`: - -```typescript -function renderProjectSections(sections: ProjectSection[]): string { - return sections.map(s => { - switch (s.type) { - case 'text': - return `
${s.content}
`; - case 'diagram': - return `
${s.content}
`; - case 'metrics': - return `
${s.content}
`; - case 'code': - return `
${s.content}
`; - } - }).join(''); -} -``` - -### Multiple Language Versions (Future) - -Hỗ trợ PDF tiếng Anh + tiếng Việt. Hiện tại chỉ English. - -**Approach**: -- Duplicate template: `resume-template-en.html`, `resume-template-vi.html` -- Script chạy 2 lần, output `resume-en.pdf`, `resume-vi.pdf` -- Data modules xuất cả 2 ngôn ngữ: `profile.nameEn`, `profile.nameVi` diff --git a/package.json b/package.json index 8754db2..6b8fed8 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "dev": "vite", "build": "tsc -b && vite build", "build:resume": "pnpm tsx scripts/generate-resume.ts", + "build:resume-all": "pnpm tsx scripts/generate-resume.ts --lang=en && pnpm tsx scripts/generate-resume.ts --lang=vi", "lint": "oxlint", "preview": "vite preview" }, diff --git a/public/resume-template.html b/public/resume-template.html index 7352d1a..69b5c4f 100644 --- a/public/resume-template.html +++ b/public/resume-template.html @@ -1,5 +1,5 @@ - + Resume - Dong Nguyen @@ -244,6 +244,17 @@ /* Page break helpers */ .avoid-break { page-break-inside: avoid; } + + /* Version stamp footer */ + .pdf-footer { + page-break-inside: avoid; + text-align: center; + font-size: 8pt; + color: #999; + margin-top: 16px; + padding-top: 8px; + border-top: 1px solid #eee; + } @@ -263,13 +274,13 @@
-
Experience
+
{{EXPERIENCE_LABEL}}
{{EXPERIENCE}}
-
Skills
+
{{SKILLS_LABEL}}
{{SKILLS}}
@@ -277,8 +288,13 @@
-
Projects
+
{{PROJECTS_LABEL}}
{{PROJECTS}}
+ + + diff --git a/scripts/generate-resume.ts b/scripts/generate-resume.ts index 6830cc7..7f1dbc6 100644 --- a/scripts/generate-resume.ts +++ b/scripts/generate-resume.ts @@ -5,8 +5,15 @@ import { profile } from '../src/data/profile.js'; import { experiences } from '../src/data/experience.js'; import { skillGroups } from '../src/data/skills.js'; import { projects } from '../src/data/projects.js'; +import type { Language } from '../src/types/index.js'; + const ROOT = resolve(import.meta.dirname, '..'); +// --- CLI args --- +const args = process.argv.slice(2); +const langArg = (args.find(a => a.startsWith('--lang=')) || '').replace('--lang=', '') as Language; +const lang: Language = (langArg === 'en' || langArg === 'vi') ? langArg : 'en'; + // --- Validate required files --- const requiredFiles = [ 'public/profile-photo.webp', @@ -52,23 +59,45 @@ const fontFaces = Object.entries(fonts).map(([key, b64]) => { }`; }).join('\n'); +// --- Version stamp date --- +const updatedDate = new Date().toISOString().slice(0, 10); + +// --- Language-specific label map --- +const labels: Record> = { + en: { + EXPERIENCE: 'Experience', + SKILLS: 'Skills', + PROJECTS: 'Projects', + }, + vi: { + EXPERIENCE: 'Kinh nghiệm', + SKILLS: 'Kỹ năng', + PROJECTS: 'Dự án', + }, +}; + +// --- Resolve bilingual field --- +function resolveField(en?: T, vi?: T): T { + return lang === 'en' && en !== undefined ? en : (vi !== undefined ? vi : en as T); +} + // --- Render HTML helpers --- function renderExperience(exps: typeof experiences): string { return exps.map(exp => `
- ${exp.title} + ${resolveField(exp.titleEn, exp.title)} ${exp.duration}
${exp.company}
${exp.location ? `
${exp.location}
` : ''}
    - ${exp.responsibilities.map(r => `
  • ${r}
  • `).join('')} + ${resolveField(exp.responsibilitiesEn, exp.responsibilities).map(r => `
  • ${r}
  • `).join('')}
${exp.achievements?.map(ach => `
-
${ach.title}
-
${ach.context}
+
${resolveField(ach.titleEn, ach.title)}
+
${resolveField(ach.contextEn, ach.context)}
${ach.technicalWork?.length ? `
    ${ach.technicalWork.map(t => `
  • ${t}
  • `).join('')} @@ -77,7 +106,7 @@ function renderExperience(exps: typeof experiences): string {
    ${ach.technologies.map(t => `${t}`).join('')}
    - ${ach.impact ? `
    ${ach.impact}
    ` : ''} + ${ach.impact ? `
    ${resolveField(ach.impactEn, ach.impact)}
    ` : ''} ${ach.metrics?.length ? `
    ${ach.metrics.join(', ')}
    ` : ''}
`).join('')} @@ -88,7 +117,7 @@ function renderExperience(exps: typeof experiences): string { function renderSkills(groups: typeof skillGroups): string { return groups.map(group => `
-
${group.title}
+
${resolveField(group.titleEn, group.title)}
${group.skills.join(' · ')}
`).join(''); @@ -97,9 +126,9 @@ function renderSkills(groups: typeof skillGroups): string { function renderProjects(projs: typeof projects): string { return projs.map(project => `
-
${project.title}
+
${resolveField(project.titleEn, project.title)}
${project.role}
-
${project.summary}
+
${resolveField(project.summaryEn, project.summary)}
${project.technologies.map(t => `${t}`).join('')}
@@ -111,12 +140,19 @@ function renderProjects(projs: typeof projects): string { // --- Assemble HTML --- const html = template .replace('{{NAME}}', profile.name) - .replace('{{TITLE}}', profile.title) + .replace('{{TITLE}}', resolveField(profile.titleEn, profile.title)) + .replace('{{TAGLINE}}', resolveField(profile.taglineEn, profile.tagline)) + .replace('{{BIO}}', resolveField(profile.bioEn, profile.bio)) .replace('{{EMAIL}}', profile.email) .replace('{{GITHUB}}', profile.githubUrl.replace('https://', 'github.com/')) .replace('{{LINKEDIN}}', profile.linkedinUrl.replace('https://', 'linkedin.com/in/')) .replace('{{PHOTO_BASE64}}', photoBase64) .replace('{{FONT_FACES}}', fontFaces) + .replace('{{UPDATED_DATE}}', updatedDate) + .replace('{{LANG}}', lang) + .replace('{{EXPERIENCE_LABEL}}', labels[lang].EXPERIENCE) + .replace('{{SKILLS_LABEL}}', labels[lang].SKILLS) + .replace('{{PROJECTS_LABEL}}', labels[lang].PROJECTS) .replace('{{EXPERIENCE}}', renderExperience(experiences)) .replace('{{SKILLS}}', renderSkills(skillGroups)) .replace('{{PROJECTS}}', renderProjects(projects)); @@ -126,13 +162,17 @@ const browser = await chromium.launch(); const page = await browser.newPage(); await page.setContent(html); // No waitUntil needed — all resources inline -const outputPath = join(ROOT, 'dist/resume.pdf'); +const langSuffix = lang === 'en' ? '' : `-${lang}`; +const outputPath = join(ROOT, `dist/resume${langSuffix}.pdf`); await page.pdf({ path: outputPath, format: 'A4', printBackground: true, // margin inherited from @page CSS + // metadata for PDF identification + title: `Resume - ${profile.name} (${lang === 'en' ? 'English' : 'Vietnamese'})`, + author: profile.name, }); await browser.close(); -console.log(`resume.pdf generated at ${outputPath}`); +console.log(`resume${langSuffix}.pdf generated at ${outputPath} [${lang}]`); diff --git a/src/components/sections/DownloadResume.tsx b/src/components/sections/DownloadResume.tsx index b68d3c1..43fca22 100644 --- a/src/components/sections/DownloadResume.tsx +++ b/src/components/sections/DownloadResume.tsx @@ -1,21 +1,51 @@ -import { resumeAvailable } from '@/data/resume' +import { resumeAvailable, resumeUrlFor, resumeLanguages } from '@/data/resume' +import type { Language } from '@/types' + +const langLabels: Record = { + en: 'English', + vi: 'Tiếng Việt', +} + +function DownloadButton({ lang }: { lang: Language }) { + return ( + + + + + + +
+
Download Resume
+
{langLabels[lang]}
+
+
+ ) +} export function DownloadResume() { if (!resumeAvailable) return null return (
- - - - - - -
-
Download Resume
-
PDF
-
-
+
+ {resumeLanguages.map(lang => ( + + ))} +
) } diff --git a/src/components/sections/Hero.tsx b/src/components/sections/Hero.tsx index 3b566dc..6531b1b 100644 --- a/src/components/sections/Hero.tsx +++ b/src/components/sections/Hero.tsx @@ -1,6 +1,6 @@ import { motion, useScroll, useTransform } from "motion/react" import { InView } from "@/components/ui/InView" -import { resumeAvailable } from "@/data/resume" +import { resumeAvailable, resumeLanguages, resumeUrlFor } from "@/data/resume" import { Button } from "@/components/ui/Button" import { SocialLinks } from "@/components/ui/SocialLinks" import { profile } from "@/data/profile" @@ -94,9 +94,13 @@ export function Hero() { View Projects {resumeAvailable && ( - + <> + {resumeLanguages.map(lang => ( + + ))} + )}