Skip to content

Commit

Permalink
Frontend fix
Browse files Browse the repository at this point in the history
  • Loading branch information
gxjansen committed Dec 20, 2024
1 parent 13e5466 commit 707d817
Show file tree
Hide file tree
Showing 25 changed files with 118 additions and 14 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ pnpm-debug.log*

# macOS-specific files
.DS_Store

# CLine instructions
.clinerules
63 changes: 63 additions & 0 deletions migrate-images.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import fs from 'fs/promises';
import path from 'path';

const FREELANCERS_CONTENT_DIR = 'src/content/freelancers';
const FREELANCERS_IMAGES_DIR = 'src/images/freelancers';

async function migrateImages() {
try {
// Get all freelancer YAML files
const files = await fs.readdir(FREELANCERS_CONTENT_DIR);
const yamlFiles = files.filter(file => file.endsWith('.yaml'));

for (const yamlFile of yamlFiles) {
// Skip the new format file
if (yamlFile === 'onofrei-andrei-codrut.yaml') continue;

// Read YAML content
const yamlPath = path.join(FREELANCERS_CONTENT_DIR, yamlFile);
const content = await fs.readFile(yamlPath, 'utf8');

// Extract current photo path
const photoMatch = content.match(/photo: (.+\.jpe?g)/);
if (!photoMatch) {
console.log(`No photo found in ${yamlFile}`);
continue;
}

const oldPhotoName = photoMatch[1];
const oldPhotoPath = path.join(FREELANCERS_IMAGES_DIR, oldPhotoName);

// Create new directory name from YAML filename (without extension)
const dirName = yamlFile.replace('.yaml', '').toLowerCase().replace(/ /g, '-');
const newDirPath = path.join(FREELANCERS_IMAGES_DIR, dirName);

// Create new directory
await fs.mkdir(newDirPath, { recursive: true });

// Get file extension from original image
const ext = path.extname(oldPhotoName);
const newPhotoPath = path.join(newDirPath, `photo${ext}`);

// Move and rename the image
await fs.rename(oldPhotoPath, newPhotoPath);

// Update YAML content with new photo path
const newContent = content.replace(
/photo: .+/,
`photo: "${dirName}/photo${ext}"`
);

// Write updated YAML
await fs.writeFile(yamlPath, newContent, 'utf8');

console.log(`Migrated ${yamlFile} and its image`);
}

console.log('Migration completed successfully');
} catch (error) {
console.error('Migration failed:', error);
}
}

