1
0
mirror of https://github.com/XFox111/my-website.git synced 2026-04-22 07:28:01 +03:00

feat: ATS-compliant resume download links

This commit is contained in:
2025-05-11 17:21:53 +00:00
parent 9cf3901307
commit 9a4d6966d0
4 changed files with 35 additions and 13 deletions
+8 -4
View File
@@ -5,18 +5,22 @@ import { PDFDocument, PDFPage } from "pdf-lib";
export async function GET(req: NextRequest): Promise<Response>
{
const type: string | null = req.nextUrl.searchParams.get("type");
const isAts: boolean = req.nextUrl.searchParams.get("ats") === "true";
const resume: Resume | undefined = findResume(type);
const url: string | undefined = isAts ? process.env.ATS_RESUME_URL : process.env.RESUME_URL;
if (!resume)
return error(400, "'type' parameter is invalid");
if (!process.env.RESUME_URL)
const fileName: string = (isAts ? "(ATS) " + resume.fileName : resume.fileName).replaceAll("\"", "'");
if (!url)
return error(500, "Cannot find file location.");
try
{
// Fetch the PDF file from the remote URL using the fetch API
const response: Response = await fetch(process.env.RESUME_URL as string);
const response: Response = await fetch(url);
if (!response.ok)
return error(500, "Failed to fetch PDF file");
@@ -30,7 +34,7 @@ export async function GET(req: NextRequest): Promise<Response>
const [page, refs]: PDFPage[] = await newDoc.copyPages(srcDoc, [resume.pageIndex, srcDoc.getPageCount() - 1]);
newDoc.addPage(page);
if (process.env.RESUME_HAS_REFS === "true")
if (process.env.RESUME_HAS_REFS === "true" && isAts)
newDoc.addPage(refs);
// Serialize the new PDF document
@@ -43,7 +47,7 @@ export async function GET(req: NextRequest): Promise<Response>
// Set response headers for PDF file
headers: {
"Content-Type": "application/pdf",
"Content-Disposition": `inline; filename="${resume.fileName.replaceAll("\"", "'")}.pdf"`
"Content-Disposition": `inline; filename="${fileName}.pdf"`
}
}
);
+10
View File
@@ -20,6 +20,16 @@
grid-auto-columns: 1fr;
gap: $spacingXL;
.buttonContainer
{
@include flex(column);
}
.atsLink
{
@include body1();
}
.button
{
flex-flow: column;
+15 -8
View File
@@ -21,15 +21,22 @@ const ResumePage: React.FC = () => (
<h1>Who are you looking for?</h1>
<div className={ cls.resumeButtons }>
{ resumeList.map(i =>
<Button key={ i.key } className={ cls.button }
href={ `/resume/download?type=${i.key}` } download
icon={
<Image className={ cls.image } src={ i.image.src } priority draggable={ false }
aria-hidden alt={ i.image.alt } />
}>
<div key={ i.key } className={ cls.buttonContainer }>
<Button className={ cls.button }
href={ `/resume/download?type=${i.key}` } download
icon={
<Image className={ cls.image } src={ i.image.src } priority draggable={ false }
aria-hidden alt={ i.image.alt } />
}>
{ i.label }
</Button>
{ i.label }
</Button>
{ process.env.ATS_RESUME_URL &&
<a className={ cls.atsLink } href={ `/resume/download?type=${i.key}&ats=true` } download>
ATS-compatible version
</a>
}
</div>
) }
</div>