because I got bored of customising my CV for every job
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat(cv-renderer): add Handlebars template engine package

+84
+15
packages/cv-renderer/package.json
··· 1 + { 2 + "name": "@cv/cv-renderer", 3 + "version": "0.0.0", 4 + "private": true, 5 + "main": "./src/index.ts", 6 + "types": "./src/index.ts", 7 + "dependencies": { 8 + "handlebars": "^4.7.8" 9 + }, 10 + "devDependencies": { 11 + "@cv/tsconfig": "*", 12 + "@types/node": "^22.7.5", 13 + "typescript": "^5.3.3" 14 + } 15 + }
+20
packages/cv-renderer/src/document.ts
··· 1 + export const wrapInDocument = (body: string, css: string): string => 2 + `<!DOCTYPE html> 3 + <html lang="en"> 4 + <head> 5 + <meta charset="UTF-8"> 6 + <meta name="viewport" content="width=device-width, initial-scale=1.0"> 7 + <style> 8 + *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; } 9 + body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; } 10 + @media print { 11 + body { print-color-adjust: exact; -webkit-print-color-adjust: exact; margin: 1cm; } 12 + @page { margin: 0; } 13 + } 14 + ${css} 15 + </style> 16 + </head> 17 + <body> 18 + ${body} 19 + </body> 20 + </html>`;
+34
packages/cv-renderer/src/engines/handlebars.engine.ts
··· 1 + import Handlebars from "handlebars"; 2 + import type { TemplateEngine } from "../template-engine.interface"; 3 + 4 + const createHandlebarsInstance = (): typeof Handlebars => { 5 + const instance = Handlebars.create(); 6 + 7 + instance.registerHelper( 8 + "hasItems", 9 + (arr: unknown) => Array.isArray(arr) && arr.length > 0, 10 + ); 11 + 12 + instance.registerHelper( 13 + "join", 14 + (arr: unknown, separator: string) => 15 + Array.isArray(arr) ? arr.join(separator) : "", 16 + ); 17 + 18 + instance.registerHelper( 19 + "eq", 20 + (a: unknown, b: unknown) => a === b, 21 + ); 22 + 23 + return instance; 24 + }; 25 + 26 + export class HandlebarsEngine implements TemplateEngine { 27 + readonly name = "handlebars"; 28 + private readonly hbs = createHandlebarsInstance(); 29 + 30 + render(template: string, context: object): string { 31 + const compiled = this.hbs.compile(template); 32 + return compiled(context); 33 + } 34 + }
+3
packages/cv-renderer/src/index.ts
··· 1 + export type { TemplateEngine } from "./template-engine.interface"; 2 + export { HandlebarsEngine } from "./engines/handlebars.engine"; 3 + export { wrapInDocument } from "./document";
+4
packages/cv-renderer/src/template-engine.interface.ts
··· 1 + export interface TemplateEngine { 2 + readonly name: string; 3 + render(template: string, context: object): string; 4 + }
+8
packages/cv-renderer/tsconfig.json
··· 1 + { 2 + "extends": "@cv/tsconfig/tsconfig.library.json", 3 + "compilerOptions": { 4 + "outDir": "./dist", 5 + "rootDir": "./src" 6 + }, 7 + "include": ["src/**/*"] 8 + }