Skip to content

feat: add URL support for projects, update PDF generation #129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/components/Resume/ResumeControlBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const ResumeControlBar = ({

// Hook to update pdf when document changes
useEffect(() => {
update();
update(document);
}, [update, document]);

return (
Expand Down
14 changes: 12 additions & 2 deletions src/app/components/Resume/ResumePDF/ResumePDFProject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,40 @@ import {
ResumePDFSection,
ResumePDFBulletList,
ResumePDFText,
ResumePDFLink,
} from "components/Resume/ResumePDF/common";
import { styles, spacing } from "components/Resume/ResumePDF/styles";
import type { ResumeProject } from "lib/redux/types";
import { formatUrl } from "./common/utils";

export const ResumePDFProject = ({
heading,
projects,
themeColor,
isPDF
}: {
heading: string;
projects: ResumeProject[];
themeColor: string;
isPDF: boolean;
}) => {
return (
<ResumePDFSection themeColor={themeColor} heading={heading}>
{projects.map(({ project, date, descriptions }, idx) => (
{projects.map(({ project, date, descriptions, url }, idx) => (
<View key={idx}>
<View
style={{
...styles.flexRowBetween,
marginTop: spacing["0.5"],
}}
>
<ResumePDFText bold={true}>{project}</ResumePDFText>
{formatUrl(url) ? (
<ResumePDFLink src={formatUrl(url)} isPDF={isPDF}>
<ResumePDFText bold={true}>{project}</ResumePDFText>
</ResumePDFLink>
) : (
<ResumePDFText>{project}</ResumePDFText>
)}
<ResumePDFText>{date}</ResumePDFText>
</View>
<View style={{ ...styles.flexCol, marginTop: spacing["0.5"] }}>
Expand Down
27 changes: 27 additions & 0 deletions src/app/components/Resume/ResumePDF/common/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Formats a URL string to ensure it has a valid protocol.
*
* @param input - The URL string to format
* @returns A properly formatted URL string:
* - Returns empty string if input is undefined or invalid
* - Returns the full URL if input is a valid URL
* - Adds 'https://' prefix for simple domain names (e.g., 'example.com')
*/
export function formatUrl(input: string | undefined): string {
if (!input) {
return '';
}

const trimmedInput = input.trim();

try {
const url = new URL(trimmedInput);
return url.href;
} catch (error) {
if (/^[a-zA-Z0-9-]+\.[a-zA-Z]{2,}$/.test(trimmedInput)) {
return `https://${trimmedInput}`;
}
}

return '';
}
1 change: 1 addition & 0 deletions src/app/components/Resume/ResumePDF/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export const ResumePDF = ({
heading={formToHeading["projects"]}
projects={projects}
themeColor={themeColor}
isPDF={isPDF}
/>
),
skills: () => (
Expand Down
10 changes: 9 additions & 1 deletion src/app/components/ResumeForm/ProjectsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const ProjectsForm = () => {

return (
<Form form="projects" addButtonText="Add Project">
{projects.map(({ project, date, descriptions }, idx) => {
{projects.map(({ project, date, descriptions, url }, idx) => {
const handleProjectChange = (
...[
field,
Expand Down Expand Up @@ -53,6 +53,14 @@ export const ProjectsForm = () => {
onChange={handleProjectChange}
labelClassName="col-span-2"
/>
<Input
name="url"
label="Project URL"
placeholder="Enter a valid URL"
value={url}
onChange={handleProjectChange}
labelClassName="col-span-full"
/>
<BulletListTextarea
name="descriptions"
label="Description"
Expand Down
1 change: 1 addition & 0 deletions src/app/lib/redux/resumeSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const initialProject: ResumeProject = {
project: "",
date: "",
descriptions: [],
url: ""
};

export const initialFeaturedSkill: FeaturedSkill = { skill: "", rating: 4 };
Expand Down
1 change: 1 addition & 0 deletions src/app/lib/redux/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export interface ResumeProject {
project: string;
date: string;
descriptions: string[];
url: string;
}

export interface FeaturedSkill {
Expand Down