Skip to content

Add "move-images" script #14

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
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
"name": "projects-repository",
"version": "0.1.0",
"private": true,
"type": "module",

"scripts": {
"dev": "next dev --turbopack",
"build": "next build",
"move-project-images": "node scripts/move-project-images.js",
"build": "npm run move-project-images && next build",
"start": "next start",
"lint": "next lint",
"check": "prettier --check '{src,tests}/**/*.{css,scss,html,js,tsx}'",
Expand Down
12 changes: 12 additions & 0 deletions public/project-images/another-project/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
id: "another-project"
title: "Another Project"
description: "This is a description of another project that showcases my skills in React Native and AR technology."
author: "Matthew MacRae-Bovell"
tags:
- Example Tag
- React Native
- AR
hasUI: true
githubUrl: "https://github.com/sarahchen/campus-nav"
---
16 changes: 16 additions & 0 deletions public/project-images/smart-campus-app/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
id: "smart-campus-app"
title: "Smart Campus Navigation App"
description: "A React Native mobile app that helps students navigate Carleton's campus using AR and real-time location services."
author: "Sarah Chen"
tags:
- React Native
- AR
- Mobile
- TypeScript
- Firebase
hasUI: true
previewImageUrl: "./placeholder.svg"
githubUrl: "https://github.com/sarahchen/campus-nav"
liveUrl: "https://campus-nav.app"
---
42 changes: 42 additions & 0 deletions scripts/move-project-images.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import fs from "fs";
import path from "path";
import { fileURLToPath } from "url";

// Get the current file URL and convert it to a path
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);


const srcDir = path.join(__dirname, "..", "content", "projects");
const destDir = path.join(__dirname, "..", "public", "project-images");

function copyImages(srcPath) {
fs.readdir(srcPath, (err, projects) => {
if (err) throw err;

projects.forEach((project) => {
const projectPath = path.join(srcPath, project);

const srcImagePath = path.join(projectPath, "index.md");
const destImagePath = path.join(
destDir,
project,
"index.md",
);

// Check if image.png exists
if (fs.existsSync(srcImagePath)) {
// Create destination directory if it doesn't exist
fs.mkdirSync(path.dirname(destImagePath), { recursive: true });

// Copy the image
fs.copyFile(srcImagePath, destImagePath, (err) => {
if (err) throw err;
console.log(`Copied: ${srcImagePath} to ${destImagePath}`);
});
}
});
});
}

copyImages(srcDir);