Skip to content

Commit

Permalink
Added domains to job descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
kshehadeh committed Jan 5, 2025
1 parent cb12d87 commit 31b5020
Show file tree
Hide file tree
Showing 13 changed files with 71 additions and 13 deletions.
49 changes: 44 additions & 5 deletions resume/resume.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,35 @@ function getPropertyMultiSelect(
return null;
}

function getPropertyRelation(
property: PageObjectResponse['properties'][number],
lookupRows: PageObjectResponse[]
) {
if (property.type === 'relation') {
return property.relation.map(option => {
const row = lookupRows.find(row => row.id === option.id);
if (row) {
const ob: Record<string, unknown> = {};
for (const key in row.properties) {
if (row.properties[key].type === 'title') {
ob[key] = getPropertyText(row.properties[key]);
} else if (row.properties[key].type === 'rich_text') {
ob[key] = getPropertyText(row.properties[key]);
} else if (row.properties[key].type === 'number') {
ob[key] = row.properties[key].number;
} else if (row.properties[key].type === 'select') {
ob[key] = row.properties[key].select?.name;
} else if (row.properties[key].type === 'multi_select') {
ob[key] = row.properties[key].multi_select.map(option => option.name);
}
}
return ob
}
});
}
return null;
}

// Retrieves a value from the "About" section by key
function getAboutValueWithKey(rows: PageObjectResponse[], key: string) {
const row = rows.find(row => getPropertyText(row.properties.Name) === key);
Expand Down Expand Up @@ -199,9 +228,16 @@ function getPropertyDate(property: PageObjectResponse['properties'][number]) {
return { start: null, end: null, duration: null };
}

async function getSkillsList(databases: Record<string, ChildDatabaseBlockObjectResponse>) {
return (await getRows(
databases['Skills'].id,
)) as PageObjectResponse[];
}

// Builds the experience list
async function buildExperienceList(
data: Record<string, ChildDatabaseBlockObjectResponse>,
skills: PageObjectResponse[]
) {
spinner.text = 'Reading company data';
const companies = (await getRows(
Expand Down Expand Up @@ -251,11 +287,13 @@ async function buildExperienceList(
start: start?.toFormat('MMMM yyyy'),
end: end?.toFormat('MMMM yyyy') ?? 'Present',
duration: toHuman(duration, !end),
domain: getPropertyRelation(exp.properties.Domain, skills),
bullets: bulletsForExperience.map(bullet => {
return {
text: getPropertyText(bullet.properties.Name),
skills: getPropertyMultiSelect(
bullet.properties.Skills,
skills: getPropertyRelation(
bullet.properties.Skill,
skills
),
};
}),
Expand Down Expand Up @@ -323,7 +361,8 @@ async function buildEducationList(
{},
);

const experiences = await buildExperienceList(databases);
const skills = await getSkillsList(databases);
const experiences = await buildExperienceList(databases, skills);
const education = await buildEducationList(databases);
const about = await buildAboutInfo(databases);

Expand All @@ -341,10 +380,10 @@ async function buildEducationList(
education,
};

const outputPath = path.join(rootDir, '/resume.json');
const outputPath = path.join(rootDir, '/typst/resume.json');
fs.writeFileSync(outputPath, JSON.stringify(data, null, 2));

const pathToTemplate = path.join(rootDir, 'main.typ');
const pathToTemplate = path.join(rootDir, '/typst/main.typ');
const output = q()
.add(`typst compile ${pathToTemplate} ${outputFile}`)
.run()
Expand Down
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
4 changes: 2 additions & 2 deletions resume/main.typ → resume/typst/main.typ
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#import "resume.typ": *

#let data = json("resume.json")
#let data = json("./resume.json")

#show: resume.with(
name: data.name,
Expand Down Expand Up @@ -28,7 +28,7 @@
#company-heading(company.company, start: company.start, end: company.end)[
#for exp in company.experience [
#let bullets = exp.bullets.map(bullet => bullet.text)
#job-heading(exp.title, start: exp.duration, list(..bullets))
#job-heading(exp.title, start: exp.duration, domain: exp.domain.at(0).Name, list(..bullets))
]
]
]
Expand Down
31 changes: 25 additions & 6 deletions resume/resume.typ → resume/typst/resume.typ
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,11 @@
context text(
weight: COMPANY_NAME_WEIGHT,
size: COMPANY_NAME_SIZE,
font: __get("heading-font"),
font: __get("heading-font"),
name
),


// third column, dots
if start != none {
repeat(h(0.3em) + "." + h(0.3em))
Expand Down Expand Up @@ -178,15 +179,15 @@
// Alias to school heading
#let school-heading = company-heading

#let job-heading(title, location: none, start: none, end: none, comment: none, body) = {
#let job-heading(title, location: none, start: none, end: none, domain: none, comment: none, body) = {
block(
above: JOB_BLOCK_ABOVE,
below: JOB_BLOCK_BELOW,
breakable: true,

// heading
grid(
columns: (auto, auto, auto, 1fr, auto),
columns: (auto, auto, auto, auto, 1fr, auto),
gutter: 1em,
align: (left + horizon, right + horizon),

Expand All @@ -200,10 +201,28 @@
title
),

// second column, job comment ellipsisd

// domain
if domain != none {
context box(
fill: black,
outset: 0.2em,
inset: 0.2em,
radius: 0.2em,
text(
weight: "light",
size: 0.7em,
fill: white,
font: __get("heading-font"),
domain
)
)
},

// job comment ellipsisd
if comment != none { [ ... ] },

// third column, job comment ellipsis
// job comment ellipsis
if comment != none { [ #comment ] },

// fourth column, hfill
Expand All @@ -225,7 +244,7 @@
}
),

grid.cell(colspan: 5, body)
grid.cell(colspan: 6, body)
)
)
}
Expand Down
File renamed without changes.

0 comments on commit 31b5020

Please sign in to comment.