migrateImages();
4 changes: 2 additions & 2 deletions src/components/FreelancerCard.astro
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type Skill = string;
const hasCertifications = hasSprykerCertifications(freelancer.sprykerCertifications);
// Import all images at build time with proper typing
const imageFiles: Record<string, ImageMetadata> = import.meta.glob('/src/images/freelancers/*.{jpeg,jpg,png,gif}', {
const imageFiles: Record<string, ImageMetadata> = import.meta.glob('/src/images/freelancers/**/*.{jpeg,jpg,png,gif}', {
eager: true,
import: 'default'
});
Expand All @@ -40,7 +40,7 @@ async function getFreelancerImage(photoPath: string) {
const freelancerSlug = generateNameSlug(freelancer.firstName, freelancer.lastName);
// Construct the correct image path
const imagePath = `/src/images/freelancers/${freelancer.photo}`;
const imagePath = freelancer.photo;
// Get the image from our glob with type checking
const freelancerImage: ImageMetadata | undefined = imageFiles[imagePath];
Expand Down
2 changes: 1 addition & 1 deletion src/content/freelancers/Andrey Lidokhover.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
firstName: Andrey
lastName: Lidokhover
photo: andrey-lidokhover.jpg
photo: /src/images/freelancers/andrey-lidokhover/photo.jpg
headline: Senior Spryker Backend Developer
availability: November 2024, fulltime
location: Hamburg
Expand Down
2 changes: 1 addition & 1 deletion src/content/freelancers/Constantin Iordan.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
firstName: Constantin
lastName: Iordan
photo: Constantin-Iordan.jpg
photo: /src/images/freelancers/constantin-iordan/photo.jpg
headline: Senior PHP Developer
availability: January 2025, 8h/day, 5 days/week
location: Brasov
Expand Down
2 changes: 1 addition & 1 deletion src/content/freelancers/David Greiner.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
firstName: David
lastName: Greiner
photo: david_greiner_spryker_freelancer.jpg
photo: /src/images/freelancers/david-greiner/photo.jpg
headline: Senior Spryker Backend Developer
availability: Immediate
location: Germany
Expand Down
2 changes: 1 addition & 1 deletion src/content/freelancers/Evgeny Nekhamkin.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
firstName: Evgeny
lastName: Nekhamkin
photo: evgeny-nekhamkin.jpg
photo: /src/images/freelancers/evgeny-nekhamkin/photo.jpg
headline: Senior Webdeveloper & Architect
availability: Mid October / 36-40 Hours
location: Hamburg
Expand Down
2 changes: 1 addition & 1 deletion src/content/freelancers/Filip Galic.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
firstName: Filip
lastName: Galic
photo: filip-galic.jpeg
photo: /src/images/freelancers/filip-galic/photo.jpeg
headline: Spryker engineer
availability: Immediately
location: Bosnia and Herzegovina, Siroki Brijeg
Expand Down
2 changes: 1 addition & 1 deletion src/content/freelancers/Ivan Jurisic.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
firstName: Ivan
lastName: Jurisic
photo: ivan-jurisic.jpg
photo: /src/images/freelancers/ivan-jurisic/photo.jpg
headline: Spryker developer
availability: Immediately
location: Makarska, Croatia
Expand Down
2 changes: 1 addition & 1 deletion src/content/freelancers/Jan Kovacs.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
firstName: Jan
lastName: Kovács
photo: jan-kovacs.jpg
photo: /src/images/freelancers/jan-kovacs/photo.jpg
headline: Experienced Software Engineer & Leader
availability: November 2024, 40 hours/week
location: Hamburg
Expand Down
2 changes: 1 addition & 1 deletion src/content/freelancers/Javier Benito.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
firstName: Javier
lastName: Benito
photo: javier-benito.jpg
photo: /src/images/freelancers/javier-benito/photo.jpg
headline: Senior Software Engineer
availability: Immediately
location: Madrid
Expand Down
2 changes: 1 addition & 1 deletion src/content/freelancers/Vasily Rodin.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
firstName: Vasily
lastName: Rodin
photo: vasily-rodin.jpg
photo: /src/images/freelancers/vasily-rodin/photo.jpg
headline: Senior Spryker Developer & Tech Lead
availability: 2025, usually 8h per day
location: Berlin
Expand Down
2 changes: 1 addition & 1 deletion src/content/freelancers/Volodymyr Rychenko.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
firstName: Volodymyr
lastName: Hrychenko
photo: volodymyr-rychenko.jpg
photo: /src/images/freelancers/volodymyr-rychenko/photo.jpg
headline: Spryker Developer & Solution Architect
availability: Fulltime
location: Warsaw
Expand Down
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 src/pages/jobs/[slug].astro
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import keystaticConfig from '../../../keystatic.config';
import type { Freelancer, KeystaticFreelancer } from '../../types.ts';
// Import all images at build time with proper typing
const imageFiles: Record<string, ImageMetadata> = import.meta.glob('/src/images/freelancers/*.{jpeg,jpg,png,gif}', {
const imageFiles: Record<string, ImageMetadata> = import.meta.glob('/src/images/freelancers/**/*.{jpeg,jpg,png,gif}', {
eager: true,
import: 'default'
});
Expand Down Expand Up @@ -61,7 +61,7 @@ const pageTitle = `${`${freelancer.firstName} ${freelancer.lastName}`} - Spryker
const hasCertifications = hasSprykerCertifications(freelancer.sprykerCertifications);
// Construct the correct image path
const imagePath = `/src/images/freelancers/${freelancer.photo}`;
const imagePath = freelancer.photo;
// Get the image from our glob
const freelancerImage: ImageMetadata | undefined = imageFiles[imagePath];
Expand Down
38 changes: 38 additions & 0 deletions update-paths.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import fs from 'fs/promises';
import path from 'path';

const FREELANCERS_CONTENT_DIR = 'src/content/freelancers';

async function updatePaths() {
try {
// Get all freelancer YAML files
const files = await fs.readdir(FREELANCERS_CONTENT_DIR);
const yamlFiles = files.filter(file => file.endsWith('.yaml'));

for (const yamlFile of yamlFiles) {
// Skip the new format file
if (yamlFile === 'onofrei-andrei-codrut.yaml') continue;

// Read YAML content
const yamlPath = path.join(FREELANCERS_CONTENT_DIR, yamlFile);
const content = await fs.readFile(yamlPath, 'utf8');

// Update photo path to include /src prefix
const newContent = content.replace(
/photo: "([^"]+)"/,
'photo: /src/images/freelancers/$1'
);

// Write updated YAML
await fs.writeFile(yamlPath, newContent, 'utf8');

console.log(`Updated path in ${yamlFile}`);
}

console.log('Path updates completed successfully');
} catch (error) {
console.error('Update failed:', error);
}
}

updatePaths();

0 comments on commit 707d817

Please sign in to comment.